Prompt:
Schema:
  invoices (alias: inv)(id, level, date, value)
  staff(status, date, salary, code)
Task: Find code from invoices where level appears in staff entries with matching level.
SQL:

SELECT code FROM invoices AS inv
WHERE level IN (
    SELECT level FROM staff AS tsk
    WHERE tsk.level = inv.level
);


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

SELECT amount FROM projects AS prj
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS shp
    WHERE shp.status = prj.status
);


Prompt:
Schema:
  orders (alias: ord)(type, amount, value, date)
  staff(name, date, type, salary)
Task: Retrieve salary from orders with salary above the COUNT(value) of staff rows sharing the same id.
SQL:

SELECT salary FROM orders AS ord
WHERE salary > (
    SELECT COUNT(value) FROM staff AS empl
    WHERE empl.id = ord.id
);


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM transactions AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = acct.id
);


Prompt:
Schema:
  invoices (alias: inv)(value, level, amount, id)
  employees(salary, value, name, level)
Task: Find id from invoices where type appears in employees entries with matching status.
SQL:

SELECT id FROM invoices AS inv
WHERE type IN (
    SELECT type FROM employees AS prod
    WHERE prod.status = inv.status
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM staff AS emp
    WHERE emp.code = ord.code
);


Prompt:
Schema:
  orders (alias: ord)(salary, type, level, name)
  staff(id, name, code, date)
Task: Retrieve id from orders whose code is found in staff rows where id matches the outer record.
SQL:

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


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = schd.level
);


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

SELECT name FROM customers AS cust
WHERE amount > (
    SELECT AVG(value) FROM orders AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT code FROM departments AS dept
WHERE code IN (
    SELECT code FROM invoices AS cust
    WHERE cust.type = dept.type
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.status = schd.status
);


Prompt:
Schema:
  schedules (alias: schd)(date, salary, status, name)
  products(status, date, salary, name)
Task: Find value from schedules where salary exceeds the average value from products for the same id.
SQL:

SELECT value FROM schedules AS schd
WHERE salary > (
    SELECT AVG(value) FROM products AS catg
    WHERE catg.id = schd.id
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.level = brc.level
);


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

SELECT amount FROM schedules AS schd
WHERE level IN (
    SELECT level FROM requests AS cust
    WHERE cust.level = schd.level
);


Prompt:
Schema:
  regions (alias: rgn)(name, salary, amount, value)
  shipments(status, name, type, amount)
Task: Find value from regions where status appears in shipments entries with matching code.
SQL:

SELECT value FROM regions AS rgn
WHERE status IN (
    SELECT status FROM shipments AS prod
    WHERE prod.code = rgn.code
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM sales AS empl
    WHERE empl.type = cust.type
);


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

SELECT code FROM customers AS cust
WHERE level IN (
    SELECT level FROM branches AS ord
    WHERE ord.code = cust.code
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.code = cust.code
);


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

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.type = shp.type
);


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

SELECT value FROM transactions AS txn
WHERE level IN (
    SELECT level FROM items AS shp
    WHERE shp.id = txn.id
);


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

SELECT code FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.id = tsk.id
);


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

SELECT value FROM orders AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM items AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT id FROM products AS prod
WHERE status IN (
    SELECT status FROM projects AS sale
    WHERE sale.id = prod.id
);


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.level = empl.level
);


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

SELECT name FROM shipments AS shp
WHERE type IN (
    SELECT type FROM staff AS brc
    WHERE brc.type = shp.type
);


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

SELECT id FROM tasks AS tsk
WHERE amount > (
    SELECT MAX(amount) FROM staff AS emp
    WHERE emp.type = tsk.type
);


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

SELECT salary FROM categories AS catg
WHERE amount > (
    SELECT MIN(amount) FROM transactions AS inv
    WHERE inv.type = catg.type
);


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

SELECT salary FROM invoices AS inv
WHERE value > (
    SELECT MIN(value) FROM shipments AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT value FROM invoices AS inv
WHERE code IN (
    SELECT code FROM items AS schd
    WHERE schd.id = inv.id
);


Prompt:
Schema:
  schedules (alias: schd)(amount, date, id, value)
  products(name, status, amount, value)
Task: Find code from schedules where amount exceeds the count of amount from products for the same type.
SQL:

SELECT code FROM schedules AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM products AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT id FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM schedules AS rgn
    WHERE rgn.status = tsk.status
);


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

SELECT amount FROM orders AS ord
WHERE value > (
    SELECT SUM(amount) FROM departments AS emp
    WHERE emp.code = ord.code
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.type = ord.type
);


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

SELECT id FROM schedules AS schd
WHERE value > (
    SELECT MIN(salary) FROM transactions AS dept
    WHERE dept.code = schd.code
);


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

SELECT amount FROM tasks AS tsk
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS schd
    WHERE schd.status = tsk.status
);


Prompt:
Schema:
  accounts (alias: acct)(status, name, amount, level)
  regions(status, code, name, amount)
Task: Retrieve name from accounts with amount above the SUM(amount) of regions rows sharing the same level.
SQL:

SELECT name FROM accounts AS acct
WHERE amount > (
    SELECT SUM(amount) FROM regions AS txn
    WHERE txn.level = acct.level
);


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

SELECT name FROM transactions AS txn
WHERE level IN (
    SELECT level FROM requests AS inv
    WHERE inv.status = txn.status
);


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

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


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM staff AS txn
    WHERE txn.level = catg.level
);


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

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT salary FROM staff AS empl
WHERE type IN (
    SELECT type FROM employees AS inv
    WHERE inv.status = empl.status
);


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

SELECT name FROM projects AS prj
WHERE type IN (
    SELECT type FROM employees AS ordr
    WHERE ordr.code = prj.code
);


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

SELECT name FROM products AS prod
WHERE type IN (
    SELECT type FROM branches AS cust
    WHERE cust.level = prod.level
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.type = txn.type
);


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

SELECT amount FROM shipments AS shp
WHERE status IN (
    SELECT status FROM orders AS inv
    WHERE inv.id = shp.id
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS prj
    WHERE prj.type = ord.type
);


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS shp
    WHERE shp.level = emp.level
);


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

SELECT amount FROM branches AS brc
WHERE code IN (
    SELECT code FROM transactions AS acct
    WHERE acct.level = brc.level
);


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

SELECT name FROM branches AS brc
WHERE status IN (
    SELECT status FROM tasks AS prod
    WHERE prod.status = brc.status
);


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

SELECT name FROM employees AS emp
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS sale
    WHERE sale.code = emp.code
);


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

SELECT code FROM shipments AS shp
WHERE salary > (
    SELECT SUM(salary) FROM departments AS emp
    WHERE emp.level = shp.level
);


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM items AS schd
    WHERE schd.status = sale.status
);


Prompt:
Schema:
  employees (alias: emp)(status, value, name, amount)
  regions(code, type, name, value)
Task: Find name from employees where amount exceeds the total amount from regions for the same id.
SQL:

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT SUM(amount) FROM regions AS dept
    WHERE dept.id = emp.id
);


Prompt:
Schema:
  requests (alias: ordr)(status, level, value, date)
  products(id, status, type, level)
Task: Find id from requests where id appears in products entries with matching type.
SQL:

SELECT id FROM requests AS ordr
WHERE id IN (
    SELECT id FROM products AS txn
    WHERE txn.type = ordr.type
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.type = catg.type
);


Prompt:
Schema:
  branches (alias: brc)(value, level, salary, amount)
  tasks(amount, level, name, status)
Task: Find name from branches where value exceeds the minimum amount from tasks for the same level.
SQL:

SELECT name FROM branches AS brc
WHERE value > (
    SELECT MIN(amount) FROM tasks AS emp
    WHERE emp.level = brc.level
);


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

SELECT salary FROM regions AS rgn
WHERE type IN (
    SELECT type FROM sales AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT name FROM schedules AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT code FROM branches AS brc
WHERE id IN (
    SELECT id FROM items AS sale
    WHERE sale.code = brc.code
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.code = lne.code
);


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

SELECT salary FROM items AS lne
WHERE level IN (
    SELECT level FROM sales AS empl
    WHERE empl.status = lne.status
);


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

SELECT value FROM requests AS ordr
WHERE salary > (
    SELECT SUM(value) FROM staff AS prj
    WHERE prj.status = ordr.status
);


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

SELECT amount FROM transactions AS txn
WHERE level IN (
    SELECT level FROM regions AS empl
    WHERE empl.status = txn.status
);


Prompt:
Schema:
  staff (alias: empl)(level, amount, id, name)
  schedules(amount, status, level, salary)
Task: Find name from staff where value exceeds the total salary from schedules for the same type.
SQL:

SELECT name FROM staff AS empl
WHERE value > (
    SELECT SUM(salary) FROM schedules AS acct
    WHERE acct.type = empl.type
);


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

SELECT name FROM transactions AS txn
WHERE type IN (
    SELECT type FROM managers AS schd
    WHERE schd.level = txn.level
);


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

SELECT id FROM accounts AS acct
WHERE status IN (
    SELECT status FROM departments AS cust
    WHERE cust.status = acct.status
);


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

SELECT code FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(value) FROM departments AS ord
    WHERE ord.type = tsk.type
);


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

SELECT code FROM accounts AS acct
WHERE status IN (
    SELECT status FROM categories AS emp
    WHERE emp.type = acct.type
);


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

SELECT salary FROM sales AS sale
WHERE type IN (
    SELECT type FROM tasks AS acct
    WHERE acct.type = sale.type
);


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

SELECT amount FROM employees AS emp
WHERE value > (
    SELECT MAX(value) FROM branches AS sale
    WHERE sale.id = emp.id
);


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

SELECT code FROM employees AS emp
WHERE type IN (
    SELECT type FROM staff AS cust
    WHERE cust.code = emp.code
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM items AS txn
    WHERE txn.type = inv.type
);


Prompt:
Schema:
  categories (alias: catg)(level, name, code, salary)
  invoices(status, amount, id, level)
Task: Find value from categories where level appears in invoices entries with matching id.
SQL:

SELECT value FROM categories AS catg
WHERE level IN (
    SELECT level FROM invoices AS catg
    WHERE catg.id = catg.id
);


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

SELECT name FROM accounts AS acct
WHERE status IN (
    SELECT status FROM invoices AS cust
    WHERE cust.code = acct.code
);


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

SELECT name FROM managers AS mgr
WHERE salary > (
    SELECT AVG(amount) FROM departments AS prod
    WHERE prod.type = mgr.type
);


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

SELECT salary FROM items AS lne
WHERE status IN (
    SELECT status FROM staff AS txn
    WHERE txn.status = lne.status
);


Prompt:
Schema:
  sales (alias: sale)(id, value, salary, level)
  departments(id, date, status, level)
Task: Find name from sales where salary exceeds the total salary from departments for the same type.
SQL:

SELECT name FROM sales AS sale
WHERE salary > (
    SELECT SUM(salary) FROM departments AS acct
    WHERE acct.type = sale.type
);


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

SELECT value FROM tasks AS tsk
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS emp
    WHERE emp.type = tsk.type
);


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

SELECT id FROM managers AS mgr
WHERE code IN (
    SELECT code FROM employees AS schd
    WHERE schd.code = mgr.code
);


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

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


Prompt:
Schema:
  accounts (alias: acct)(name, salary, code, amount)
  items(status, name, salary, value)
Task: Find code from accounts where status appears in items entries with matching status.
SQL:

SELECT code FROM accounts AS acct
WHERE status IN (
    SELECT status FROM items AS acct
    WHERE acct.status = acct.status
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.id = txn.id
);


Prompt:
Schema:
  projects (alias: prj)(amount, value, level, name)
  invoices(type, name, status, date)
Task: Find value from projects where value exceeds the average value from invoices for the same id.
SQL:

SELECT value FROM projects AS prj
WHERE value > (
    SELECT AVG(value) FROM invoices AS dept
    WHERE dept.id = prj.id
);


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

SELECT salary FROM shipments AS shp
WHERE level IN (
    SELECT level FROM transactions AS dept
    WHERE dept.level = shp.level
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS tsk
    WHERE tsk.type = ordr.type
);


Prompt:
Schema:
  items (alias: lne)(name, id, value, date)
  managers(date, value, code, salary)
Task: Retrieve code from items with salary above the MIN(salary) of managers rows sharing the same id.
SQL:

SELECT code FROM items AS lne
WHERE salary > (
    SELECT MIN(salary) FROM managers AS schd
    WHERE schd.id = lne.id
);


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

SELECT salary FROM schedules AS schd
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT value FROM schedules AS schd
WHERE status IN (
    SELECT status FROM requests AS sale
    WHERE sale.status = schd.status
);


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

SELECT salary FROM customers AS cust
WHERE salary > (
    SELECT MAX(value) FROM orders AS acct
    WHERE acct.id = cust.id
);


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

SELECT code FROM requests AS ordr
WHERE id IN (
    SELECT id FROM transactions AS tsk
    WHERE tsk.code = ordr.code
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM schedules AS lne
    WHERE lne.type = sale.type
);


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.status = emp.status
);


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

SELECT salary FROM projects AS prj
WHERE status IN (
    SELECT status FROM managers AS prod
    WHERE prod.type = prj.type
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.id = sale.id
);


Prompt:
Schema:
  branches (alias: brc)(date, amount, code, name)
  transactions(level, id, salary, date)
Task: Find amount from branches where salary exceeds the count of amount from transactions for the same code.
SQL:

SELECT amount FROM branches AS brc
WHERE salary > (
    SELECT COUNT(amount) FROM transactions AS rgn
    WHERE rgn.code = brc.code
);


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

SELECT salary FROM orders AS ord
WHERE code IN (
    SELECT code FROM projects AS schd
    WHERE schd.type = ord.type
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.id = schd.id
);


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

SELECT id FROM accounts AS acct
WHERE type IN (
    SELECT type FROM staff AS sale
    WHERE sale.type = acct.type
);


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

SELECT name FROM transactions AS txn
WHERE salary > (
    SELECT MAX(value) FROM customers AS tsk
    WHERE tsk.id = txn.id
);


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

SELECT name FROM departments AS dept
WHERE salary > (
    SELECT MAX(value) FROM customers AS lne
    WHERE lne.status = dept.status
);


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

SELECT code FROM departments AS dept
WHERE status IN (
    SELECT status FROM products AS brc
    WHERE brc.type = dept.type
);


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

SELECT salary FROM accounts AS acct
WHERE value > (
    SELECT MAX(salary) FROM sales AS txn
    WHERE txn.type = acct.type
);


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

SELECT id FROM staff AS empl
WHERE salary > (
    SELECT SUM(salary) FROM schedules AS prj
    WHERE prj.type = empl.type
);


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

SELECT amount FROM departments AS dept
WHERE amount > (
    SELECT SUM(salary) FROM projects AS schd
    WHERE schd.type = dept.type
);


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

SELECT id FROM regions AS rgn
WHERE salary > (
    SELECT AVG(value) FROM branches AS prod
    WHERE prod.status = rgn.status
);


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

SELECT salary FROM items AS lne
WHERE value > (
    SELECT COUNT(amount) FROM staff AS prod
    WHERE prod.level = lne.level
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.code = prod.code
);


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

SELECT salary FROM sales AS sale
WHERE type IN (
    SELECT type FROM accounts AS emp
    WHERE emp.code = sale.code
);


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

SELECT value FROM invoices AS inv
WHERE status IN (
    SELECT status FROM tasks AS prod
    WHERE prod.status = inv.status
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.level = tsk.level
);


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

SELECT salary FROM products AS prod
WHERE amount > (
    SELECT SUM(salary) FROM managers AS mgr
    WHERE mgr.id = prod.id
);


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

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


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

SELECT value FROM sales AS sale
WHERE status IN (
    SELECT status FROM items AS txn
    WHERE txn.id = sale.id
);


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS brc
    WHERE brc.level = sale.level
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.code = rgn.code
);


Prompt:
Schema:
  employees (alias: emp)(code, name, date, status)
  projects(id, amount, salary, type)
Task: Find value from employees where id appears in projects entries with matching code.
SQL:

SELECT value FROM employees AS emp
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.code = emp.code
);


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

SELECT name FROM invoices AS inv
WHERE type IN (
    SELECT type FROM transactions AS tsk
    WHERE tsk.code = inv.code
);


Prompt:
Schema:
  items (alias: lne)(id, status, amount, code)
  orders(id, name, salary, type)
Task: Find name from items where amount exceeds the minimum amount from orders for the same level.
SQL:

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


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

SELECT id FROM projects AS prj
WHERE amount > (
    SELECT MIN(value) FROM staff AS rgn
    WHERE rgn.code = prj.code
);


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

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


Prompt:
Schema:
  sales (alias: sale)(type, salary, value, status)
  customers(code, value, status, type)
Task: Retrieve amount from sales with amount above the MIN(value) of customers rows sharing the same code.
SQL:

SELECT amount FROM sales AS sale
WHERE amount > (
    SELECT MIN(value) FROM customers AS sale
    WHERE sale.code = sale.code
);


Prompt:
Schema:
  employees (alias: emp)(salary, amount, date, id)
  accounts(level, status, id, amount)
Task: Find salary from employees where code appears in accounts entries with matching code.
SQL:

SELECT salary FROM employees AS emp
WHERE code IN (
    SELECT code FROM accounts AS prj
    WHERE prj.code = emp.code
);


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

SELECT amount FROM tasks AS tsk
WHERE amount > (
    SELECT AVG(salary) FROM schedules AS txn
    WHERE txn.code = tsk.code
);


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

SELECT id FROM schedules AS schd
WHERE amount > (
    SELECT SUM(value) FROM requests AS ord
    WHERE ord.id = schd.id
);


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

SELECT value FROM departments AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM managers AS prj
    WHERE prj.type = dept.type
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM requests AS acct
    WHERE acct.level = catg.level
);


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

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


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

SELECT code FROM regions AS rgn
WHERE amount > (
    SELECT COUNT(amount) FROM sales AS sale
    WHERE sale.level = rgn.level
);


Prompt:
Schema:
  items (alias: lne)(id, salary, value, date)
  tasks(date, name, id, salary)
Task: Find salary from items where salary exceeds the average amount from tasks for the same type.
SQL:

SELECT salary FROM items AS lne
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS schd
    WHERE schd.type = lne.type
);


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

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


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM items AS emp
    WHERE emp.status = acct.status
);


Prompt:
Schema:
  projects (alias: prj)(value, date, status, salary)
  shipments(salary, name, date, amount)
Task: Retrieve name from projects with value above the MAX(salary) of shipments rows sharing the same level.
SQL:

SELECT name FROM projects AS prj
WHERE value > (
    SELECT MAX(salary) FROM shipments AS cust
    WHERE cust.level = prj.level
);


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

SELECT value FROM categories AS catg
WHERE value > (
    SELECT COUNT(amount) FROM items AS tsk
    WHERE tsk.level = catg.level
);


Prompt:
Schema:
  categories (alias: catg)(id, code, status, value)
  shipments(id, salary, level, date)
Task: Find id from categories where level appears in shipments entries with matching status.
SQL:

SELECT id FROM categories AS catg
WHERE level IN (
    SELECT level FROM shipments AS rgn
    WHERE rgn.status = catg.status
);


Prompt:
Schema:
  tasks (alias: tsk)(status, name, amount, id)
  products(value, name, id, date)
Task: Find id from tasks where a matching record exists in products with the same id.
SQL:

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM products AS prj
    WHERE prj.id = tsk.id
);


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

SELECT amount FROM invoices AS inv
WHERE status IN (
    SELECT status FROM accounts AS tsk
    WHERE tsk.code = inv.code
);


Prompt:
Schema:
  customers (alias: cust)(date, type, code, id)
  regions(type, level, amount, id)
Task: Retrieve id from customers with amount above the SUM(amount) of regions rows sharing the same code.
SQL:

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT SUM(amount) FROM regions AS txn
    WHERE txn.code = cust.code
);


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

SELECT value FROM transactions AS txn
WHERE value > (
    SELECT COUNT(salary) FROM departments AS acct
    WHERE acct.type = txn.type
);


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

SELECT code FROM branches AS brc
WHERE type IN (
    SELECT type FROM customers AS prj
    WHERE prj.status = brc.status
);


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

SELECT salary FROM accounts AS acct
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT code FROM sales AS sale
WHERE amount > (
    SELECT AVG(amount) FROM products AS schd
    WHERE schd.status = sale.status
);


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

SELECT salary FROM tasks AS tsk
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS shp
    WHERE shp.id = tsk.id
);


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

SELECT value FROM accounts AS acct
WHERE value > (
    SELECT MAX(amount) FROM categories AS dept
    WHERE dept.level = acct.level
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.level = prod.level
);


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

SELECT id FROM shipments AS shp
WHERE id IN (
    SELECT id FROM employees AS dept
    WHERE dept.status = shp.status
);


Prompt:
Schema:
  products (alias: prod)(id, value, date, code)
  staff(amount, value, code, status)
Task: Find salary from products where value exceeds the count of amount from staff for the same type.
SQL:

SELECT salary FROM products AS prod
WHERE value > (
    SELECT COUNT(amount) FROM staff AS prod
    WHERE prod.type = prod.type
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.status = ordr.status
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS tsk
    WHERE tsk.id = lne.id
);


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

SELECT id FROM orders AS ord
WHERE type IN (
    SELECT type FROM schedules AS ord
    WHERE ord.status = ord.status
);


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

SELECT id FROM branches AS brc
WHERE status IN (
    SELECT status FROM items AS ordr
    WHERE ordr.level = brc.level
);


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

SELECT salary FROM transactions AS txn
WHERE level IN (
    SELECT level FROM categories AS brc
    WHERE brc.id = txn.id
);


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

SELECT amount FROM departments AS dept
WHERE amount > (
    SELECT AVG(value) FROM shipments AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM requests AS schd
    WHERE schd.type = sale.type
);


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = sale.level
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.type = catg.type
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.type = empl.type
);


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

SELECT salary FROM shipments AS shp
WHERE status IN (
    SELECT status FROM managers AS acct
    WHERE acct.level = shp.level
);


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM sales AS emp
    WHERE emp.id = prj.id
);


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

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


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

SELECT code FROM categories AS catg
WHERE salary > (
    SELECT MAX(value) FROM accounts AS prj
    WHERE prj.code = catg.code
);


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

SELECT name FROM regions AS rgn
WHERE value > (
    SELECT SUM(amount) FROM requests AS lne
    WHERE lne.code = rgn.code
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.code = lne.code
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.code = empl.code
);


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

SELECT code FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM items AS empl
    WHERE empl.id = tsk.id
);


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

SELECT amount FROM categories AS catg
WHERE type IN (
    SELECT type FROM requests AS tsk
    WHERE tsk.level = catg.level
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.code = schd.code
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.id = shp.id
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = tsk.level
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS brc
    WHERE brc.status = mgr.status
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.code = empl.code
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM staff AS inv
    WHERE inv.status = shp.status
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.type = acct.type
);


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

SELECT value FROM requests AS ordr
WHERE amount > (
    SELECT MAX(value) FROM orders AS empl
    WHERE empl.type = ordr.type
);


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

SELECT code FROM categories AS catg
WHERE id IN (
    SELECT id FROM staff AS schd
    WHERE schd.status = catg.status
);


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

SELECT amount FROM items AS lne
WHERE value > (
    SELECT AVG(value) FROM departments AS brc
    WHERE brc.level = lne.level
);


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

SELECT value FROM categories AS catg
WHERE value > (
    SELECT MIN(value) FROM managers AS inv
    WHERE inv.type = catg.type
);


Prompt:
Schema:
  orders (alias: ord)(date, value, id, salary)
  managers(salary, value, status, code)
Task: Find id from orders where value exceeds the minimum salary from managers for the same code.
SQL:

SELECT id FROM orders AS ord
WHERE value > (
    SELECT MIN(salary) FROM managers AS acct
    WHERE acct.code = ord.code
);


Prompt:
Schema:
  regions (alias: rgn)(type, level, name, date)
  branches(code, type, salary, id)
Task: Find id from regions where value exceeds the maximum value from branches for the same id.
SQL:

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT MAX(value) FROM branches AS brc
    WHERE brc.id = rgn.id
);


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

SELECT name FROM products AS prod
WHERE amount > (
    SELECT MAX(salary) FROM sales AS ord
    WHERE ord.level = prod.level
);


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

SELECT code FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM items AS txn
    WHERE txn.code = tsk.code
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM requests AS mgr
    WHERE mgr.id = tsk.id
);


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

SELECT name FROM tasks AS tsk
WHERE salary > (
    SELECT AVG(salary) FROM branches AS brc
    WHERE brc.code = tsk.code
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM requests AS sale
    WHERE sale.id = ord.id
);


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

SELECT id FROM accounts AS acct
WHERE amount > (
    SELECT COUNT(value) FROM employees AS inv
    WHERE inv.id = acct.id
);


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

SELECT salary FROM regions AS rgn
WHERE code IN (
    SELECT code FROM tasks AS emp
    WHERE emp.status = rgn.status
);


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

SELECT value FROM products AS prod
WHERE id IN (
    SELECT id FROM transactions AS inv
    WHERE inv.level = prod.level
);


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.code = mgr.code
);


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

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


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

SELECT name FROM employees AS emp
WHERE status IN (
    SELECT status FROM projects AS cust
    WHERE cust.type = emp.type
);


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.id = empl.id
);


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

SELECT salary FROM projects AS prj
WHERE amount > (
    SELECT AVG(value) FROM invoices AS schd
    WHERE schd.id = prj.id
);


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

SELECT code FROM orders AS ord
WHERE id IN (
    SELECT id FROM employees AS txn
    WHERE txn.level = ord.level
);


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

SELECT name FROM accounts AS acct
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.type = acct.type
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.code = lne.code
);


Prompt:
Schema:
  requests (alias: ordr)(amount, level, type, status)
  invoices(status, code, level, amount)
Task: Find name from requests where amount exceeds the average value from invoices for the same level.
SQL:

SELECT name FROM requests AS ordr
WHERE amount > (
    SELECT AVG(value) FROM invoices AS txn
    WHERE txn.level = ordr.level
);


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

SELECT name FROM sales AS sale
WHERE code IN (
    SELECT code FROM customers AS schd
    WHERE schd.status = sale.status
);


Prompt:
Schema:
  regions (alias: rgn)(level, type, status, amount)
  managers(date, status, level, amount)
Task: Select id from regions where type exists in managers for the same level.
SQL:

SELECT id FROM regions AS rgn
WHERE type IN (
    SELECT type FROM managers AS inv
    WHERE inv.level = rgn.level
);


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

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


Prompt:
Schema:
  branches (alias: brc)(value, code, level, amount)
  categories(date, level, type, status)
Task: Find name from branches where level appears in categories entries with matching id.
SQL:

SELECT name FROM branches AS brc
WHERE level IN (
    SELECT level FROM categories AS mgr
    WHERE mgr.id = brc.id
);


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

SELECT value FROM products AS prod
WHERE type IN (
    SELECT type FROM managers AS tsk
    WHERE tsk.level = prod.level
);


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

SELECT code FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM employees AS catg
    WHERE catg.code = tsk.code
);


Prompt:
Schema:
  invoices (alias: inv)(type, amount, status, code)
  categories(date, type, status, amount)
Task: Retrieve id from invoices with salary above the SUM(salary) of categories rows sharing the same code.
SQL:

SELECT id FROM invoices AS inv
WHERE salary > (
    SELECT SUM(salary) FROM categories AS prj
    WHERE prj.code = inv.code
);


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

SELECT name FROM schedules AS schd
WHERE type IN (
    SELECT type FROM items AS prj
    WHERE prj.id = schd.id
);


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

SELECT value FROM sales AS sale
WHERE salary > (
    SELECT SUM(amount) FROM employees AS tsk
    WHERE tsk.code = sale.code
);


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

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


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

SELECT code FROM customers AS cust
WHERE id IN (
    SELECT id FROM staff AS shp
    WHERE shp.code = cust.code
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT amount FROM managers AS mgr
WHERE value > (
    SELECT AVG(salary) FROM items AS shp
    WHERE shp.type = mgr.type
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.code = rgn.code
);


Prompt:
Schema:
  managers (alias: mgr)(name, id, level, salary)
  branches(date, id, salary, code)
Task: Find id from managers where id appears in branches entries with matching id.
SQL:

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


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

SELECT code FROM sales AS sale
WHERE salary > (
    SELECT SUM(amount) FROM employees AS catg
    WHERE catg.status = sale.status
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.level = emp.level
);


Prompt:
Schema:
  items (alias: lne)(value, name, type, salary)
  products(salary, status, date, type)
Task: Find salary from items where value exceeds the average value from products for the same type.
SQL:

SELECT salary FROM items AS lne
WHERE value > (
    SELECT AVG(value) FROM products AS acct
    WHERE acct.type = lne.type
);


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

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


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

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


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

SELECT id FROM regions AS rgn
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS inv
    WHERE inv.level = rgn.level
);


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

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


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

SELECT id FROM sales AS sale
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.id = sale.id
);


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

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


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

SELECT value FROM departments AS dept
WHERE amount > (
    SELECT AVG(salary) FROM staff AS schd
    WHERE schd.id = dept.id
);


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

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


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

SELECT id FROM departments AS dept
WHERE status IN (
    SELECT status FROM invoices AS prj
    WHERE prj.level = dept.level
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM managers AS emp
    WHERE emp.type = schd.type
);


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

SELECT id FROM items AS lne
WHERE code IN (
    SELECT code FROM shipments AS schd
    WHERE schd.level = lne.level
);


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

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS inv
    WHERE inv.level = emp.level
);


Prompt:
Schema:
  items (alias: lne)(salary, code, date, status)
  managers(date, type, status, level)
Task: Find name from items where amount exceeds the maximum value from managers for the same status.
SQL:

SELECT name FROM items AS lne
WHERE amount > (
    SELECT MAX(value) FROM managers AS emp
    WHERE emp.status = lne.status
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM requests AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM sales AS empl
    WHERE empl.id = tsk.id
);


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

SELECT code FROM products AS prod
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS shp
    WHERE shp.id = prod.id
);


Prompt:
Schema:
  invoices (alias: inv)(value, status, id, level)
  departments(amount, id, name, level)
Task: Find salary from invoices where type appears in departments entries with matching type.
SQL:

SELECT salary FROM invoices AS inv
WHERE type IN (
    SELECT type FROM departments AS empl
    WHERE empl.type = inv.type
);


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

SELECT amount FROM branches AS brc
WHERE id IN (
    SELECT id FROM regions AS dept
    WHERE dept.id = brc.id
);


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

SELECT value FROM sales AS sale
WHERE code IN (
    SELECT code FROM categories AS rgn
    WHERE rgn.type = sale.type
);


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

SELECT name FROM regions AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS sale
    WHERE sale.id = rgn.id
);


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

SELECT name FROM accounts AS acct
WHERE id IN (
    SELECT id FROM regions AS prod
    WHERE prod.id = acct.id
);


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

SELECT value FROM customers AS cust
WHERE amount > (
    SELECT COUNT(amount) FROM managers AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT salary FROM regions AS rgn
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.level = inv.level
);


Prompt:
Schema:
  branches (alias: brc)(value, level, status, code)
  accounts(value, type, level, code)
Task: Retrieve code from branches with salary above the MIN(value) of accounts rows sharing the same code.
SQL:

SELECT code FROM branches AS brc
WHERE salary > (
    SELECT MIN(value) FROM accounts AS prod
    WHERE prod.code = brc.code
);


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

SELECT code FROM sales AS sale
WHERE salary > (
    SELECT AVG(value) FROM items AS ord
    WHERE ord.type = sale.type
);


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

SELECT amount FROM categories AS catg
WHERE amount > (
    SELECT MAX(salary) FROM staff AS emp
    WHERE emp.level = catg.level
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS tsk
    WHERE tsk.level = cust.level
);


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

SELECT amount FROM staff AS empl
WHERE type IN (
    SELECT type FROM products AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.level = ord.level
);


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

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


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

SELECT value FROM departments AS dept
WHERE value > (
    SELECT COUNT(value) FROM tasks AS prod
    WHERE prod.id = dept.id
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM sales AS inv
    WHERE inv.id = empl.id
);


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

SELECT value FROM staff AS empl
WHERE code IN (
    SELECT code FROM shipments AS emp
    WHERE emp.type = empl.type
);


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

SELECT amount FROM transactions AS txn
WHERE level IN (
    SELECT level FROM schedules AS catg
    WHERE catg.type = txn.type
);


Prompt:
Schema:
  requests (alias: ordr)(id, value, level, status)
  shipments(code, date, status, name)
Task: Find code from requests where amount exceeds the maximum salary from shipments for the same level.
SQL:

SELECT code FROM requests AS ordr
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS acct
    WHERE acct.level = ordr.level
);


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

SELECT code FROM invoices AS inv
WHERE value > (
    SELECT AVG(amount) FROM accounts AS brc
    WHERE brc.type = inv.type
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.id = acct.id
);


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

SELECT code FROM managers AS mgr
WHERE amount > (
    SELECT MIN(value) FROM products AS shp
    WHERE shp.type = mgr.type
);


Prompt:
Schema:
  accounts (alias: acct)(type, amount, status, value)
  departments(code, amount, level, type)
Task: Select amount from accounts where code exists in departments for the same level.
SQL:

SELECT amount FROM accounts AS acct
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.level = acct.level
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE salary > (
    SELECT MAX(salary) FROM projects AS prod
    WHERE prod.code = tsk.code
);


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

SELECT salary FROM orders AS ord
WHERE salary > (
    SELECT MIN(value) FROM staff AS catg
    WHERE catg.level = ord.level
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT code FROM regions AS rgn
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS ord
    WHERE ord.status = rgn.status
);


Prompt:
Schema:
  staff (alias: empl)(code, id, type, value)
  shipments(level, date, type, name)
Task: Find name from staff where value exceeds the minimum salary from shipments for the same status.
SQL:

SELECT name FROM staff AS empl
WHERE value > (
    SELECT MIN(salary) FROM shipments AS empl
    WHERE empl.status = empl.status
);


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

SELECT name FROM products AS prod
WHERE code IN (
    SELECT code FROM customers AS brc
    WHERE brc.status = prod.status
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = dept.type
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM sales AS tsk
    WHERE tsk.level = mgr.level
);


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

SELECT salary FROM transactions AS txn
WHERE status IN (
    SELECT status FROM orders AS cust
    WHERE cust.level = txn.level
);


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

SELECT salary FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM sales AS empl
    WHERE empl.id = tsk.id
);


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

SELECT name FROM regions AS rgn
WHERE status IN (
    SELECT status FROM employees AS emp
    WHERE emp.type = rgn.type
);


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

SELECT id FROM tasks AS tsk
WHERE amount > (
    SELECT MAX(value) FROM regions AS inv
    WHERE inv.id = tsk.id
);


Prompt:
Schema:
  managers (alias: mgr)(name, amount, date, value)
  accounts(value, level, status, amount)
Task: Find value from managers where value exceeds the total salary from accounts for the same status.
SQL:

SELECT value FROM managers AS mgr
WHERE value > (
    SELECT SUM(salary) FROM accounts AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM managers AS rgn
    WHERE rgn.level = tsk.level
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.type = ordr.type
);


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

SELECT amount FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM projects AS ordr
    WHERE ordr.id = tsk.id
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.code = txn.code
);


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

SELECT name FROM categories AS catg
WHERE id IN (
    SELECT id FROM transactions AS schd
    WHERE schd.id = catg.id
);


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

SELECT code FROM orders AS ord
WHERE salary > (
    SELECT AVG(salary) FROM products AS empl
    WHERE empl.level = ord.level
);


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

SELECT code FROM customers AS cust
WHERE salary > (
    SELECT AVG(amount) FROM invoices AS tsk
    WHERE tsk.type = cust.type
);


Prompt:
Schema:
  sales (alias: sale)(amount, name, id, level)
  regions(status, amount, code, date)
Task: Find amount from sales where salary exceeds the count of salary from regions for the same code.
SQL:

SELECT amount FROM sales AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS inv
    WHERE inv.code = sale.code
);


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = rgn.id
);


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

SELECT name FROM categories AS catg
WHERE value > (
    SELECT AVG(amount) FROM departments AS cust
    WHERE cust.code = catg.code
);


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

SELECT name FROM customers AS cust
WHERE status IN (
    SELECT status FROM managers AS mgr
    WHERE mgr.id = cust.id
);


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

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


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.id = emp.id
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.id = schd.id
);


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

SELECT salary FROM items AS lne
WHERE type IN (
    SELECT type FROM branches AS inv
    WHERE inv.status = lne.status
);


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT MAX(salary) FROM managers AS catg
    WHERE catg.status = catg.status
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT code FROM requests AS ordr
WHERE id IN (
    SELECT id FROM transactions AS sale
    WHERE sale.id = ordr.id
);


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

SELECT salary FROM departments AS dept
WHERE amount > (
    SELECT MIN(salary) FROM categories AS shp
    WHERE shp.code = dept.code
);


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

SELECT code FROM categories AS catg
WHERE id IN (
    SELECT id FROM projects AS prod
    WHERE prod.code = catg.code
);


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM staff AS shp
    WHERE shp.id = prj.id
);


Prompt:
Schema:
  managers (alias: mgr)(type, value, id, date)
  schedules(date, name, code, type)
Task: Find salary from managers where salary exceeds the count of salary from schedules for the same level.
SQL:

SELECT salary FROM managers AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM schedules AS cust
    WHERE cust.level = mgr.level
);


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

SELECT salary FROM departments AS dept
WHERE id IN (
    SELECT id FROM accounts AS dept
    WHERE dept.level = dept.level
);


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

SELECT id FROM customers AS cust
WHERE type IN (
    SELECT type FROM accounts AS dept
    WHERE dept.id = cust.id
);


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.type = brc.type
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.code = tsk.code
);


Prompt:
Schema:
  products (alias: prod)(date, id, type, amount)
  regions(value, level, id, type)
Task: Retrieve id from products with value above the COUNT(value) of regions rows sharing the same status.
SQL:

SELECT id FROM products AS prod
WHERE value > (
    SELECT COUNT(value) FROM regions AS txn
    WHERE txn.status = prod.status
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.status = dept.status
);