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

SELECT value FROM orders AS ord
WHERE id IN (
    SELECT id FROM requests AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT id FROM items AS lne
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS inv
    WHERE inv.status = lne.status
);


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

SELECT id FROM warehouses AS whs
WHERE amount > (
    SELECT COUNT(salary) FROM managers AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT salary FROM staff AS empl
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.code = empl.code
);


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

SELECT id FROM sales AS sale
WHERE id IN (
    SELECT id FROM shipments AS shp
    WHERE shp.status = sale.status
);


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = rgn.status
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT SUM(salary) FROM shipments AS shp
    WHERE shp.type = txn.type
);


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

SELECT id FROM items AS lne
WHERE type IN (
    SELECT type FROM warehouses AS whs
    WHERE whs.status = lne.status
);


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

SELECT name FROM customers AS cust
WHERE value > (
    SELECT AVG(salary) FROM requests AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT name FROM regions AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM categories AS catg
    WHERE catg.id = rgn.id
);


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

SELECT code FROM shipments AS shp
WHERE type IN (
    SELECT type FROM managers AS mgr
    WHERE mgr.status = shp.status
);


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

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


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.status = sale.status
);


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

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


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = emp.code
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.level = rgn.level
);


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

SELECT name FROM managers AS mgr
WHERE type IN (
    SELECT type FROM requests AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.id = shp.id
);


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

SELECT name FROM shipments AS shp
WHERE level IN (
    SELECT level FROM items AS lne
    WHERE lne.type = shp.type
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.status = dept.status
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = schd.code
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = inv.type
);


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

SELECT code FROM staff AS empl
WHERE salary > (
    SELECT AVG(value) FROM services AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = whs.level
);


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

SELECT amount FROM invoices AS inv
WHERE level IN (
    SELECT level FROM sales AS sale
    WHERE sale.type = inv.type
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.id = mgr.id
);


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

SELECT value FROM items AS lne
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.code = lne.code
);


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

SELECT name FROM schedules AS schd
WHERE status IN (
    SELECT status FROM sales AS sale
    WHERE sale.type = schd.type
);


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

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


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

SELECT value FROM staff AS empl
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.id = empl.id
);


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

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


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

SELECT id FROM customers AS cust
WHERE value > (
    SELECT COUNT(salary) FROM sales AS sale
    WHERE sale.type = cust.type
);


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

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


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

SELECT id FROM warehouses AS whs
WHERE salary > (
    SELECT AVG(salary) FROM managers AS mgr
    WHERE mgr.status = whs.status
);


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

SELECT name FROM requests AS ordr
WHERE amount > (
    SELECT SUM(salary) FROM categories AS catg
    WHERE catg.type = ordr.type
);


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT MAX(salary) FROM services AS srvc
    WHERE srvc.code = catg.code
);


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

SELECT id FROM employees AS emp
WHERE code IN (
    SELECT code FROM warehouses AS whs
    WHERE whs.status = emp.status
);


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

SELECT value FROM transactions AS txn
WHERE value > (
    SELECT MAX(value) FROM requests AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT id FROM invoices AS inv
WHERE value > (
    SELECT SUM(salary) FROM sales AS sale
    WHERE sale.code = inv.code
);


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

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


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

SELECT code FROM shipments AS shp
WHERE id IN (
    SELECT id FROM accounts AS acct
    WHERE acct.type = shp.type
);


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

SELECT id FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = budg.code
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = schd.type
);


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

SELECT amount FROM staff AS empl
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.level = empl.level
);


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

SELECT amount FROM invoices AS inv
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.type = inv.type
);


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

SELECT name FROM items AS lne
WHERE value > (
    SELECT MAX(amount) FROM budgets AS budg
    WHERE budg.id = lne.id
);


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

SELECT name FROM items AS lne
WHERE salary > (
    SELECT SUM(amount) FROM categories AS catg
    WHERE catg.type = lne.type
);


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

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


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.level = whs.level
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = catg.level
);


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

SELECT id FROM requests AS ordr
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.level = ordr.level
);


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

SELECT amount FROM regions AS rgn
WHERE id IN (
    SELECT id FROM budgets AS budg
    WHERE budg.type = rgn.type
);


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

SELECT name FROM staff AS empl
WHERE level IN (
    SELECT level FROM budgets AS budg
    WHERE budg.id = empl.id
);


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

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


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

SELECT code FROM budgets AS budg
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.id = budg.id
);


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.level = emp.level
);


Prompt:
Schema:
  budgets (alias: budg)(level, salary, name, date)
  customers(code, date, amount, value)
Task: Find id from budgets where level appears in customers entries with matching code.
SQL:

SELECT id FROM budgets AS budg
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.code = budg.code
);


Prompt:
Schema:
  services (alias: srvc)(type, value, date, id)
  schedules(value, type, code, amount)
Task: Find value from services where a matching record exists in schedules with the same id.
SQL:

SELECT value FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.id = srvc.id
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.id = schd.id
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = txn.type
);


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

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


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

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


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

SELECT id FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.code = srvc.code
);


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

SELECT name FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = whs.level
);


Prompt:
Schema:
  employees (alias: emp)(amount, code, level, value)
  staff(id, level, code, name)
Task: Retrieve id from employees with value above the AVG(amount) of staff rows sharing the same code.
SQL:

SELECT id FROM employees AS emp
WHERE value > (
    SELECT AVG(amount) FROM staff AS empl
    WHERE empl.code = emp.code
);


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

SELECT name FROM schedules AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS txn
    WHERE txn.code = schd.code
);


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

SELECT code FROM invoices AS inv
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.status = inv.status
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.code = cust.code
);


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

SELECT amount FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT name FROM shipments AS shp
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.type = shp.type
);


Prompt:
Schema:
  accounts (alias: acct)(name, code, salary, date)
  departments(name, code, status, value)
Task: Retrieve value from accounts with salary above the AVG(salary) of departments rows sharing the same level.
SQL:

SELECT value FROM accounts AS acct
WHERE salary > (
    SELECT AVG(salary) FROM departments AS dept
    WHERE dept.level = acct.level
);


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

SELECT name FROM schedules AS schd
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.status = schd.status
);


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

SELECT salary FROM managers AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM services AS srvc
    WHERE srvc.status = mgr.status
);


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

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


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

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


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

SELECT salary FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = srvc.status
);


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

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


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

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


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

SELECT name FROM schedules AS schd
WHERE status IN (
    SELECT status FROM categories AS catg
    WHERE catg.level = schd.level
);


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

SELECT name FROM transactions AS txn
WHERE id IN (
    SELECT id FROM budgets AS budg
    WHERE budg.id = txn.id
);


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

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


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

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


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

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


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

SELECT name FROM categories AS catg
WHERE code IN (
    SELECT code FROM services AS srvc
    WHERE srvc.code = catg.code
);


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

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


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

SELECT amount FROM services AS srvc
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.id = srvc.id
);


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

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


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

SELECT name FROM warehouses AS whs
WHERE id IN (
    SELECT id FROM categories AS catg
    WHERE catg.status = whs.status
);


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

SELECT salary FROM invoices AS inv
WHERE value > (
    SELECT SUM(salary) FROM departments AS dept
    WHERE dept.type = inv.type
);


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

SELECT value FROM transactions AS txn
WHERE amount > (
    SELECT MIN(amount) FROM categories AS catg
    WHERE catg.level = txn.level
);


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

SELECT id FROM items AS lne
WHERE value > (
    SELECT MAX(salary) FROM orders AS ord
    WHERE ord.id = lne.id
);


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

SELECT salary FROM accounts AS acct
WHERE code IN (
    SELECT code FROM schedules AS schd
    WHERE schd.type = acct.type
);


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

SELECT code FROM regions AS rgn
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.status = rgn.status
);


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

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


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

SELECT amount FROM transactions AS txn
WHERE status IN (
    SELECT status FROM categories AS catg
    WHERE catg.code = txn.code
);


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

SELECT name FROM categories AS catg
WHERE code IN (
    SELECT code FROM employees AS emp
    WHERE emp.code = catg.code
);


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

SELECT amount FROM sales AS sale
WHERE id IN (
    SELECT id FROM categories AS catg
    WHERE catg.status = sale.status
);


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = schd.level
);


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

SELECT amount FROM items AS lne
WHERE level IN (
    SELECT level FROM regions AS rgn
    WHERE rgn.id = lne.id
);


Prompt:
Schema:
  schedules (alias: schd)(value, status, code, amount)
  warehouses(code, status, name, date)
Task: Retrieve code from schedules with salary above the MIN(value) of warehouses rows sharing the same status.
SQL:

SELECT code FROM schedules AS schd
WHERE salary > (
    SELECT MIN(value) FROM warehouses AS whs
    WHERE whs.status = schd.status
);


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

SELECT amount FROM departments AS dept
WHERE id IN (
    SELECT id FROM items AS lne
    WHERE lne.status = dept.status
);


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

SELECT value FROM regions AS rgn
WHERE code IN (
    SELECT code FROM warehouses AS whs
    WHERE whs.type = rgn.type
);


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

SELECT name FROM categories AS catg
WHERE salary > (
    SELECT SUM(amount) FROM items AS lne
    WHERE lne.id = catg.id
);


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

SELECT id FROM shipments AS shp
WHERE level IN (
    SELECT level FROM requests AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT name FROM services AS srvc
WHERE code IN (
    SELECT code FROM managers AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT code FROM items AS lne
WHERE amount > (
    SELECT AVG(salary) FROM categories AS catg
    WHERE catg.code = lne.code
);


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

SELECT salary FROM items AS lne
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.level = lne.level
);


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

SELECT name FROM invoices AS inv
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.id = inv.id
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.id = catg.id
);


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.type = ordr.type
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE salary > (
    SELECT SUM(value) FROM categories AS catg
    WHERE catg.type = ordr.type
);


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

SELECT name FROM items AS lne
WHERE id IN (
    SELECT id FROM managers AS mgr
    WHERE mgr.id = lne.id
);


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

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


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

SELECT salary FROM invoices AS inv
WHERE value > (
    SELECT MAX(value) FROM staff AS empl
    WHERE empl.level = inv.level
);


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT SUM(salary) FROM items AS lne
    WHERE lne.status = catg.status
);


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

SELECT salary FROM customers AS cust
WHERE salary > (
    SELECT MAX(salary) FROM managers AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.type = txn.type
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.status = catg.status
);


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

SELECT code FROM sales AS sale
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.type = sale.type
);


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

SELECT id FROM employees AS emp
WHERE id IN (
    SELECT id FROM invoices AS inv
    WHERE inv.level = emp.level
);


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

SELECT id FROM orders AS ord
WHERE id IN (
    SELECT id FROM accounts AS acct
    WHERE acct.status = ord.status
);


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

SELECT value FROM managers AS mgr
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.id = mgr.id
);


Prompt:
Schema:
  schedules (alias: schd)(status, type, code, value)
  budgets(amount, value, code, status)
Task: Select name from schedules where level exists in budgets for the same type.
SQL:

SELECT name FROM schedules AS schd
WHERE level IN (
    SELECT level FROM budgets AS budg
    WHERE budg.type = schd.type
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.id = lne.id
);


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

SELECT name FROM products AS prod
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT salary FROM orders AS ord
WHERE code IN (
    SELECT code FROM categories AS catg
    WHERE catg.status = ord.status
);


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

SELECT code FROM transactions AS txn
WHERE salary > (
    SELECT MIN(salary) FROM categories AS catg
    WHERE catg.code = txn.code
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.type = shp.type
);


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

SELECT code FROM staff AS empl
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS inv
    WHERE inv.level = empl.level
);


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

SELECT code FROM items AS lne
WHERE status IN (
    SELECT status FROM schedules AS schd
    WHERE schd.type = lne.type
);


Prompt:
Schema:
  services (alias: srvc)(salary, value, status, level)
  budgets(name, status, id, type)
Task: Select name from services where level exists in budgets for the same level.
SQL:

SELECT name FROM services AS srvc
WHERE level IN (
    SELECT level FROM budgets AS budg
    WHERE budg.level = srvc.level
);


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

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


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

SELECT code FROM employees AS emp
WHERE type IN (
    SELECT type FROM budgets AS budg
    WHERE budg.code = emp.code
);


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

SELECT salary FROM regions AS rgn
WHERE id IN (
    SELECT id FROM schedules AS schd
    WHERE schd.status = rgn.status
);


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

SELECT amount FROM orders AS ord
WHERE value > (
    SELECT AVG(value) FROM invoices AS inv
    WHERE inv.status = ord.status
);


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

SELECT id FROM budgets AS budg
WHERE id IN (
    SELECT id FROM requests AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT id FROM products AS prod
WHERE value > (
    SELECT MAX(salary) FROM sales AS sale
    WHERE sale.type = prod.type
);


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

SELECT amount FROM customers AS cust
WHERE salary > (
    SELECT SUM(value) FROM requests AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT amount FROM items AS lne
WHERE salary > (
    SELECT AVG(amount) FROM services AS srvc
    WHERE srvc.code = lne.code
);


Prompt:
Schema:
  managers (alias: mgr)(code, level, salary, amount)
  requests(amount, value, id, level)
Task: Retrieve amount from managers with value above the AVG(salary) of requests rows sharing the same id.
SQL:

SELECT amount FROM managers AS mgr
WHERE value > (
    SELECT AVG(salary) FROM requests AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.status = catg.status
);


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

SELECT name FROM shipments AS shp
WHERE id IN (
    SELECT id FROM services AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT value FROM managers AS mgr
WHERE value > (
    SELECT MIN(value) FROM customers AS cust
    WHERE cust.id = mgr.id
);


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

SELECT code FROM shipments AS shp
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS txn
    WHERE txn.status = shp.status
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT value FROM categories AS catg
WHERE code IN (
    SELECT code FROM staff AS empl
    WHERE empl.type = catg.type
);


Prompt:
Schema:
  accounts (alias: acct)(amount, name, type, date)
  budgets(type, level, code, id)
Task: Find salary from accounts where salary exceeds the average amount from budgets for the same status.
SQL:

SELECT salary FROM accounts AS acct
WHERE salary > (
    SELECT COUNT(amount) FROM budgets AS budg
    WHERE budg.status = acct.status
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.id = inv.id
);


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

SELECT id FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.code = budg.code
);


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

SELECT code FROM budgets AS budg
WHERE code IN (
    SELECT code FROM items AS lne
    WHERE lne.id = budg.id
);


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

SELECT amount FROM requests AS ordr
WHERE amount > (
    SELECT SUM(value) FROM invoices AS inv
    WHERE inv.type = ordr.type
);


Prompt:
Schema:
  sales (alias: sale)(id, amount, date, level)
  managers(id, salary, code, level)
Task: Select code from sales where id exists in managers for the same code.
SQL:

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


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

SELECT amount FROM orders AS ord
WHERE level IN (
    SELECT level FROM transactions AS txn
    WHERE txn.type = ord.type
);


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

SELECT value FROM shipments AS shp
WHERE level IN (
    SELECT level FROM categories AS catg
    WHERE catg.status = shp.status
);


Prompt:
Schema:
  requests (alias: ordr)(status, date, type, code)
  staff(code, type, status, amount)
Task: Find salary from requests where salary exceeds the average salary from staff for the same code.
SQL:

SELECT salary FROM requests AS ordr
WHERE salary > (
    SELECT MIN(salary) FROM staff AS empl
    WHERE empl.code = ordr.code
);


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.status = ordr.status
);