Prompt:
Schema:
  departments (alias: dept)(code, salary, value, type)
  categories(type, code, id, salary)
Task: Retrieve name from departments with value above the AVG(value) of categories rows sharing the same type.
SQL:

SELECT name FROM departments AS dept
WHERE value > (
    SELECT AVG(value) FROM categories AS txn
    WHERE txn.type = dept.type
);


Prompt:
Schema:
  departments (alias: dept)(status, code, name, salary)
  transactions(name, salary, date, level)
Task: Retrieve name from departments that have at least one corresponding entry in transactions sharing the same level.
SQL:

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.level = dept.level
);


Prompt:
Schema:
  employees (alias: emp)(id, name, level, value)
  customers(name, amount, type, salary)
Task: Retrieve code from employees whose level is found in customers rows where level matches the outer record.
SQL:

SELECT code FROM employees AS emp
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.level = emp.level
);


Prompt:
Schema:
  schedules (alias: schd)(date, status, code, id)
  customers(code, amount, salary, value)
Task: Find amount from schedules where salary exceeds the minimum amount from customers for the same code.
SQL:

SELECT amount FROM schedules AS schd
WHERE salary > (
    SELECT MIN(amount) FROM customers AS catg
    WHERE catg.code = schd.code
);


Prompt:
Schema:
  tasks (alias: tsk)(code, amount, date, status)
  sales(name, type, value, status)
Task: Retrieve salary from tasks with salary above the COUNT(value) of sales rows sharing the same id.
SQL:

SELECT salary FROM tasks AS tsk
WHERE salary > (
    SELECT COUNT(value) FROM sales AS empl
    WHERE empl.id = tsk.id
);


Prompt:
Schema:
  accounts (alias: acct)(level, type, salary, date)
  products(level, status, value, code)
Task: Retrieve id from accounts that have at least one corresponding entry in products sharing the same status.
SQL:

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.status = acct.status
);


Prompt:
Schema:
  accounts (alias: acct)(status, value, level, name)
  managers(amount, type, code, value)
Task: Find value from accounts where a matching record exists in managers with the same level.
SQL:

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM managers AS txn
    WHERE txn.level = acct.level
);


Prompt:
Schema:
  departments (alias: dept)(status, salary, amount, value)
  employees(value, date, salary, type)
Task: Retrieve id from departments that have at least one corresponding entry in employees sharing the same code.
SQL:

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.code = dept.code
);


Prompt:
Schema:
  invoices (alias: inv)(salary, type, status, level)
  tasks(date, status, id, level)
Task: Select value from invoices where code exists in tasks for the same code.
SQL:

SELECT value FROM invoices AS inv
WHERE code IN (
    SELECT code FROM tasks AS dept
    WHERE dept.code = inv.code
);


Prompt:
Schema:
  shipments (alias: shp)(code, amount, salary, status)
  regions(level, type, status, date)
Task: Find id from shipments where status appears in regions entries with matching id.
SQL:

SELECT id FROM shipments AS shp
WHERE status IN (
    SELECT status FROM regions AS catg
    WHERE catg.id = shp.id
);


Prompt:
Schema:
  orders (alias: ord)(level, type, value, amount)
  transactions(amount, level, date, status)
Task: Find salary from orders where type appears in transactions entries with matching type.
SQL:

SELECT salary FROM orders AS ord
WHERE type IN (
    SELECT type FROM transactions AS catg
    WHERE catg.type = ord.type
);


Prompt:
Schema:
  schedules (alias: schd)(id, status, type, date)
  categories(amount, name, level, id)
Task: Find id from schedules where a matching record exists in categories with the same id.
SQL:

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.id = schd.id
);


Prompt:
Schema:
  customers (alias: cust)(name, id, code, status)
  sales(level, amount, date, code)
Task: Find code from customers where level appears in sales entries with matching level.
SQL:

SELECT code FROM customers AS cust
WHERE level IN (
    SELECT level FROM sales AS empl
    WHERE empl.level = cust.level
);


Prompt:
Schema:
  accounts (alias: acct)(amount, status, level, id)
  regions(level, status, id, name)
Task: Retrieve amount from accounts with salary above the COUNT(value) of regions rows sharing the same type.
SQL:

SELECT amount FROM accounts AS acct
WHERE salary > (
    SELECT COUNT(value) FROM regions AS emp
    WHERE emp.type = acct.type
);


Prompt:
Schema:
  regions (alias: rgn)(type, value, amount, status)
  schedules(id, date, code, amount)
Task: Retrieve code from regions whose id is found in schedules rows where status matches the outer record.
SQL:

SELECT code FROM regions AS rgn
WHERE id IN (
    SELECT id FROM schedules AS dept
    WHERE dept.status = rgn.status
);


Prompt:
Schema:
  shipments (alias: shp)(amount, date, code, level)
  transactions(salary, date, name, code)
Task: Find amount from shipments where id appears in transactions entries with matching code.
SQL:

SELECT amount FROM shipments AS shp
WHERE id IN (
    SELECT id FROM transactions AS shp
    WHERE shp.code = shp.code
);


Prompt:
Schema:
  requests (alias: ordr)(level, id, salary, amount)
  orders(name, date, value, id)
Task: Find name from requests where a matching record exists in orders with the same type.
SQL:

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.type = ordr.type
);


Prompt:
Schema:
  requests (alias: ordr)(salary, name, level, value)
  categories(level, amount, code, date)
Task: Retrieve id from requests that have at least one corresponding entry in categories sharing the same code.
SQL:

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.code = ordr.code
);


Prompt:
Schema:
  schedules (alias: schd)(code, level, date, value)
  orders(salary, level, type, amount)
Task: Retrieve salary from schedules that have at least one corresponding entry in orders sharing the same status.
SQL:

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.status = schd.status
);


Prompt:
Schema:
  orders (alias: ord)(level, name, status, type)
  departments(salary, amount, id, level)
Task: Retrieve amount from orders that have at least one corresponding entry in departments sharing the same level.
SQL:

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.level = ord.level
);


Prompt:
Schema:
  products (alias: prod)(salary, name, value, level)
  accounts(status, code, type, amount)
Task: Retrieve name from products that have at least one corresponding entry in accounts sharing the same status.
SQL:

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.status = prod.status
);


Prompt:
Schema:
  orders (alias: ord)(id, type, amount, name)
  regions(salary, name, id, type)
Task: Find name from orders where a matching record exists in regions with the same level.
SQL:

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = ord.level
);


Prompt:
Schema:
  items (alias: lne)(salary, value, status, id)
  staff(amount, type, salary, name)
Task: Select id from items where level exists in staff for the same id.
SQL:

SELECT id FROM items AS lne
WHERE level IN (
    SELECT level FROM staff AS dept
    WHERE dept.id = lne.id
);


Prompt:
Schema:
  departments (alias: dept)(amount, salary, name, id)
  projects(name, code, amount, value)
Task: Retrieve value from departments with value above the AVG(amount) of projects rows sharing the same status.
SQL:

SELECT value FROM departments AS dept
WHERE value > (
    SELECT AVG(amount) FROM projects AS ordr
    WHERE ordr.status = dept.status
);


Prompt:
Schema:
  products (alias: prod)(name, date, id, amount)
  tasks(id, status, value, amount)
Task: Retrieve amount from products that have at least one corresponding entry in tasks sharing the same level.
SQL:

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS prj
    WHERE prj.level = prod.level
);


Prompt:
Schema:
  transactions (alias: txn)(salary, date, id, amount)
  departments(id, amount, value, code)
Task: Find code from transactions where value exceeds the minimum salary from departments for the same type.
SQL:

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT MIN(salary) FROM departments AS empl
    WHERE empl.type = txn.type
);


Prompt:
Schema:
  regions (alias: rgn)(salary, type, status, level)
  orders(id, code, amount, value)
Task: Retrieve salary from regions that have at least one corresponding entry in orders sharing the same type.
SQL:

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.type = rgn.type
);


Prompt:
Schema:
  products (alias: prod)(code, value, level, id)
  items(amount, type, salary, code)
Task: Retrieve salary from products that have at least one corresponding entry in items sharing the same id.
SQL:

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM items AS catg
    WHERE catg.id = prod.id
);


Prompt:
Schema:
  regions (alias: rgn)(name, code, id, status)
  orders(date, name, status, code)
Task: Find name from regions where a matching record exists in orders with the same level.
SQL:

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = rgn.level
);


Prompt:
Schema:
  requests (alias: ordr)(status, salary, name, value)
  regions(value, date, amount, name)
Task: Find value from requests where a matching record exists in regions with the same code.
SQL:

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.code = ordr.code
);


Prompt:
Schema:
  accounts (alias: acct)(type, salary, code, status)
  categories(level, type, amount, value)
Task: Retrieve code from accounts whose level is found in categories rows where level matches the outer record.
SQL:

SELECT code FROM accounts AS acct
WHERE level IN (
    SELECT level FROM categories AS rgn
    WHERE rgn.level = acct.level
);


Prompt:
Schema:
  shipments (alias: shp)(date, salary, value, code)
  accounts(value, status, code, salary)
Task: Find id from shipments where amount exceeds the minimum amount from accounts for the same id.
SQL:

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS shp
    WHERE shp.id = shp.id
);


Prompt:
Schema:
  staff (alias: empl)(name, status, date, value)
  managers(value, id, amount, status)
Task: Find code from staff where a matching record exists in managers with the same type.
SQL:

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM managers AS brc
    WHERE brc.type = empl.type
);


Prompt:
Schema:
  transactions (alias: txn)(level, value, date, type)
  staff(value, salary, code, status)
Task: Find salary from transactions where salary exceeds the total amount from staff for the same code.
SQL:

SELECT salary FROM transactions AS txn
WHERE salary > (
    SELECT SUM(amount) FROM staff AS brc
    WHERE brc.code = txn.code
);


Prompt:
Schema:
  invoices (alias: inv)(amount, level, value, type)
  employees(amount, type, level, status)
Task: Find id from invoices where a matching record exists in employees with the same code.
SQL:

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.code = inv.code
);


Prompt:
Schema:
  categories (alias: catg)(salary, level, type, name)
  schedules(code, type, amount, salary)
Task: Find value from categories where salary exceeds the maximum amount from schedules for the same status.
SQL:

SELECT value FROM categories AS catg
WHERE salary > (
    SELECT MAX(amount) FROM schedules AS inv
    WHERE inv.status = catg.status
);


Prompt:
Schema:
  items (alias: lne)(level, status, amount, date)
  schedules(salary, date, amount, level)
Task: Retrieve code from items whose type is found in schedules rows where id matches the outer record.
SQL:

SELECT code FROM items AS lne
WHERE type IN (
    SELECT type FROM schedules AS dept
    WHERE dept.id = lne.id
);


Prompt:
Schema:
  sales (alias: sale)(date, id, code, amount)
  items(salary, amount, value, name)
Task: Find id from sales where value exceeds the average amount from items for the same level.
SQL:

SELECT id FROM sales AS sale
WHERE value > (
    SELECT AVG(amount) FROM items AS prod
    WHERE prod.level = sale.level
);


Prompt:
Schema:
  items (alias: lne)(amount, date, salary, name)
  accounts(salary, type, value, level)
Task: Retrieve amount from items with value above the MAX(amount) of accounts rows sharing the same id.
SQL:

SELECT amount FROM items AS lne
WHERE value > (
    SELECT MAX(amount) FROM accounts AS mgr
    WHERE mgr.id = lne.id
);


Prompt:
Schema:
  invoices (alias: inv)(amount, level, salary, status)
  managers(date, type, value, status)
Task: Find name from invoices where a matching record exists in managers with the same code.
SQL:

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM managers AS cust
    WHERE cust.code = inv.code
);


Prompt:
Schema:
  categories (alias: catg)(value, code, date, amount)
  tasks(type, salary, name, amount)
Task: Retrieve code from categories with value above the AVG(amount) of tasks rows sharing the same status.
SQL:

SELECT code FROM categories AS catg
WHERE value > (
    SELECT AVG(amount) FROM tasks AS emp
    WHERE emp.status = catg.status
);


Prompt:
Schema:
  categories (alias: catg)(code, value, amount, salary)
  regions(date, amount, name, code)
Task: Find name from categories where value exceeds the total value from regions for the same status.
SQL:

SELECT name FROM categories AS catg
WHERE value > (
    SELECT SUM(value) FROM regions AS rgn
    WHERE rgn.status = catg.status
);


Prompt:
Schema:
  invoices (alias: inv)(level, status, amount, code)
  schedules(id, level, type, date)
Task: Find id from invoices where a matching record exists in schedules with the same id.
SQL:

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM schedules AS dept
    WHERE dept.id = inv.id
);


Prompt:
Schema:
  categories (alias: catg)(code, date, type, id)
  requests(value, amount, status, salary)
Task: Find name from categories where a matching record exists in requests with the same level.
SQL:

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM requests AS schd
    WHERE schd.level = catg.level
);


Prompt:
Schema:
  tasks (alias: tsk)(value, status, level, salary)
  accounts(value, level, status, code)
Task: Find code from tasks where amount exceeds the maximum salary from accounts for the same status.
SQL:

SELECT code FROM tasks AS tsk
WHERE amount > (
    SELECT MAX(salary) FROM accounts AS catg
    WHERE catg.status = tsk.status
);


Prompt:
Schema:
  sales (alias: sale)(salary, name, level, status)
  employees(amount, type, name, id)
Task: Retrieve id from sales that have at least one corresponding entry in employees sharing the same status.
SQL:

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.status = sale.status
);


Prompt:
Schema:
  sales (alias: sale)(type, name, salary, level)
  requests(amount, type, date, code)
Task: Retrieve salary from sales that have at least one corresponding entry in requests sharing the same type.
SQL:

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM requests AS acct
    WHERE acct.type = sale.type
);


Prompt:
Schema:
  shipments (alias: shp)(code, value, type, amount)
  requests(status, date, code, name)
Task: Retrieve id from shipments with amount above the COUNT(amount) of requests rows sharing the same status.
SQL:

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM requests AS mgr
    WHERE mgr.status = shp.status
);


Prompt:
Schema:
  categories (alias: catg)(value, code, id, date)
  regions(amount, value, code, level)
Task: Retrieve code from categories whose type is found in regions rows where id matches the outer record.
SQL:

SELECT code FROM categories AS catg
WHERE type IN (
    SELECT type FROM regions AS catg
    WHERE catg.id = catg.id
);


Prompt:
Schema:
  projects (alias: prj)(name, id, code, salary)
  products(value, type, level, amount)
Task: Retrieve name from projects that have at least one corresponding entry in products sharing the same id.
SQL:

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.id = prj.id
);


Prompt:
Schema:
  transactions (alias: txn)(id, type, value, status)
  sales(amount, value, id, status)
Task: Select value from transactions where level exists in sales for the same level.
SQL:

SELECT value FROM transactions AS txn
WHERE level IN (
    SELECT level FROM sales AS schd
    WHERE schd.level = txn.level
);


Prompt:
Schema:
  categories (alias: catg)(amount, code, type, id)
  projects(salary, level, name, id)
Task: Find id from categories where a matching record exists in projects with the same status.
SQL:

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = catg.status
);


Prompt:
Schema:
  departments (alias: dept)(name, value, amount, salary)
  managers(value, name, salary, code)
Task: Retrieve amount from departments that have at least one corresponding entry in managers sharing the same code.
SQL:

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM managers AS ord
    WHERE ord.code = dept.code
);


Prompt:
Schema:
  transactions (alias: txn)(amount, level, type, value)
  shipments(date, salary, type, amount)
Task: Find value from transactions where a matching record exists in shipments with the same status.
SQL:

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.status = txn.status
);


Prompt:
Schema:
  staff (alias: empl)(status, code, amount, value)
  sales(id, name, type, level)
Task: Select name from staff where id exists in sales for the same status.
SQL:

SELECT name FROM staff AS empl
WHERE id IN (
    SELECT id FROM sales AS shp
    WHERE shp.status = empl.status
);


Prompt:
Schema:
  invoices (alias: inv)(type, value, status, level)
  branches(value, id, type, date)
Task: Retrieve name from invoices that have at least one corresponding entry in branches sharing the same level.
SQL:

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS tsk
    WHERE tsk.level = inv.level
);


Prompt:
Schema:
  managers (alias: mgr)(type, code, date, name)
  employees(code, name, salary, date)
Task: Retrieve value from managers with amount above the COUNT(value) of employees rows sharing the same status.
SQL:

SELECT value FROM managers AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM employees AS txn
    WHERE txn.status = mgr.status
);


Prompt:
Schema:
  regions (alias: rgn)(type, level, status, code)
  staff(type, amount, level, status)
Task: Retrieve name from regions with salary above the AVG(amount) of staff rows sharing the same code.
SQL:

SELECT name FROM regions AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM staff AS sale
    WHERE sale.code = rgn.code
);


Prompt:
Schema:
  customers (alias: cust)(level, date, status, salary)
  invoices(type, date, code, name)
Task: Select amount from customers where status exists in invoices for the same id.
SQL:

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM invoices AS emp
    WHERE emp.id = cust.id
);


Prompt:
Schema:
  staff (alias: empl)(code, value, date, id)
  shipments(level, id, status, amount)
Task: Find name from staff where level appears in shipments entries with matching id.
SQL:

SELECT name FROM staff AS empl
WHERE level IN (
    SELECT level FROM shipments AS ord
    WHERE ord.id = empl.id
);


Prompt:
Schema:
  staff (alias: empl)(id, date, amount, status)
  orders(id, date, type, name)
Task: Find name from staff where code appears in orders entries with matching level.
SQL:

SELECT name FROM staff AS empl
WHERE code IN (
    SELECT code FROM orders AS prod
    WHERE prod.level = empl.level
);


Prompt:
Schema:
  staff (alias: empl)(date, salary, name, level)
  tasks(date, value, id, level)
Task: Find amount from staff where level appears in tasks entries with matching type.
SQL:

SELECT amount FROM staff AS empl
WHERE level IN (
    SELECT level FROM tasks AS txn
    WHERE txn.type = empl.type
);


Prompt:
Schema:
  projects (alias: prj)(level, name, code, id)
  categories(type, date, level, salary)
Task: Find value from projects where a matching record exists in categories with the same level.
SQL:

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.level = prj.level
);


Prompt:
Schema:
  projects (alias: prj)(type, status, salary, value)
  requests(name, status, value, code)
Task: Retrieve amount from projects whose code is found in requests rows where level matches the outer record.
SQL:

SELECT amount FROM projects AS prj
WHERE code IN (
    SELECT code FROM requests AS cust
    WHERE cust.level = prj.level
);


Prompt:
Schema:
  staff (alias: empl)(status, value, type, name)
  customers(type, date, value, salary)
Task: Retrieve salary from staff that have at least one corresponding entry in customers sharing the same id.
SQL:

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.id = empl.id
);


Prompt:
Schema:
  transactions (alias: txn)(value, date, type, level)
  staff(value, code, id, date)
Task: Retrieve amount from transactions with salary above the SUM(value) of staff rows sharing the same status.
SQL:

SELECT amount FROM transactions AS txn
WHERE salary > (
    SELECT SUM(value) FROM staff AS tsk
    WHERE tsk.status = txn.status
);


Prompt:
Schema:
  schedules (alias: schd)(date, id, level, status)
  employees(code, value, salary, name)
Task: Retrieve id from schedules that have at least one corresponding entry in employees sharing the same code.
SQL:

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.code = schd.code
);


Prompt:
Schema:
  projects (alias: prj)(status, level, type, salary)
  tasks(status, level, salary, type)
Task: Retrieve name from projects with value above the SUM(value) of tasks rows sharing the same id.
SQL:

SELECT name FROM projects AS prj
WHERE value > (
    SELECT SUM(value) FROM tasks AS emp
    WHERE emp.id = prj.id
);


Prompt:
Schema:
  invoices (alias: inv)(amount, status, name, value)
  shipments(id, level, code, salary)
Task: Find amount from invoices where a matching record exists in shipments with the same level.
SQL:

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.level = inv.level
);


Prompt:
Schema:
  requests (alias: ordr)(id, salary, amount, date)
  customers(id, date, name, value)
Task: Select salary from requests where code exists in customers for the same status.
SQL:

SELECT salary FROM requests AS ordr
WHERE code IN (
    SELECT code FROM customers AS schd
    WHERE schd.status = ordr.status
);


Prompt:
Schema:
  shipments (alias: shp)(type, salary, code, value)
  products(status, id, code, value)
Task: Find amount from shipments where value exceeds the minimum salary from products for the same type.
SQL:

SELECT amount FROM shipments AS shp
WHERE value > (
    SELECT MIN(salary) FROM products AS catg
    WHERE catg.type = shp.type
);


Prompt:
Schema:
  categories (alias: catg)(status, salary, type, date)
  schedules(date, status, level, value)
Task: Retrieve id from categories that have at least one corresponding entry in schedules sharing the same code.
SQL:

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.code = catg.code
);


Prompt:
Schema:
  items (alias: lne)(type, date, amount, level)
  branches(id, salary, date, type)
Task: Retrieve id from items with amount above the MAX(amount) of branches rows sharing the same level.
SQL:

SELECT id FROM items AS lne
WHERE amount > (
    SELECT MAX(amount) FROM branches AS empl
    WHERE empl.level = lne.level
);


Prompt:
Schema:
  requests (alias: ordr)(type, amount, salary, value)
  regions(status, id, level, code)
Task: Select amount from requests where id exists in regions for the same code.
SQL:

SELECT amount FROM requests AS ordr
WHERE id IN (
    SELECT id FROM regions AS cust
    WHERE cust.code = ordr.code
);


Prompt:
Schema:
  tasks (alias: tsk)(id, value, name, status)
  regions(code, date, level, amount)
Task: Select salary from tasks where status exists in regions for the same level.
SQL:

SELECT salary FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM regions AS prod
    WHERE prod.level = tsk.level
);


Prompt:
Schema:
  branches (alias: brc)(name, type, level, status)
  shipments(date, value, salary, id)
Task: Find code from branches where a matching record exists in shipments with the same id.
SQL:

SELECT code FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM shipments AS brc
    WHERE brc.id = brc.id
);


Prompt:
Schema:
  orders (alias: ord)(id, status, level, salary)
  customers(amount, id, status, level)
Task: Select code from orders where id exists in customers for the same id.
SQL:

SELECT code FROM orders AS ord
WHERE id IN (
    SELECT id FROM customers AS schd
    WHERE schd.id = ord.id
);


Prompt:
Schema:
  items (alias: lne)(code, status, date, id)
  staff(name, status, id, date)
Task: Find value from items where a matching record exists in staff with the same status.
SQL:

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.status = lne.status
);


Prompt:
Schema:
  sales (alias: sale)(amount, id, code, salary)
  managers(type, salary, name, code)
Task: Find name from sales where id appears in managers entries with matching code.
SQL:

SELECT name FROM sales AS sale
WHERE id IN (
    SELECT id FROM managers AS dept
    WHERE dept.code = sale.code
);


Prompt:
Schema:
  tasks (alias: tsk)(amount, value, status, type)
  branches(value, salary, id, level)
Task: Find id from tasks where value exceeds the average value from branches for the same level.
SQL:

SELECT id FROM tasks AS tsk
WHERE value > (
    SELECT AVG(value) FROM branches AS prj
    WHERE prj.level = tsk.level
);


Prompt:
Schema:
  regions (alias: rgn)(id, value, code, salary)
  categories(date, amount, id, salary)
Task: Select code from regions where id exists in categories for the same type.
SQL:

SELECT code FROM regions AS rgn
WHERE id IN (
    SELECT id FROM categories AS prj
    WHERE prj.type = rgn.type
);


Prompt:
Schema:
  sales (alias: sale)(name, id, amount, type)
  products(code, amount, type, level)
Task: Retrieve value from sales that have at least one corresponding entry in products sharing the same code.
SQL:

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.code = sale.code
);


Prompt:
Schema:
  regions (alias: rgn)(code, status, level, amount)
  projects(date, code, value, type)
Task: Find amount from regions where a matching record exists in projects with the same code.
SQL:

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS brc
    WHERE brc.code = rgn.code
);


Prompt:
Schema:
  categories (alias: catg)(value, type, level, date)
  orders(id, salary, type, value)
Task: Retrieve salary from categories whose type is found in orders rows where status matches the outer record.
SQL:

SELECT salary FROM categories AS catg
WHERE type IN (
    SELECT type FROM orders AS dept
    WHERE dept.status = catg.status
);


Prompt:
Schema:
  employees (alias: emp)(value, id, level, salary)
  invoices(salary, level, date, amount)
Task: Find value from employees where a matching record exists in invoices with the same code.
SQL:

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.code = emp.code
);


Prompt:
Schema:
  tasks (alias: tsk)(code, level, amount, id)
  sales(code, salary, amount, status)
Task: Retrieve id from tasks whose code is found in sales rows where id matches the outer record.
SQL:

SELECT id FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM sales AS ord
    WHERE ord.id = tsk.id
);


Prompt:
Schema:
  accounts (alias: acct)(level, date, status, value)
  managers(date, code, salary, id)
Task: Find code from accounts where a matching record exists in managers with the same level.
SQL:

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM managers AS dept
    WHERE dept.level = acct.level
);


Prompt:
Schema:
  customers (alias: cust)(salary, id, name, value)
  orders(amount, date, salary, name)
Task: Retrieve name from customers that have at least one corresponding entry in orders sharing the same id.
SQL:

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS brc
    WHERE brc.id = cust.id
);


Prompt:
Schema:
  shipments (alias: shp)(name, id, value, code)
  products(date, amount, code, id)
Task: Retrieve code from shipments whose code is found in products rows where type matches the outer record.
SQL:

SELECT code FROM shipments AS shp
WHERE code IN (
    SELECT code FROM products AS ord
    WHERE ord.type = shp.type
);


Prompt:
Schema:
  categories (alias: catg)(code, amount, name, id)
  schedules(id, level, amount, type)
Task: Find name from categories where a matching record exists in schedules with the same id.
SQL:

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM schedules AS dept
    WHERE dept.id = catg.id
);


Prompt:
Schema:
  branches (alias: brc)(status, code, id, level)
  customers(salary, level, name, status)
Task: Select value from branches where status exists in customers for the same level.
SQL:

SELECT value FROM branches AS brc
WHERE status IN (
    SELECT status FROM customers AS shp
    WHERE shp.level = brc.level
);


Prompt:
Schema:
  items (alias: lne)(type, amount, status, date)
  branches(code, level, id, status)
Task: Retrieve code from items whose id is found in branches rows where status matches the outer record.
SQL:

SELECT code FROM items AS lne
WHERE id IN (
    SELECT id FROM branches AS mgr
    WHERE mgr.status = lne.status
);


Prompt:
Schema:
  customers (alias: cust)(type, status, id, level)
  requests(level, amount, type, date)
Task: Retrieve salary from customers whose status is found in requests rows where id matches the outer record.
SQL:

SELECT salary FROM customers AS cust
WHERE status IN (
    SELECT status FROM requests AS schd
    WHERE schd.id = cust.id
);


Prompt:
Schema:
  tasks (alias: tsk)(value, date, amount, type)
  products(id, salary, status, code)
Task: Find name from tasks where salary exceeds the minimum salary from products for the same level.
SQL:

SELECT name FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(salary) FROM products AS rgn
    WHERE rgn.level = tsk.level
);


Prompt:
Schema:
  managers (alias: mgr)(type, date, value, salary)
  branches(name, salary, level, value)
Task: Find amount from managers where a matching record exists in branches with the same type.
SQL:

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.type = mgr.type
);


Prompt:
Schema:
  sales (alias: sale)(salary, name, type, code)
  employees(value, name, amount, code)
Task: Find code from sales where a matching record exists in employees with the same level.
SQL:

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.level = sale.level
);


Prompt:
Schema:
  tasks (alias: tsk)(type, code, salary, value)
  orders(name, id, value, code)
Task: Find salary from tasks where a matching record exists in orders with the same code.
SQL:

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM orders AS brc
    WHERE brc.code = tsk.code
);


Prompt:
Schema:
  employees (alias: emp)(type, salary, value, amount)
  customers(value, type, date, name)
Task: Find code from employees where salary exceeds the maximum amount from customers for the same status.
SQL:

SELECT code FROM employees AS emp
WHERE salary > (
    SELECT MAX(amount) FROM customers AS empl
    WHERE empl.status = emp.status
);


Prompt:
Schema:
  staff (alias: empl)(value, code, type, level)
  departments(status, name, id, amount)
Task: Retrieve salary from staff with salary above the MIN(amount) of departments rows sharing the same level.
SQL:

SELECT salary FROM staff AS empl
WHERE salary > (
    SELECT MIN(amount) FROM departments AS mgr
    WHERE mgr.level = empl.level
);


Prompt:
Schema:
  invoices (alias: inv)(amount, salary, code, name)
  accounts(value, code, amount, status)
Task: Find salary from invoices where salary exceeds the maximum salary from accounts for the same type.
SQL:

SELECT salary FROM invoices AS inv
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS ord
    WHERE ord.type = inv.type
);


Prompt:
Schema:
  customers (alias: cust)(status, name, value, code)
  accounts(salary, level, value, code)
Task: Retrieve amount from customers that have at least one corresponding entry in accounts sharing the same status.
SQL:

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.status = cust.status
);


Prompt:
Schema:
  departments (alias: dept)(date, type, level, value)
  managers(name, value, status, amount)
Task: Retrieve code from departments with amount above the MAX(salary) of managers rows sharing the same level.
SQL:

SELECT code FROM departments AS dept
WHERE amount > (
    SELECT MAX(salary) FROM managers AS inv
    WHERE inv.level = dept.level
);


Prompt:
Schema:
  regions (alias: rgn)(code, salary, status, id)
  projects(type, name, value, date)
Task: Find id from regions where a matching record exists in projects with the same level.
SQL:

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = rgn.level
);


Prompt:
Schema:
  branches (alias: brc)(status, name, type, salary)
  employees(code, name, id, type)
Task: Retrieve value from branches that have at least one corresponding entry in employees sharing the same type.
SQL:

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.type = brc.type
);


Prompt:
Schema:
  transactions (alias: txn)(value, level, type, status)
  orders(type, date, id, amount)
Task: Retrieve id from transactions that have at least one corresponding entry in orders sharing the same status.
SQL:

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.status = txn.status
);


Prompt:
Schema:
  employees (alias: emp)(code, amount, type, id)
  items(name, date, status, type)
Task: Retrieve amount from employees whose status is found in items rows where type matches the outer record.
SQL:

SELECT amount FROM employees AS emp
WHERE status IN (
    SELECT status FROM items AS tsk
    WHERE tsk.type = emp.type
);


Prompt:
Schema:
  requests (alias: ordr)(code, id, status, salary)
  schedules(level, value, date, code)
Task: Retrieve id from requests with salary above the SUM(salary) of schedules rows sharing the same level.
SQL:

SELECT id FROM requests AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM schedules AS shp
    WHERE shp.level = ordr.level
);


Prompt:
Schema:
  tasks (alias: tsk)(id, type, value, salary)
  managers(status, date, level, value)
Task: Find amount from tasks where salary exceeds the average value from managers for the same id.
SQL:

SELECT amount FROM tasks AS tsk
WHERE salary > (
    SELECT AVG(value) FROM managers AS rgn
    WHERE rgn.id = tsk.id
);


Prompt:
Schema:
  departments (alias: dept)(salary, amount, code, id)
  orders(amount, salary, value, id)
Task: Find id from departments where value exceeds the total value from orders for the same code.
SQL:

SELECT id FROM departments AS dept
WHERE value > (
    SELECT SUM(value) FROM orders AS prod
    WHERE prod.code = dept.code
);


Prompt:
Schema:
  projects (alias: prj)(date, salary, status, value)
  categories(amount, value, level, id)
Task: Find value from projects where salary exceeds the total amount from categories for the same code.
SQL:

SELECT value FROM projects AS prj
WHERE salary > (
    SELECT SUM(amount) FROM categories AS brc
    WHERE brc.code = prj.code
);


Prompt:
Schema:
  schedules (alias: schd)(salary, status, name, level)
  accounts(name, amount, level, id)
Task: Retrieve salary from schedules whose id is found in accounts rows where status matches the outer record.
SQL:

SELECT salary FROM schedules AS schd
WHERE id IN (
    SELECT id FROM accounts AS tsk
    WHERE tsk.status = schd.status
);


Prompt:
Schema:
  orders (alias: ord)(level, date, code, type)
  projects(type, amount, value, id)
Task: Retrieve salary from orders with amount above the MIN(salary) of projects rows sharing the same status.
SQL:

SELECT salary FROM orders AS ord
WHERE amount > (
    SELECT MIN(salary) FROM projects AS prod
    WHERE prod.status = ord.status
);


Prompt:
Schema:
  staff (alias: empl)(level, value, date, type)
  transactions(value, id, code, amount)
Task: Retrieve name from staff with value above the MIN(value) of transactions rows sharing the same code.
SQL:

SELECT name FROM staff AS empl
WHERE value > (
    SELECT MIN(value) FROM transactions AS inv
    WHERE inv.code = empl.code
);


Prompt:
Schema:
  regions (alias: rgn)(type, value, status, id)
  orders(salary, value, code, level)
Task: Retrieve id from regions whose code is found in orders rows where status matches the outer record.
SQL:

SELECT id FROM regions AS rgn
WHERE code IN (
    SELECT code FROM orders AS prj
    WHERE prj.status = rgn.status
);


Prompt:
Schema:
  branches (alias: brc)(name, date, salary, status)
  tasks(status, salary, type, level)
Task: Retrieve amount from branches whose code is found in tasks rows where type matches the outer record.
SQL:

SELECT amount FROM branches AS brc
WHERE code IN (
    SELECT code FROM tasks AS tsk
    WHERE tsk.type = brc.type
);


Prompt:
Schema:
  requests (alias: ordr)(code, type, date, value)
  departments(salary, code, date, id)
Task: Select name from requests where status exists in departments for the same code.
SQL:

SELECT name FROM requests AS ordr
WHERE status IN (
    SELECT status FROM departments AS empl
    WHERE empl.code = ordr.code
);


Prompt:
Schema:
  items (alias: lne)(status, level, value, salary)
  categories(code, type, name, date)
Task: Retrieve amount from items with amount above the AVG(value) of categories rows sharing the same status.
SQL:

SELECT amount FROM items AS lne
WHERE amount > (
    SELECT AVG(value) FROM categories AS sale
    WHERE sale.status = lne.status
);


Prompt:
Schema:
  employees (alias: emp)(amount, code, salary, type)
  categories(id, amount, level, code)
Task: Find name from employees where amount exceeds the average value from categories for the same type.
SQL:

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT AVG(value) FROM categories AS acct
    WHERE acct.type = emp.type
);


Prompt:
Schema:
  schedules (alias: schd)(date, value, level, code)
  branches(value, name, id, status)
Task: Retrieve salary from schedules that have at least one corresponding entry in branches sharing the same status.
SQL:

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.status = schd.status
);


Prompt:
Schema:
  departments (alias: dept)(value, type, status, amount)
  employees(type, date, value, salary)
Task: Retrieve id from departments with value above the SUM(amount) of employees rows sharing the same level.
SQL:

SELECT id FROM departments AS dept
WHERE value > (
    SELECT SUM(amount) FROM employees AS dept
    WHERE dept.level = dept.level
);


Prompt:
Schema:
  products (alias: prod)(code, id, amount, level)
  branches(type, status, name, code)
Task: Retrieve name from products with value above the SUM(amount) of branches rows sharing the same status.
SQL:

SELECT name FROM products AS prod
WHERE value > (
    SELECT SUM(amount) FROM branches AS mgr
    WHERE mgr.status = prod.status
);


Prompt:
Schema:
  employees (alias: emp)(id, code, salary, level)
  regions(type, value, code, status)
Task: Retrieve value from employees with amount above the MIN(salary) of regions rows sharing the same type.
SQL:

SELECT value FROM employees AS emp
WHERE amount > (
    SELECT MIN(salary) FROM regions AS sale
    WHERE sale.type = emp.type
);


Prompt:
Schema:
  projects (alias: prj)(type, amount, code, level)
  managers(value, amount, type, level)
Task: Retrieve code from projects with amount above the MIN(amount) of managers rows sharing the same level.
SQL:

SELECT code FROM projects AS prj
WHERE amount > (
    SELECT MIN(amount) FROM managers AS sale
    WHERE sale.level = prj.level
);


Prompt:
Schema:
  projects (alias: prj)(date, code, value, type)
  requests(type, date, id, name)
Task: Retrieve name from projects with salary above the COUNT(amount) of requests rows sharing the same level.
SQL:

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT COUNT(amount) FROM requests AS inv
    WHERE inv.level = prj.level
);


Prompt:
Schema:
  items (alias: lne)(value, name, id, code)
  accounts(name, value, type, id)
Task: Find amount from items where a matching record exists in accounts with the same level.
SQL:

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = lne.level
);


Prompt:
Schema:
  products (alias: prod)(level, amount, name, type)
  staff(amount, date, id, salary)
Task: Retrieve salary from products that have at least one corresponding entry in staff sharing the same status.
SQL:

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM staff AS schd
    WHERE schd.status = prod.status
);


Prompt:
Schema:
  tasks (alias: tsk)(salary, amount, code, value)
  transactions(name, amount, id, value)
Task: Find value from tasks where a matching record exists in transactions with the same level.
SQL:

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.level = tsk.level
);


Prompt:
Schema:
  invoices (alias: inv)(salary, date, type, id)
  items(date, type, status, name)
Task: Select id from invoices where code exists in items for the same level.
SQL:

SELECT id FROM invoices AS inv
WHERE code IN (
    SELECT code FROM items AS catg
    WHERE catg.level = inv.level
);


Prompt:
Schema:
  items (alias: lne)(amount, type, salary, code)
  customers(type, salary, date, amount)
Task: Select id from items where status exists in customers for the same level.
SQL:

SELECT id FROM items AS lne
WHERE status IN (
    SELECT status FROM customers AS ordr
    WHERE ordr.level = lne.level
);


Prompt:
Schema:
  products (alias: prod)(status, id, amount, type)
  sales(code, status, id, level)
Task: Select salary from products where status exists in sales for the same id.
SQL:

SELECT salary FROM products AS prod
WHERE status IN (
    SELECT status FROM sales AS ord
    WHERE ord.id = prod.id
);


Prompt:
Schema:
  schedules (alias: schd)(amount, salary, name, id)
  invoices(date, id, type, name)
Task: Find code from schedules where type appears in invoices entries with matching type.
SQL:

SELECT code FROM schedules AS schd
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.type = schd.type
);


Prompt:
Schema:
  invoices (alias: inv)(value, code, salary, type)
  projects(level, value, type, id)
Task: Retrieve id from invoices with value above the AVG(value) of projects rows sharing the same code.
SQL:

SELECT id FROM invoices AS inv
WHERE value > (
    SELECT AVG(value) FROM projects AS emp
    WHERE emp.code = inv.code
);


Prompt:
Schema:
  accounts (alias: acct)(name, id, salary, code)
  employees(status, date, value, code)
Task: Select value from accounts where status exists in employees for the same level.
SQL:

SELECT value FROM accounts AS acct
WHERE status IN (
    SELECT status FROM employees AS prj
    WHERE prj.level = acct.level
);


Prompt:
Schema:
  staff (alias: empl)(status, code, level, salary)
  requests(type, amount, id, value)
Task: Find amount from staff where id appears in requests entries with matching code.
SQL:

SELECT amount FROM staff AS empl
WHERE id IN (
    SELECT id FROM requests AS lne
    WHERE lne.code = empl.code
);


Prompt:
Schema:
  invoices (alias: inv)(value, salary, level, id)
  shipments(level, code, date, salary)
Task: Find name from invoices where a matching record exists in shipments with the same status.
SQL:

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.status = inv.status
);


Prompt:
Schema:
  schedules (alias: schd)(code, salary, date, amount)
  products(amount, salary, name, date)
Task: Retrieve name from schedules whose code is found in products rows where level matches the outer record.
SQL:

SELECT name FROM schedules AS schd
WHERE code IN (
    SELECT code FROM products AS prj
    WHERE prj.level = schd.level
);


Prompt:
Schema:
  projects (alias: prj)(type, date, level, code)
  schedules(name, date, status, value)
Task: Find code from projects where a matching record exists in schedules with the same status.
SQL:

SELECT code FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM schedules AS dept
    WHERE dept.status = prj.status
);


Prompt:
Schema:
  orders (alias: ord)(date, id, level, name)
  transactions(name, code, date, status)
Task: Find value from orders where a matching record exists in transactions with the same status.
SQL:

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.status = ord.status
);


Prompt:
Schema:
  shipments (alias: shp)(salary, status, type, level)
  orders(type, amount, date, salary)
Task: Find amount from shipments where level appears in orders entries with matching id.
SQL:

SELECT amount FROM shipments AS shp
WHERE level IN (
    SELECT level FROM orders AS txn
    WHERE txn.id = shp.id
);


Prompt:
Schema:
  projects (alias: prj)(type, value, id, amount)
  departments(value, name, level, amount)
Task: Find code from projects where a matching record exists in departments with the same type.
SQL:

SELECT code FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.type = prj.type
);


Prompt:
Schema:
  requests (alias: ordr)(value, status, level, code)
  managers(value, amount, type, salary)
Task: Retrieve code from requests whose code is found in managers rows where level matches the outer record.
SQL:

SELECT code FROM requests AS ordr
WHERE code IN (
    SELECT code FROM managers AS sale
    WHERE sale.level = ordr.level
);


Prompt:
Schema:
  employees (alias: emp)(status, date, id, salary)
  projects(amount, value, level, name)
Task: Find name from employees where amount exceeds the count of value from projects for the same status.
SQL:

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT COUNT(value) FROM projects AS brc
    WHERE brc.status = emp.status
);


Prompt:
Schema:
  customers (alias: cust)(amount, status, name, date)
  accounts(id, amount, name, status)
Task: Retrieve name from customers with value above the SUM(amount) of accounts rows sharing the same code.
SQL:

SELECT name FROM customers AS cust
WHERE value > (
    SELECT SUM(amount) FROM accounts AS inv
    WHERE inv.code = cust.code
);


Prompt:
Schema:
  transactions (alias: txn)(salary, id, status, type)
  accounts(code, name, amount, salary)
Task: Retrieve salary from transactions with value above the COUNT(value) of accounts rows sharing the same code.
SQL:

SELECT salary FROM transactions AS txn
WHERE value > (
    SELECT COUNT(value) FROM accounts AS cust
    WHERE cust.code = txn.code
);


Prompt:
Schema:
  employees (alias: emp)(type, name, code, date)
  schedules(value, level, name, type)
Task: Find code from employees where salary exceeds the maximum value from schedules for the same type.
SQL:

SELECT code FROM employees AS emp
WHERE salary > (
    SELECT MAX(value) FROM schedules AS brc
    WHERE brc.type = emp.type
);


Prompt:
Schema:
  categories (alias: catg)(salary, value, name, type)
  requests(level, status, value, name)
Task: Retrieve code from categories with value above the MAX(value) of requests rows sharing the same status.
SQL:

SELECT code FROM categories AS catg
WHERE value > (
    SELECT MAX(value) FROM requests AS lne
    WHERE lne.status = catg.status
);


Prompt:
Schema:
  items (alias: lne)(amount, date, name, value)
  categories(type, level, salary, code)
Task: Retrieve code from items with salary above the SUM(value) of categories rows sharing the same type.
SQL:

SELECT code FROM items AS lne
WHERE salary > (
    SELECT SUM(value) FROM categories AS shp
    WHERE shp.type = lne.type
);


Prompt:
Schema:
  accounts (alias: acct)(type, value, name, id)
  shipments(value, name, salary, date)
Task: Select value from accounts where status exists in shipments for the same status.
SQL:

SELECT value FROM accounts AS acct
WHERE status IN (
    SELECT status FROM shipments AS catg
    WHERE catg.status = acct.status
);


Prompt:
Schema:
  categories (alias: catg)(salary, name, date, amount)
  departments(code, id, status, date)
Task: Retrieve value from categories whose level is found in departments rows where code matches the outer record.
SQL:

SELECT value FROM categories AS catg
WHERE level IN (
    SELECT level FROM departments AS prj
    WHERE prj.code = catg.code
);


Prompt:
Schema:
  schedules (alias: schd)(value, level, status, date)
  tasks(date, amount, salary, status)
Task: Select id from schedules where id exists in tasks for the same level.
SQL:

SELECT id FROM schedules AS schd
WHERE id IN (
    SELECT id FROM tasks AS emp
    WHERE emp.level = schd.level
);


Prompt:
Schema:
  transactions (alias: txn)(level, value, amount, status)
  regions(code, name, value, level)
Task: Retrieve code from transactions that have at least one corresponding entry in regions sharing the same code.
SQL:

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS tsk
    WHERE tsk.code = txn.code
);


Prompt:
Schema:
  products (alias: prod)(salary, code, value, type)
  staff(value, status, amount, code)
Task: Find value from products where a matching record exists in staff with the same code.
SQL:

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM staff AS ord
    WHERE ord.code = prod.code
);


Prompt:
Schema:
  products (alias: prod)(date, type, salary, value)
  categories(type, salary, code, amount)
Task: Retrieve id from products with value above the MIN(amount) of categories rows sharing the same level.
SQL:

SELECT id FROM products AS prod
WHERE value > (
    SELECT MIN(amount) FROM categories AS lne
    WHERE lne.level = prod.level
);


Prompt:
Schema:
  invoices (alias: inv)(type, id, amount, level)
  orders(amount, date, name, type)
Task: Retrieve code from invoices that have at least one corresponding entry in orders sharing the same type.
SQL:

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS brc
    WHERE brc.type = inv.type
);


Prompt:
Schema:
  customers (alias: cust)(status, value, amount, code)
  shipments(level, amount, date, status)
Task: Select id from customers where status exists in shipments for the same code.
SQL:

SELECT id FROM customers AS cust
WHERE status IN (
    SELECT status FROM shipments AS catg
    WHERE catg.code = cust.code
);


Prompt:
Schema:
  branches (alias: brc)(status, id, type, level)
  products(status, level, type, code)
Task: Retrieve name from branches whose code is found in products rows where code matches the outer record.
SQL:

SELECT name FROM branches AS brc
WHERE code IN (
    SELECT code FROM products AS inv
    WHERE inv.code = brc.code
);


Prompt:
Schema:
  invoices (alias: inv)(salary, date, type, code)
  transactions(value, status, date, level)
Task: Find code from invoices where a matching record exists in transactions with the same type.
SQL:

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS tsk
    WHERE tsk.type = inv.type
);


Prompt:
Schema:
  branches (alias: brc)(type, status, value, salary)
  invoices(id, status, name, salary)
Task: Retrieve value from branches with salary above the AVG(amount) of invoices rows sharing the same id.
SQL:

SELECT value FROM branches AS brc
WHERE salary > (
    SELECT AVG(amount) FROM invoices AS acct
    WHERE acct.id = brc.id
);


Prompt:
Schema:
  departments (alias: dept)(date, id, amount, name)
  customers(type, name, id, amount)
Task: Retrieve amount from departments that have at least one corresponding entry in customers sharing the same level.
SQL:

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.level = dept.level
);


Prompt:
Schema:
  items (alias: lne)(code, name, amount, id)
  transactions(level, name, id, code)
Task: Retrieve name from items with amount above the MIN(amount) of transactions rows sharing the same level.
SQL:

SELECT name FROM items AS lne
WHERE amount > (
    SELECT MIN(amount) FROM transactions AS emp
    WHERE emp.level = lne.level
);


Prompt:
Schema:
  employees (alias: emp)(status, name, date, value)
  regions(code, amount, status, id)
Task: Retrieve name from employees that have at least one corresponding entry in regions sharing the same level.
SQL:

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.level = emp.level
);


Prompt:
Schema:
  branches (alias: brc)(date, id, salary, status)
  shipments(level, name, value, id)
Task: Find name from branches where a matching record exists in shipments with the same code.
SQL:

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.code = brc.code
);


Prompt:
Schema:
  employees (alias: emp)(code, type, status, amount)
  managers(value, salary, id, date)
Task: Select name from employees where status exists in managers for the same id.
SQL:

SELECT name FROM employees AS emp
WHERE status IN (
    SELECT status FROM managers AS mgr
    WHERE mgr.id = emp.id
);


Prompt:
Schema:
  tasks (alias: tsk)(status, type, id, amount)
  items(salary, status, level, type)
Task: Select salary from tasks where id exists in items for the same id.
SQL:

SELECT salary FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM items AS ord
    WHERE ord.id = tsk.id
);


Prompt:
Schema:
  regions (alias: rgn)(type, date, status, level)
  transactions(status, level, salary, type)
Task: Retrieve name from regions whose level is found in transactions rows where level matches the outer record.
SQL:

SELECT name FROM regions AS rgn
WHERE level IN (
    SELECT level FROM transactions AS prod
    WHERE prod.level = rgn.level
);


Prompt:
Schema:
  products (alias: prod)(value, name, level, date)
  invoices(code, name, salary, status)
Task: Find salary from products where a matching record exists in invoices with the same level.
SQL:

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.level = prod.level
);


Prompt:
Schema:
  managers (alias: mgr)(level, amount, status, name)
  orders(id, value, amount, status)
Task: Retrieve id from managers that have at least one corresponding entry in orders sharing the same code.
SQL:

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS brc
    WHERE brc.code = mgr.code
);


Prompt:
Schema:
  employees (alias: emp)(id, amount, type, level)
  categories(type, id, level, amount)
Task: Find value from employees where a matching record exists in categories with the same code.
SQL:

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.code = emp.code
);


Prompt:
Schema:
  accounts (alias: acct)(date, level, code, value)
  requests(status, date, type, salary)
Task: Retrieve id from accounts whose id is found in requests rows where code matches the outer record.
SQL:

SELECT id FROM accounts AS acct
WHERE id IN (
    SELECT id FROM requests AS txn
    WHERE txn.code = acct.code
);


Prompt:
Schema:
  sales (alias: sale)(code, name, type, salary)
  requests(salary, type, date, status)
Task: Find salary from sales where a matching record exists in requests with the same type.
SQL:

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM requests AS emp
    WHERE emp.type = sale.type
);


Prompt:
Schema:
  managers (alias: mgr)(level, date, id, code)
  products(salary, status, date, name)
Task: Find amount from managers where salary exceeds the minimum amount from products for the same level.
SQL:

SELECT amount FROM managers AS mgr
WHERE salary > (
    SELECT MIN(amount) FROM products AS ord
    WHERE ord.level = mgr.level
);


Prompt:
Schema:
  items (alias: lne)(level, value, type, date)
  invoices(amount, level, type, code)
Task: Retrieve amount from items that have at least one corresponding entry in invoices sharing the same type.
SQL:

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.type = lne.type
);


Prompt:
Schema:
  branches (alias: brc)(value, code, level, status)
  regions(status, date, id, code)
Task: Select id from branches where code exists in regions for the same level.
SQL:

SELECT id FROM branches AS brc
WHERE code IN (
    SELECT code FROM regions AS rgn
    WHERE rgn.level = brc.level
);


Prompt:
Schema:
  categories (alias: catg)(id, salary, value, date)
  shipments(status, salary, type, amount)
Task: Retrieve code from categories with amount above the COUNT(value) of shipments rows sharing the same type.
SQL:

SELECT code FROM categories AS catg
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS ord
    WHERE ord.type = catg.type
);


Prompt:
Schema:
  managers (alias: mgr)(type, amount, salary, status)
  shipments(type, id, value, salary)
Task: Find id from managers where a matching record exists in shipments with the same code.
SQL:

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.code = mgr.code
);


Prompt:
Schema:
  schedules (alias: schd)(date, name, amount, salary)
  products(type, salary, level, date)
Task: Retrieve salary from schedules that have at least one corresponding entry in products sharing the same id.
SQL:

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.id = schd.id
);


Prompt:
Schema:
  accounts (alias: acct)(code, salary, name, status)
  invoices(id, date, code, type)
Task: Find id from accounts where id appears in invoices entries with matching status.
SQL:

SELECT id FROM accounts AS acct
WHERE id IN (
    SELECT id FROM invoices AS prod
    WHERE prod.status = acct.status
);


Prompt:
Schema:
  customers (alias: cust)(date, value, type, amount)
  branches(code, salary, name, type)
Task: Find id from customers where amount exceeds the count of value from branches for the same code.
SQL:

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT COUNT(value) FROM branches AS txn
    WHERE txn.code = cust.code
);


Prompt:
Schema:
  sales (alias: sale)(id, salary, type, value)
  accounts(code, type, level, date)
Task: Find id from sales where a matching record exists in accounts with the same id.
SQL:

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.id = sale.id
);


Prompt:
Schema:
  products (alias: prod)(date, code, value, level)
  sales(code, salary, amount, id)
Task: Find amount from products where level appears in sales entries with matching level.
SQL:

SELECT amount FROM products AS prod
WHERE level IN (
    SELECT level FROM sales AS lne
    WHERE lne.level = prod.level
);


Prompt:
Schema:
  categories (alias: catg)(type, name, value, code)
  items(id, amount, code, status)
Task: Retrieve code from categories whose status is found in items rows where status matches the outer record.
SQL:

SELECT code FROM categories AS catg
WHERE status IN (
    SELECT status FROM items AS cust
    WHERE cust.status = catg.status
);


Prompt:
Schema:
  branches (alias: brc)(amount, name, type, date)
  schedules(salary, id, date, amount)
Task: Select id from branches where level exists in schedules for the same status.
SQL:

SELECT id FROM branches AS brc
WHERE level IN (
    SELECT level FROM schedules AS sale
    WHERE sale.status = brc.status
);


Prompt:
Schema:
  products (alias: prod)(value, id, amount, level)
  regions(date, type, amount, id)
Task: Find amount from products where a matching record exists in regions with the same code.
SQL:

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS brc
    WHERE brc.code = prod.code
);


Prompt:
Schema:
  transactions (alias: txn)(type, value, status, date)
  categories(level, amount, name, date)
Task: Find name from transactions where amount exceeds the count of salary from categories for the same level.
SQL:

SELECT name FROM transactions AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM categories AS catg
    WHERE catg.level = txn.level
);


Prompt:
Schema:
  branches (alias: brc)(type, amount, date, salary)
  managers(id, value, code, type)
Task: Find value from branches where a matching record exists in managers with the same id.
SQL:

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM managers AS shp
    WHERE shp.id = brc.id
);


Prompt:
Schema:
  invoices (alias: inv)(name, code, amount, status)
  tasks(amount, salary, level, name)
Task: Find code from invoices where a matching record exists in tasks with the same level.
SQL:

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS brc
    WHERE brc.level = inv.level
);


Prompt:
Schema:
  managers (alias: mgr)(name, value, type, amount)
  items(status, amount, code, level)
Task: Find id from managers where code appears in items entries with matching code.
SQL:

SELECT id FROM managers AS mgr
WHERE code IN (
    SELECT code FROM items AS tsk
    WHERE tsk.code = mgr.code
);


Prompt:
Schema:
  branches (alias: brc)(type, salary, value, code)
  employees(id, date, amount, name)
Task: Find amount from branches where a matching record exists in employees with the same status.
SQL:

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = brc.status
);


Prompt:
Schema:
  categories (alias: catg)(level, value, date, amount)
  staff(amount, value, level, salary)
Task: Select amount from categories where type exists in staff for the same code.
SQL:

SELECT amount FROM categories AS catg
WHERE type IN (
    SELECT type FROM staff AS ordr
    WHERE ordr.code = catg.code
);


Prompt:
Schema:
  items (alias: lne)(type, date, amount, level)
  categories(value, id, type, status)
Task: Retrieve id from items that have at least one corresponding entry in categories sharing the same id.
SQL:

SELECT id FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.id = lne.id
);


Prompt:
Schema:
  customers (alias: cust)(amount, id, date, salary)
  orders(level, status, code, name)
Task: Retrieve salary from customers with value above the AVG(amount) of orders rows sharing the same status.
SQL:

SELECT salary FROM customers AS cust
WHERE value > (
    SELECT AVG(amount) FROM orders AS prj
    WHERE prj.status = cust.status
);


Prompt:
Schema:
  requests (alias: ordr)(type, id, status, salary)
  invoices(type, name, status, code)
Task: Retrieve value from requests with salary above the AVG(value) of invoices rows sharing the same level.
SQL:

SELECT value FROM requests AS ordr
WHERE salary > (
    SELECT AVG(value) FROM invoices AS prj
    WHERE prj.level = ordr.level
);


Prompt:
Schema:
  categories (alias: catg)(name, status, salary, value)
  branches(level, code, amount, id)
Task: Retrieve value from categories that have at least one corresponding entry in branches sharing the same id.
SQL:

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.id = catg.id
);


Prompt:
Schema:
  transactions (alias: txn)(status, value, type, code)
  sales(amount, level, name, status)
Task: Find id from transactions where salary exceeds the average salary from sales for the same code.
SQL:

SELECT id FROM transactions AS txn
WHERE salary > (
    SELECT AVG(salary) FROM sales AS prod
    WHERE prod.code = txn.code
);


Prompt:
Schema:
  customers (alias: cust)(status, id, salary, name)
  tasks(status, name, id, salary)
Task: Retrieve amount from customers that have at least one corresponding entry in tasks sharing the same id.
SQL:

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.id = cust.id
);


Prompt:
Schema:
  regions (alias: rgn)(amount, code, name, date)
  schedules(type, code, name, id)
Task: Retrieve name from regions that have at least one corresponding entry in schedules sharing the same level.
SQL:

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM schedules AS catg
    WHERE catg.level = rgn.level
);


Prompt:
Schema:
  categories (alias: catg)(status, name, amount, type)
  items(value, date, level, type)
Task: Find id from categories where amount exceeds the minimum salary from items for the same type.
SQL:

SELECT id FROM categories AS catg
WHERE amount > (
    SELECT MIN(salary) FROM items AS ord
    WHERE ord.type = catg.type
);


Prompt:
Schema:
  schedules (alias: schd)(level, name, type, date)
  tasks(name, code, date, level)
Task: Retrieve code from schedules that have at least one corresponding entry in tasks sharing the same code.
SQL:

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.code = schd.code
);


Prompt:
Schema:
  departments (alias: dept)(status, date, salary, amount)
  projects(code, name, salary, type)
Task: Retrieve code from departments that have at least one corresponding entry in projects sharing the same status.
SQL:

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.status = dept.status
);


Prompt:
Schema:
  customers (alias: cust)(value, salary, name, id)
  tasks(value, salary, date, status)
Task: Retrieve amount from customers whose status is found in tasks rows where code matches the outer record.
SQL:

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM tasks AS cust
    WHERE cust.code = cust.code
);


Prompt:
Schema:
  staff (alias: empl)(code, name, id, level)
  items(type, code, name, level)
Task: Find name from staff where level appears in items entries with matching status.
SQL:

SELECT name FROM staff AS empl
WHERE level IN (
    SELECT level FROM items AS dept
    WHERE dept.status = empl.status
);


Prompt:
Schema:
  employees (alias: emp)(status, salary, type, code)
  schedules(salary, type, date, status)
Task: Retrieve salary from employees that have at least one corresponding entry in schedules sharing the same code.
SQL:

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM schedules AS rgn
    WHERE rgn.code = emp.code
);


Prompt:
Schema:
  transactions (alias: txn)(code, id, name, amount)
  items(value, amount, id, date)
Task: Retrieve salary from transactions that have at least one corresponding entry in items sharing the same type.
SQL:

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM items AS empl
    WHERE empl.type = txn.type
);


Prompt:
Schema:
  customers (alias: cust)(salary, level, id, type)
  accounts(code, name, salary, status)
Task: Find value from customers where a matching record exists in accounts with the same id.
SQL:

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS tsk
    WHERE tsk.id = cust.id
);


Prompt:
Schema:
  products (alias: prod)(status, value, type, level)
  customers(id, date, amount, value)
Task: Retrieve salary from products whose level is found in customers rows where code matches the outer record.
SQL:

SELECT salary FROM products AS prod
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.code = prod.code
);


Prompt:
Schema:
  departments (alias: dept)(id, salary, level, status)
  regions(id, code, amount, value)
Task: Find salary from departments where value exceeds the average value from regions for the same code.
SQL:

SELECT salary FROM departments AS dept
WHERE value > (
    SELECT AVG(value) FROM regions AS empl
    WHERE empl.code = dept.code
);


Prompt:
Schema:
  schedules (alias: schd)(name, type, status, date)
  sales(level, code, name, value)
Task: Find amount from schedules where type appears in sales entries with matching type.
SQL:

SELECT amount FROM schedules AS schd
WHERE type IN (
    SELECT type FROM sales AS ordr
    WHERE ordr.type = schd.type
);


Prompt:
Schema:
  projects (alias: prj)(code, status, salary, level)
  products(value, amount, code, name)
Task: Retrieve id from projects with amount above the COUNT(value) of products rows sharing the same type.
SQL:

SELECT id FROM projects AS prj
WHERE amount > (
    SELECT COUNT(value) FROM products AS sale
    WHERE sale.type = prj.type
);


Prompt:
Schema:
  sales (alias: sale)(date, name, code, type)
  regions(type, salary, code, value)
Task: Retrieve value from sales that have at least one corresponding entry in regions sharing the same type.
SQL:

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = sale.type
);


Prompt:
Schema:
  orders (alias: ord)(value, type, level, name)
  categories(salary, type, amount, id)
Task: Select amount from orders where status exists in categories for the same id.
SQL:

SELECT amount FROM orders AS ord
WHERE status IN (
    SELECT status FROM categories AS dept
    WHERE dept.id = ord.id
);


Prompt:
Schema:
  transactions (alias: txn)(salary, level, name, date)
  products(name, status, code, level)
Task: Retrieve name from transactions whose level is found in products rows where code matches the outer record.
SQL:

SELECT name FROM transactions AS txn
WHERE level IN (
    SELECT level FROM products AS schd
    WHERE schd.code = txn.code
);


Prompt:
Schema:
  branches (alias: brc)(type, date, salary, amount)
  tasks(status, code, value, salary)
Task: Find amount from branches where salary exceeds the maximum amount from tasks for the same id.
SQL:

SELECT amount FROM branches AS brc
WHERE salary > (
    SELECT MAX(amount) FROM tasks AS sale
    WHERE sale.id = brc.id
);


Prompt:
Schema:
  products (alias: prod)(date, salary, id, status)
  orders(date, amount, id, value)
Task: Retrieve amount from products that have at least one corresponding entry in orders sharing the same status.
SQL:

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.status = prod.status
);


Prompt:
Schema:
  customers (alias: cust)(amount, code, status, type)
  shipments(amount, id, name, status)
Task: Retrieve code from customers whose level is found in shipments rows where type matches the outer record.
SQL:

SELECT code FROM customers AS cust
WHERE level IN (
    SELECT level FROM shipments AS acct
    WHERE acct.type = cust.type
);


Prompt:
Schema:
  accounts (alias: acct)(salary, id, amount, code)
  staff(level, type, value, salary)
Task: Retrieve value from accounts with salary above the MIN(salary) of staff rows sharing the same level.
SQL:

SELECT value FROM accounts AS acct
WHERE salary > (
    SELECT MIN(salary) FROM staff AS acct
    WHERE acct.level = acct.level
);


Prompt:
Schema:
  employees (alias: emp)(status, code, value, id)
  shipments(status, level, name, value)
Task: Retrieve code from employees with value above the SUM(salary) of shipments rows sharing the same id.
SQL:

SELECT code FROM employees AS emp
WHERE value > (
    SELECT SUM(salary) FROM shipments AS sale
    WHERE sale.id = emp.id
);


Prompt:
Schema:
  departments (alias: dept)(name, value, id, code)
  schedules(salary, code, date, name)
Task: Retrieve value from departments whose level is found in schedules rows where status matches the outer record.
SQL:

SELECT value FROM departments AS dept
WHERE level IN (
    SELECT level FROM schedules AS catg
    WHERE catg.status = dept.status
);


Prompt:
Schema:
  products (alias: prod)(name, type, id, code)
  accounts(code, id, date, name)
Task: Find value from products where a matching record exists in accounts with the same id.
SQL:

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS prj
    WHERE prj.id = prod.id
);


Prompt:
Schema:
  products (alias: prod)(status, date, salary, value)
  customers(name, id, value, type)
Task: Select salary from products where id exists in customers for the same code.
SQL:

SELECT salary FROM products AS prod
WHERE id IN (
    SELECT id FROM customers AS acct
    WHERE acct.code = prod.code
);


Prompt:
Schema:
  invoices (alias: inv)(name, value, amount, id)
  tasks(id, date, code, name)
Task: Find salary from invoices where value exceeds the maximum value from tasks for the same code.
SQL:

SELECT salary FROM invoices AS inv
WHERE value > (
    SELECT MAX(value) FROM tasks AS brc
    WHERE brc.code = inv.code
);


Prompt:
Schema:
  items (alias: lne)(value, status, level, id)
  customers(type, level, salary, value)
Task: Find salary from items where type appears in customers entries with matching status.
SQL:

SELECT salary FROM items AS lne
WHERE type IN (
    SELECT type FROM customers AS prod
    WHERE prod.status = lne.status
);


Prompt:
Schema:
  schedules (alias: schd)(type, code, amount, date)
  managers(amount, salary, status, id)
Task: Find code from schedules where salary exceeds the maximum salary from managers for the same code.
SQL:

SELECT code FROM schedules AS schd
WHERE salary > (
    SELECT MAX(salary) FROM managers AS cust
    WHERE cust.code = schd.code
);


Prompt:
Schema:
  categories (alias: catg)(date, code, name, id)
  items(value, code, name, type)
Task: Select id from categories where id exists in items for the same code.
SQL:

SELECT id FROM categories AS catg
WHERE id IN (
    SELECT id FROM items AS shp
    WHERE shp.code = catg.code
);


Prompt:
Schema:
  requests (alias: ordr)(code, date, amount, id)
  tasks(name, value, amount, type)
Task: Retrieve id from requests that have at least one corresponding entry in tasks sharing the same status.
SQL:

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.status = ordr.status
);


Prompt:
Schema:
  departments (alias: dept)(status, type, amount, date)
  projects(id, salary, level, name)
Task: Retrieve value from departments whose code is found in projects rows where level matches the outer record.
SQL:

SELECT value FROM departments AS dept
WHERE code IN (
    SELECT code FROM projects AS prj
    WHERE prj.level = dept.level
);


Prompt:
Schema:
  schedules (alias: schd)(type, code, amount, level)
  managers(type, salary, value, id)
Task: Retrieve code from schedules whose code is found in managers rows where type matches the outer record.
SQL:

SELECT code FROM schedules AS schd
WHERE code IN (
    SELECT code FROM managers AS rgn
    WHERE rgn.type = schd.type
);


Prompt:
Schema:
  categories (alias: catg)(value, salary, date, amount)
  schedules(level, type, value, name)
Task: Retrieve amount from categories that have at least one corresponding entry in schedules sharing the same id.
SQL:

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM schedules AS sale
    WHERE sale.id = catg.id
);


Prompt:
Schema:
  customers (alias: cust)(name, code, date, type)
  staff(date, value, code, id)
Task: Find id from customers where value exceeds the maximum amount from staff for the same type.
SQL:

SELECT id FROM customers AS cust
WHERE value > (
    SELECT MAX(amount) FROM staff AS ordr
    WHERE ordr.type = cust.type
);


Prompt:
Schema:
  products (alias: prod)(id, amount, salary, value)
  tasks(level, name, amount, id)
Task: Find salary from products where a matching record exists in tasks with the same code.
SQL:

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = prod.code
);


Prompt:
Schema:
  departments (alias: dept)(level, id, name, code)
  tasks(date, amount, level, id)
Task: Find salary from departments where value exceeds the count of amount from tasks for the same type.
SQL:

SELECT salary FROM departments AS dept
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS inv
    WHERE inv.type = dept.type
);


Prompt:
Schema:
  schedules (alias: schd)(code, date, salary, name)
  shipments(value, id, code, name)
Task: Retrieve code from schedules with value above the SUM(amount) of shipments rows sharing the same level.
SQL:

SELECT code FROM schedules AS schd
WHERE value > (
    SELECT SUM(amount) FROM shipments AS shp
    WHERE shp.level = schd.level
);


Prompt:
Schema:
  requests (alias: ordr)(id, code, salary, level)
  products(salary, name, level, id)
Task: Find amount from requests where a matching record exists in products with the same id.
SQL:

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.id = ordr.id
);


Prompt:
Schema:
  shipments (alias: shp)(value, amount, status, code)
  departments(status, name, date, amount)
Task: Select id from shipments where level exists in departments for the same type.
SQL:

SELECT id FROM shipments AS shp
WHERE level IN (
    SELECT level FROM departments AS ord
    WHERE ord.type = shp.type
);


Prompt:
Schema:
  sales (alias: sale)(name, value, status, level)
  orders(date, amount, id, type)
Task: Retrieve code from sales whose level is found in orders rows where type matches the outer record.
SQL:

SELECT code FROM sales AS sale
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.type = sale.type
);


Prompt:
Schema:
  orders (alias: ord)(id, type, level, amount)
  accounts(date, status, code, salary)
Task: Find id from orders where amount exceeds the total amount from accounts for the same status.
SQL:

SELECT id FROM orders AS ord
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS dept
    WHERE dept.status = ord.status
);


Prompt:
Schema:
  items (alias: lne)(value, amount, salary, level)
  shipments(level, type, code, value)
Task: Select amount from items where type exists in shipments for the same code.
SQL:

SELECT amount FROM items AS lne
WHERE type IN (
    SELECT type FROM shipments AS tsk
    WHERE tsk.code = lne.code
);


Prompt:
Schema:
  accounts (alias: acct)(date, name, level, status)
  customers(status, value, amount, date)
Task: Retrieve salary from accounts that have at least one corresponding entry in customers sharing the same status.
SQL:

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.status = acct.status
);


Prompt:
Schema:
  customers (alias: cust)(type, salary, name, level)
  branches(id, date, code, amount)
Task: Find name from customers where amount exceeds the average salary from branches for the same id.
SQL:

SELECT name FROM customers AS cust
WHERE amount > (
    SELECT AVG(salary) FROM branches AS ordr
    WHERE ordr.id = cust.id
);


Prompt:
Schema:
  orders (alias: ord)(code, status, salary, name)
  branches(status, level, code, type)
Task: Retrieve code from orders that have at least one corresponding entry in branches sharing the same id.
SQL:

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.id = ord.id
);


Prompt:
Schema:
  regions (alias: rgn)(amount, status, id, salary)
  transactions(status, name, salary, date)
Task: Retrieve salary from regions with value above the COUNT(salary) of transactions rows sharing the same status.
SQL:

SELECT salary FROM regions AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS acct
    WHERE acct.status = rgn.status
);


Prompt:
Schema:
  schedules (alias: schd)(code, salary, id, amount)
  categories(amount, code, salary, value)
Task: Retrieve value from schedules whose level is found in categories rows where type matches the outer record.
SQL:

SELECT value FROM schedules AS schd
WHERE level IN (
    SELECT level FROM categories AS empl
    WHERE empl.type = schd.type
);


Prompt:
Schema:
  projects (alias: prj)(id, code, name, status)
  shipments(code, id, type, salary)
Task: Select salary from projects where id exists in shipments for the same type.
SQL:

SELECT salary FROM projects AS prj
WHERE id IN (
    SELECT id FROM shipments AS lne
    WHERE lne.type = prj.type
);


Prompt:
Schema:
  transactions (alias: txn)(date, code, amount, level)
  accounts(salary, type, date, level)
Task: Select name from transactions where type exists in accounts for the same status.
SQL:

SELECT name FROM transactions AS txn
WHERE type IN (
    SELECT type FROM accounts AS dept
    WHERE dept.status = txn.status
);


Prompt:
Schema:
  orders (alias: ord)(code, status, level, type)
  products(name, status, date, code)
Task: Find code from orders where a matching record exists in products with the same code.
SQL:

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.code = ord.code
);


Prompt:
Schema:
  employees (alias: emp)(salary, type, level, status)
  tasks(salary, code, date, id)
Task: Find name from employees where a matching record exists in tasks with the same type.
SQL:

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.type = emp.type
);


Prompt:
Schema:
  accounts (alias: acct)(amount, value, date, salary)
  tasks(level, status, value, name)
Task: Retrieve id from accounts that have at least one corresponding entry in tasks sharing the same id.
SQL:

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.id = acct.id
);


Prompt:
Schema:
  branches (alias: brc)(type, amount, salary, status)
  shipments(salary, status, level, amount)
Task: Retrieve name from branches whose code is found in shipments rows where type matches the outer record.
SQL:

SELECT name FROM branches AS brc
WHERE code IN (
    SELECT code FROM shipments AS cust
    WHERE cust.type = brc.type
);


Prompt:
Schema:
  accounts (alias: acct)(amount, name, salary, level)
  invoices(amount, level, value, id)
Task: Select name from accounts where status exists in invoices for the same id.
SQL:

SELECT name FROM accounts AS acct
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.id = acct.id
);


Prompt:
Schema:
  invoices (alias: inv)(value, level, status, date)
  categories(date, level, name, code)
Task: Retrieve salary from invoices whose code is found in categories rows where type matches the outer record.
SQL:

SELECT salary FROM invoices AS inv
WHERE code IN (
    SELECT code FROM categories AS prod
    WHERE prod.type = inv.type
);


Prompt:
Schema:
  requests (alias: ordr)(status, date, amount, type)
  accounts(id, date, level, amount)
Task: Retrieve value from requests whose level is found in accounts rows where id matches the outer record.
SQL:

SELECT value FROM requests AS ordr
WHERE level IN (
    SELECT level FROM accounts AS mgr
    WHERE mgr.id = ordr.id
);


Prompt:
Schema:
  tasks (alias: tsk)(level, name, value, type)
  managers(level, salary, amount, status)
Task: Find id from tasks where salary exceeds the minimum value from managers for the same code.
SQL:

SELECT id FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(value) FROM managers AS inv
    WHERE inv.code = tsk.code
);


Prompt:
Schema:
  employees (alias: emp)(level, salary, status, code)
  orders(amount, salary, type, value)
Task: Find id from employees where value exceeds the count of amount from orders for the same id.
SQL:

SELECT id FROM employees AS emp
WHERE value > (
    SELECT COUNT(amount) FROM orders AS brc
    WHERE brc.id = emp.id
);


Prompt:
Schema:
  transactions (alias: txn)(amount, type, level, date)
  shipments(status, type, code, amount)
Task: Find code from transactions where a matching record exists in shipments with the same code.
SQL:

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS brc
    WHERE brc.code = txn.code
);


Prompt:
Schema:
  products (alias: prod)(code, level, amount, status)
  requests(type, id, name, code)
Task: Find name from products where type appears in requests entries with matching status.
SQL:

SELECT name FROM products AS prod
WHERE type IN (
    SELECT type FROM requests AS shp
    WHERE shp.status = prod.status
);


Prompt:
Schema:
  schedules (alias: schd)(level, name, amount, type)
  shipments(type, level, amount, status)
Task: Retrieve name from schedules whose code is found in shipments rows where id matches the outer record.
SQL:

SELECT name FROM schedules AS schd
WHERE code IN (
    SELECT code FROM shipments AS txn
    WHERE txn.id = schd.id
);


Prompt:
Schema:
  transactions (alias: txn)(status, id, amount, level)
  sales(salary, level, name, status)
Task: Retrieve name from transactions that have at least one corresponding entry in sales sharing the same level.
SQL:

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.level = txn.level
);


Prompt:
Schema:
  staff (alias: empl)(type, salary, id, amount)
  orders(status, code, type, value)
Task: Find amount from staff where a matching record exists in orders with the same status.
SQL:

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.status = empl.status
);


Prompt:
Schema:
  departments (alias: dept)(status, level, date, name)
  invoices(code, salary, name, date)
Task: Retrieve amount from departments with salary above the COUNT(value) of invoices rows sharing the same status.
SQL:

SELECT amount FROM departments AS dept
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS sale
    WHERE sale.status = dept.status
);


Prompt:
Schema:
  sales (alias: sale)(salary, id, level, status)
  categories(status, name, type, id)
Task: Select name from sales where level exists in categories for the same type.
SQL:

SELECT name FROM sales AS sale
WHERE level IN (
    SELECT level FROM categories AS sale
    WHERE sale.type = sale.type
);


Prompt:
Schema:
  requests (alias: ordr)(value, code, salary, name)
  shipments(status, value, date, code)
Task: Retrieve value from requests that have at least one corresponding entry in shipments sharing the same level.
SQL:

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.level = ordr.level
);


Prompt:
Schema:
  managers (alias: mgr)(salary, date, id, name)
  customers(name, status, type, code)
Task: Retrieve name from managers with value above the COUNT(value) of customers rows sharing the same code.
SQL:

SELECT name FROM managers AS mgr
WHERE value > (
    SELECT COUNT(value) FROM customers AS empl
    WHERE empl.code = mgr.code
);


Prompt:
Schema:
  shipments (alias: shp)(type, name, code, amount)
  projects(name, date, status, salary)
Task: Select id from shipments where level exists in projects for the same status.
SQL:

SELECT id FROM shipments AS shp
WHERE level IN (
    SELECT level FROM projects AS inv
    WHERE inv.status = shp.status
);


Prompt:
Schema:
  branches (alias: brc)(name, salary, date, value)
  customers(id, date, salary, amount)
Task: Select value from branches where code exists in customers for the same id.
SQL:

SELECT value FROM branches AS brc
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.id = brc.id
);


Prompt:
Schema:
  shipments (alias: shp)(salary, level, type, code)
  tasks(level, status, salary, value)
Task: Retrieve amount from shipments that have at least one corresponding entry in tasks sharing the same code.
SQL:

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS brc
    WHERE brc.code = shp.code
);


Prompt:
Schema:
  regions (alias: rgn)(code, value, type, name)
  products(value, status, name, date)
Task: Retrieve name from regions whose status is found in products rows where status matches the outer record.
SQL:

SELECT name FROM regions AS rgn
WHERE status IN (
    SELECT status FROM products AS brc
    WHERE brc.status = rgn.status
);


Prompt:
Schema:
  regions (alias: rgn)(code, id, name, salary)
  departments(salary, id, date, amount)
Task: Retrieve amount from regions that have at least one corresponding entry in departments sharing the same type.
SQL:

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.type = rgn.type
);


Prompt:
Schema:
  accounts (alias: acct)(level, type, value, status)
  products(level, value, name, amount)
Task: Retrieve name from accounts with salary above the MIN(value) of products rows sharing the same level.
SQL:

SELECT name FROM accounts AS acct
WHERE salary > (
    SELECT MIN(value) FROM products AS schd
    WHERE schd.level = acct.level
);


Prompt:
Schema:
  items (alias: lne)(value, salary, id, amount)
  regions(level, status, type, code)
Task: Find salary from items where a matching record exists in regions with the same type.
SQL:

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.type = lne.type
);


Prompt:
Schema:
  projects (alias: prj)(value, name, level, status)
  regions(code, id, status, salary)
Task: Find value from projects where a matching record exists in regions with the same type.
SQL:

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.type = prj.type
);


Prompt:
Schema:
  sales (alias: sale)(salary, status, id, type)
  invoices(salary, value, type, amount)
Task: Select id from sales where id exists in invoices for the same type.
SQL:

SELECT id FROM sales AS sale
WHERE id IN (
    SELECT id FROM invoices AS lne
    WHERE lne.type = sale.type
);


Prompt:
Schema:
  products (alias: prod)(name, code, value, level)
  branches(value, date, status, code)
Task: Find name from products where a matching record exists in branches with the same type.
SQL:

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.type = prod.type
);


Prompt:
Schema:
  customers (alias: cust)(level, status, type, id)
  categories(amount, date, type, name)
Task: Select name from customers where status exists in categories for the same code.
SQL:

SELECT name FROM customers AS cust
WHERE status IN (
    SELECT status FROM categories AS sale
    WHERE sale.code = cust.code
);


Prompt:
Schema:
  staff (alias: empl)(id, value, status, date)
  regions(type, amount, level, value)
Task: Retrieve salary from staff that have at least one corresponding entry in regions sharing the same level.
SQL:

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.level = empl.level
);


Prompt:
Schema:
  departments (alias: dept)(code, amount, name, level)
  transactions(status, id, name, code)
Task: Retrieve code from departments that have at least one corresponding entry in transactions sharing the same id.
SQL:

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = dept.id
);


Prompt:
Schema:
  shipments (alias: shp)(value, name, type, level)
  projects(code, value, name, id)
Task: Retrieve name from shipments that have at least one corresponding entry in projects sharing the same status.
SQL:

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.status = shp.status
);


Prompt:
Schema:
  sales (alias: sale)(date, id, name, value)
  transactions(status, value, type, date)
Task: Retrieve id from sales with value above the COUNT(value) of transactions rows sharing the same status.
SQL:

SELECT id FROM sales AS sale
WHERE value > (
    SELECT COUNT(value) FROM transactions AS schd
    WHERE schd.status = sale.status
);


Prompt:
Schema:
  staff (alias: empl)(code, status, date, value)
  branches(amount, name, level, date)
Task: Retrieve name from staff whose type is found in branches rows where level matches the outer record.
SQL:

SELECT name FROM staff AS empl
WHERE type IN (
    SELECT type FROM branches AS brc
    WHERE brc.level = empl.level
);


Prompt:
Schema:
  items (alias: lne)(level, value, salary, type)
  customers(id, amount, type, name)
Task: Retrieve salary from items with amount above the MIN(value) of customers rows sharing the same level.
SQL:

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT MIN(value) FROM customers AS rgn
    WHERE rgn.level = lne.level
);


Prompt:
Schema:
  accounts (alias: acct)(type, code, id, name)
  managers(value, salary, type, name)
Task: Select code from accounts where id exists in managers for the same level.
SQL:

SELECT code FROM accounts AS acct
WHERE id IN (
    SELECT id FROM managers AS ordr
    WHERE ordr.level = acct.level
);


Prompt:
Schema:
  requests (alias: ordr)(code, value, date, status)
  customers(amount, level, type, id)
Task: Select id from requests where type exists in customers for the same status.
SQL:

SELECT id FROM requests AS ordr
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.status = ordr.status
);


Prompt:
Schema:
  orders (alias: ord)(type, amount, salary, level)
  transactions(status, level, id, value)
Task: Retrieve id from orders that have at least one corresponding entry in transactions sharing the same id.
SQL:

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.id = ord.id
);


Prompt:
Schema:
  staff (alias: empl)(code, value, date, id)
  orders(id, value, type, status)
Task: Retrieve code from staff that have at least one corresponding entry in orders sharing the same status.
SQL:

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.status = empl.status
);


Prompt:
Schema:
  branches (alias: brc)(level, value, type, date)
  transactions(salary, level, id, amount)
Task: Retrieve amount from branches whose level is found in transactions rows where status matches the outer record.
SQL:

SELECT amount FROM branches AS brc
WHERE level IN (
    SELECT level FROM transactions AS prj
    WHERE prj.status = brc.status
);


Prompt:
Schema:
  regions (alias: rgn)(amount, value, name, salary)
  staff(salary, id, value, date)
Task: Retrieve id from regions that have at least one corresponding entry in staff sharing the same code.
SQL:

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM staff AS acct
    WHERE acct.code = rgn.code
);


Prompt:
Schema:
  schedules (alias: schd)(status, date, amount, salary)
  sales(level, name, type, salary)
Task: Retrieve value from schedules that have at least one corresponding entry in sales sharing the same type.
SQL:

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM sales AS inv
    WHERE inv.type = schd.type
);


Prompt:
Schema:
  shipments (alias: shp)(value, level, amount, type)
  accounts(salary, date, level, value)
Task: Find name from shipments where type appears in accounts entries with matching code.
SQL:

SELECT name FROM shipments AS shp
WHERE type IN (
    SELECT type FROM accounts AS emp
    WHERE emp.code = shp.code
);


Prompt:
Schema:
  invoices (alias: inv)(date, amount, level, salary)
  items(level, amount, value, status)
Task: Retrieve name from invoices whose status is found in items rows where id matches the outer record.
SQL:

SELECT name FROM invoices AS inv
WHERE status IN (
    SELECT status FROM items AS sale
    WHERE sale.id = inv.id
);


Prompt:
Schema:
  departments (alias: dept)(level, value, amount, date)
  products(level, value, status, salary)
Task: Select id from departments where level exists in products for the same id.
SQL:

SELECT id FROM departments AS dept
WHERE level IN (
    SELECT level FROM products AS ordr
    WHERE ordr.id = dept.id
);


Prompt:
Schema:
  items (alias: lne)(salary, date, value, amount)
  invoices(level, date, amount, value)
Task: Find amount from items where a matching record exists in invoices with the same level.
SQL:

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.level = lne.level
);


Prompt:
Schema:
  sales (alias: sale)(salary, name, amount, date)
  regions(id, date, type, level)
Task: Retrieve name from sales with salary above the SUM(salary) of regions rows sharing the same level.
SQL:

SELECT name FROM sales AS sale
WHERE salary > (
    SELECT SUM(salary) FROM regions AS sale
    WHERE sale.level = sale.level
);


Prompt:
Schema:
  items (alias: lne)(amount, salary, code, date)
  categories(salary, type, level, value)
Task: Retrieve code from items that have at least one corresponding entry in categories sharing the same level.
SQL:

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.level = lne.level
);


Prompt:
Schema:
  departments (alias: dept)(level, date, salary, amount)
  regions(status, value, name, code)
Task: Find code from departments where level appears in regions entries with matching id.
SQL:

SELECT code FROM departments AS dept
WHERE level IN (
    SELECT level FROM regions AS lne
    WHERE lne.id = dept.id
);


Prompt:
Schema:
  tasks (alias: tsk)(id, name, value, date)
  customers(level, type, date, value)
Task: Find id from tasks where level appears in customers entries with matching id.
SQL:

SELECT id FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM customers AS ordr
    WHERE ordr.id = tsk.id
);


Prompt:
Schema:
  products (alias: prod)(id, value, code, status)
  customers(level, date, salary, type)
Task: Select value from products where code exists in customers for the same code.
SQL:

SELECT value FROM products AS prod
WHERE code IN (
    SELECT code FROM customers AS mgr
    WHERE mgr.code = prod.code
);


Prompt:
Schema:
  projects (alias: prj)(value, id, code, date)
  items(amount, code, name, id)
Task: Select name from projects where level exists in items for the same type.
SQL:

SELECT name FROM projects AS prj
WHERE level IN (
    SELECT level FROM items AS schd
    WHERE schd.type = prj.type
);


Prompt:
Schema:
  regions (alias: rgn)(id, type, name, status)
  managers(name, amount, date, level)
Task: Retrieve code from regions whose type is found in managers rows where id matches the outer record.
SQL:

SELECT code FROM regions AS rgn
WHERE type IN (
    SELECT type FROM managers AS tsk
    WHERE tsk.id = rgn.id
);


Prompt:
Schema:
  departments (alias: dept)(salary, amount, id, status)
  staff(date, name, id, salary)
Task: Retrieve amount from departments that have at least one corresponding entry in staff sharing the same status.
SQL:

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM staff AS emp
    WHERE emp.status = dept.status
);


Prompt:
Schema:
  employees (alias: emp)(level, salary, value, name)
  managers(level, salary, amount, name)
Task: Find name from employees where value exceeds the count of value from managers for the same id.
SQL:

SELECT name FROM employees AS emp
WHERE value > (
    SELECT COUNT(value) FROM managers AS sale
    WHERE sale.id = emp.id
);