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

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


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS inv
    WHERE inv.id = shp.id
);


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

SELECT amount FROM schedules AS schd
WHERE code IN (
    SELECT code FROM staff AS empl
    WHERE empl.type = schd.type
);


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

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


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.status = lne.status
);


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

SELECT id FROM warehouses AS whs
WHERE code IN (
    SELECT code FROM requests AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT code FROM sales AS sale
WHERE status IN (
    SELECT status FROM regions AS rgn
    WHERE rgn.code = sale.code
);


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

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


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

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


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

SELECT amount FROM accounts AS acct
WHERE value > (
    SELECT SUM(value) FROM products AS prod
    WHERE prod.code = acct.code
);


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

SELECT name FROM sales AS sale
WHERE id IN (
    SELECT id FROM requests AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT value FROM warehouses AS whs
WHERE code IN (
    SELECT code FROM sales AS sale
    WHERE sale.level = whs.level
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = sale.code
);


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

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT AVG(salary) FROM sales AS sale
    WHERE sale.status = rgn.status
);


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

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


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

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


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

SELECT name FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = budg.level
);


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

SELECT name FROM warehouses AS whs
WHERE salary > (
    SELECT MAX(amount) FROM sales AS sale
    WHERE sale.id = whs.id
);


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

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


Prompt:
Schema:
  orders (alias: ord)(salary, status, name, date)
  employees(name, level, amount, status)
Task: Retrieve amount from orders with amount above the SUM(amount) of employees rows sharing the same status.
SQL:

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT SUM(amount) FROM employees AS emp
    WHERE emp.status = ord.status
);


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

SELECT salary FROM services AS srvc
WHERE value > (
    SELECT SUM(value) FROM employees AS emp
    WHERE emp.code = srvc.code
);


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

SELECT amount FROM regions AS rgn
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.level = rgn.level
);


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

SELECT code FROM budgets AS budg
WHERE amount > (
    SELECT AVG(amount) FROM items AS lne
    WHERE lne.type = budg.type
);


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

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


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

SELECT id FROM regions AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM requests AS ordr
    WHERE ordr.code = rgn.code
);


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

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


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

SELECT value FROM schedules AS schd
WHERE salary > (
    SELECT MIN(salary) FROM regions AS rgn
    WHERE rgn.status = schd.status
);


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

SELECT salary FROM requests AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM schedules AS schd
    WHERE schd.id = ordr.id
);


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

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


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.type = emp.type
);


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

SELECT code FROM categories AS catg
WHERE id IN (
    SELECT id FROM requests AS ordr
    WHERE ordr.id = catg.id
);


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

SELECT salary FROM requests AS ordr
WHERE value > (
    SELECT MIN(salary) FROM warehouses AS whs
    WHERE whs.code = ordr.code
);


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

SELECT salary FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.id = srvc.id
);


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

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


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

SELECT id FROM employees AS emp
WHERE value > (
    SELECT SUM(value) FROM managers AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT salary FROM customers AS cust
WHERE value > (
    SELECT COUNT(amount) FROM accounts AS acct
    WHERE acct.level = cust.level
);


Prompt:
Schema:
  services (alias: srvc)(level, type, value, salary)
  products(id, type, level, status)
Task: Retrieve id from services with value above the COUNT(value) of products rows sharing the same status.
SQL:

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


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

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


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

SELECT id FROM warehouses AS whs
WHERE value > (
    SELECT SUM(amount) FROM requests AS ordr
    WHERE ordr.id = whs.id
);


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

SELECT salary FROM services AS srvc
WHERE status IN (
    SELECT status FROM schedules AS schd
    WHERE schd.status = srvc.status
);


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

SELECT amount FROM categories AS catg
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.level = catg.level
);


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

SELECT amount FROM transactions AS txn
WHERE code IN (
    SELECT code FROM budgets AS budg
    WHERE budg.level = txn.level
);


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

SELECT id FROM warehouses AS whs
WHERE amount > (
    SELECT SUM(amount) FROM services AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT value FROM staff AS empl
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS whs
    WHERE whs.code = empl.code
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.type = dept.type
);


Prompt:
Schema:
  shipments (alias: shp)(code, level, name, date)
  staff(amount, date, name, id)
Task: Retrieve id from shipments with amount above the MAX(amount) of staff rows sharing the same status.
SQL:

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT MAX(amount) FROM staff AS empl
    WHERE empl.status = shp.status
);


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

SELECT value FROM accounts AS acct
WHERE code IN (
    SELECT code FROM items AS lne
    WHERE lne.level = acct.level
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.level = mgr.level
);


Prompt:
Schema:
  warehouses (alias: whs)(name, value, level, amount)
  accounts(amount, value, salary, name)
Task: Find code from warehouses where value exceeds the average salary from accounts for the same status.
SQL:

SELECT code FROM warehouses AS whs
WHERE value > (
    SELECT AVG(salary) FROM accounts AS acct
    WHERE acct.status = whs.status
);


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

SELECT value FROM departments AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM requests AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.code = ordr.code
);


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

SELECT salary FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = srvc.code
);


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

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


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.status = ord.status
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = inv.code
);


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

SELECT id FROM services AS srvc
WHERE value > (
    SELECT SUM(salary) FROM budgets AS budg
    WHERE budg.level = srvc.level
);


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

SELECT code FROM managers AS mgr
WHERE value > (
    SELECT SUM(value) FROM sales AS sale
    WHERE sale.status = mgr.status
);


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

SELECT value FROM departments AS dept
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.type = dept.type
);


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

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


Prompt:
Schema:
  budgets (alias: budg)(status, id, type, name)
  schedules(salary, type, value, date)
Task: Retrieve name from budgets with value above the MAX(value) of schedules rows sharing the same level.
SQL:

SELECT name FROM budgets AS budg
WHERE value > (
    SELECT MAX(value) FROM schedules AS schd
    WHERE schd.level = budg.level
);


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

SELECT name FROM customers AS cust
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.id = cust.id
);


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

SELECT name FROM staff AS empl
WHERE amount > (
    SELECT MAX(value) FROM products AS prod
    WHERE prod.code = empl.code
);


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

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


Prompt:
Schema:
  schedules (alias: schd)(type, date, status, id)
  services(level, id, amount, value)
Task: Find amount from schedules where value exceeds the average value from services for the same id.
SQL:

SELECT amount FROM schedules AS schd
WHERE value > (
    SELECT COUNT(value) FROM services AS srvc
    WHERE srvc.id = schd.id
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = prod.level
);


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

SELECT name FROM schedules AS schd
WHERE code IN (
    SELECT code FROM sales AS sale
    WHERE sale.id = schd.id
);


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

SELECT id FROM categories AS catg
WHERE type IN (
    SELECT type FROM managers AS mgr
    WHERE mgr.id = catg.id
);


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

SELECT salary FROM budgets AS budg
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.status = budg.status
);


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

SELECT id FROM departments AS dept
WHERE status IN (
    SELECT status FROM sales AS sale
    WHERE sale.id = dept.id
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.id = cust.id
);


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

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


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = rgn.status
);


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

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


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

SELECT id FROM departments AS dept
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS whs
    WHERE whs.type = dept.type
);


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

SELECT value FROM customers AS cust
WHERE status IN (
    SELECT status FROM categories AS catg
    WHERE catg.type = cust.type
);


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT MIN(amount) FROM products AS prod
    WHERE prod.id = emp.id
);


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

SELECT value FROM departments AS dept
WHERE salary > (
    SELECT COUNT(value) FROM employees AS emp
    WHERE emp.code = dept.code
);


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

SELECT value FROM regions AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM departments AS dept
    WHERE dept.id = rgn.id
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.level = schd.level
);


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

SELECT code FROM warehouses AS whs
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.level = whs.level
);


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

SELECT value FROM employees AS emp
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.type = emp.type
);


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

SELECT salary FROM orders AS ord
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.status = ord.status
);


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

SELECT name FROM transactions AS txn
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.level = txn.level
);


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

SELECT value FROM requests AS ordr
WHERE code IN (
    SELECT code FROM schedules AS schd
    WHERE schd.type = ordr.type
);


Prompt:
Schema:
  orders (alias: ord)(value, amount, salary, name)
  products(id, code, amount, salary)
Task: Find name from orders where salary exceeds the average value from products for the same type.
SQL:

SELECT name FROM orders AS ord
WHERE salary > (
    SELECT AVG(value) FROM products AS prod
    WHERE prod.type = ord.type
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.id = cust.id
);


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

SELECT amount FROM orders AS ord
WHERE code IN (
    SELECT code FROM sales AS sale
    WHERE sale.type = ord.type
);


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

SELECT name FROM transactions AS txn
WHERE code IN (
    SELECT code FROM regions AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT value FROM schedules AS schd
WHERE level IN (
    SELECT level FROM items AS lne
    WHERE lne.level = schd.level
);


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

SELECT name FROM departments AS dept
WHERE code IN (
    SELECT code FROM orders AS ord
    WHERE ord.code = dept.code
);


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

SELECT salary FROM products AS prod
WHERE salary > (
    SELECT MAX(amount) FROM staff AS empl
    WHERE empl.id = prod.id
);


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

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


Prompt:
Schema:
  products (alias: prod)(salary, type, id, value)
  orders(status, id, code, salary)
Task: Find salary from products where salary exceeds the average value from orders for the same status.
SQL:

SELECT salary FROM products AS prod
WHERE salary > (
    SELECT MAX(value) FROM orders AS ord
    WHERE ord.status = prod.status
);


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

SELECT amount FROM transactions AS txn
WHERE salary > (
    SELECT SUM(value) FROM services AS srvc
    WHERE srvc.level = txn.level
);


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

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


Prompt:
Schema:
  invoices (alias: inv)(code, id, status, value)
  items(id, name, salary, date)
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 lne
    WHERE lne.type = inv.type
);


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

SELECT name FROM categories AS catg
WHERE value > (
    SELECT AVG(amount) FROM orders AS ord
    WHERE ord.status = catg.status
);


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

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


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.type = acct.type
);


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

SELECT value FROM warehouses AS whs
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS acct
    WHERE acct.status = whs.status
);


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

SELECT salary FROM categories AS catg
WHERE code IN (
    SELECT code FROM products AS prod
    WHERE prod.status = catg.status
);


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

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


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

SELECT name FROM regions AS rgn
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.code = rgn.code
);


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

SELECT id FROM regions AS rgn
WHERE type IN (
    SELECT type FROM orders AS ord
    WHERE ord.level = rgn.level
);


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

SELECT id FROM services AS srvc
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.status = srvc.status
);


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

SELECT salary FROM staff AS empl
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.code = empl.code
);


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

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


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

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


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

SELECT value FROM categories AS catg
WHERE code IN (
    SELECT code FROM requests AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT value FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.code = whs.code
);


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

SELECT code FROM requests AS ordr
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.status = ordr.status
);


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

SELECT value FROM managers AS mgr
WHERE code IN (
    SELECT code FROM orders AS ord
    WHERE ord.level = mgr.level
);


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

SELECT value FROM customers AS cust
WHERE value > (
    SELECT MIN(amount) FROM schedules AS schd
    WHERE schd.type = cust.type
);


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

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


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

SELECT amount FROM services AS srvc
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.level = srvc.level
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = ordr.code
);


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

SELECT code FROM orders AS ord
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.level = ord.level
);


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

SELECT amount FROM orders AS ord
WHERE type IN (
    SELECT type FROM staff AS empl
    WHERE empl.type = ord.type
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.type = inv.type
);


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

SELECT id FROM budgets AS budg
WHERE status IN (
    SELECT status FROM services AS srvc
    WHERE srvc.status = budg.status
);


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

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


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

SELECT name FROM transactions AS txn
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.code = txn.code
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT name FROM shipments AS shp
WHERE value > (
    SELECT MIN(value) FROM budgets AS budg
    WHERE budg.status = shp.status
);


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

SELECT value FROM invoices AS inv
WHERE value > (
    SELECT MAX(salary) FROM warehouses AS whs
    WHERE whs.type = inv.type
);


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

SELECT code FROM managers AS mgr
WHERE id IN (
    SELECT id FROM requests AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT amount FROM items AS lne
WHERE level IN (
    SELECT level FROM transactions AS txn
    WHERE txn.status = lne.status
);


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

SELECT salary FROM customers AS cust
WHERE amount > (
    SELECT MIN(amount) FROM items AS lne
    WHERE lne.code = cust.code
);


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

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


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

SELECT code FROM products AS prod
WHERE code IN (
    SELECT code FROM regions AS rgn
    WHERE rgn.type = prod.type
);


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

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


Prompt:
Schema:
  regions (alias: rgn)(name, date, type, level)
  orders(name, id, level, type)
Task: Find name from regions where type appears in orders entries with matching id.
SQL:

SELECT name FROM regions AS rgn
WHERE type IN (
    SELECT type FROM orders AS ord
    WHERE ord.id = rgn.id
);


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

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


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

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


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

SELECT code FROM departments AS dept
WHERE amount > (
    SELECT COUNT(value) FROM items AS lne
    WHERE lne.id = dept.id
);


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

SELECT id FROM requests AS ordr
WHERE salary > (
    SELECT MIN(value) FROM regions AS rgn
    WHERE rgn.status = ordr.status
);


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

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


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT COUNT(amount) FROM warehouses AS whs
    WHERE whs.type = txn.type
);


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

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


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

SELECT name FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT id FROM schedules AS schd
WHERE salary > (
    SELECT MAX(salary) FROM regions AS rgn
    WHERE rgn.id = schd.id
);


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

SELECT code FROM departments AS dept
WHERE value > (
    SELECT MIN(value) FROM employees AS emp
    WHERE emp.status = dept.status
);


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

SELECT code FROM requests AS ordr
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.code = ordr.code
);


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

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


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

SELECT id FROM invoices AS inv
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.code = inv.code
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = dept.status
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS whs
    WHERE whs.id = schd.id
);


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

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


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

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


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

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


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

SELECT code FROM sales AS sale
WHERE salary > (
    SELECT SUM(value) FROM services AS srvc
    WHERE srvc.code = sale.code
);


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

SELECT salary FROM customers AS cust
WHERE type IN (
    SELECT type FROM transactions AS txn
    WHERE txn.status = cust.status
);


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

SELECT name FROM accounts AS acct
WHERE id IN (
    SELECT id FROM warehouses AS whs
    WHERE whs.id = acct.id
);


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

SELECT value FROM products AS prod
WHERE level IN (
    SELECT level FROM schedules AS schd
    WHERE schd.level = prod.level
);


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

SELECT salary FROM transactions AS txn
WHERE value > (
    SELECT MIN(salary) FROM schedules AS schd
    WHERE schd.status = txn.status
);


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

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


Prompt:
Schema:
  categories (alias: catg)(type, date, salary, amount)
  sales(date, type, level, amount)
Task: Find salary from categories where code appears in sales entries with matching code.
SQL:

SELECT salary FROM categories AS catg
WHERE code IN (
    SELECT code FROM sales AS sale
    WHERE sale.code = catg.code
);


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

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


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

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


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.id = dept.id
);


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

SELECT code FROM items AS lne
WHERE level IN (
    SELECT level FROM services AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT amount FROM products AS prod
WHERE amount > (
    SELECT MAX(amount) FROM customers AS cust
    WHERE cust.type = prod.type
);


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

SELECT salary FROM products AS prod
WHERE level IN (
    SELECT level FROM warehouses AS whs
    WHERE whs.code = prod.code
);


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

SELECT name FROM products AS prod
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.id = prod.id
);


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

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


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

SELECT name FROM managers AS mgr
WHERE id IN (
    SELECT id FROM schedules AS schd
    WHERE schd.status = mgr.status
);


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

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


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

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


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

SELECT id FROM managers AS mgr
WHERE id IN (
    SELECT id FROM accounts AS acct
    WHERE acct.id = mgr.id
);


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

SELECT amount FROM customers AS cust
WHERE type IN (
    SELECT type FROM schedules AS schd
    WHERE schd.status = cust.status
);


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

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


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = acct.level
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.code = dept.code
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.code = rgn.code
);


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = sale.level
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.status = ordr.status
);


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = whs.type
);


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

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


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.code = empl.code
);


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

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


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

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


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

SELECT salary FROM shipments AS shp
WHERE level IN (
    SELECT level FROM items AS lne
    WHERE lne.code = shp.code
);


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

SELECT code FROM requests AS ordr
WHERE amount > (
    SELECT SUM(value) FROM accounts AS acct
    WHERE acct.type = ordr.type
);


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

SELECT code FROM schedules AS schd
WHERE id IN (
    SELECT id FROM staff AS empl
    WHERE empl.status = schd.status
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.id = acct.id
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = cust.id
);


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

SELECT amount FROM warehouses AS whs
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.code = whs.code
);


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

SELECT name FROM customers AS cust
WHERE status IN (
    SELECT status FROM transactions AS txn
    WHERE txn.code = cust.code
);


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

SELECT value FROM accounts AS acct
WHERE status IN (
    SELECT status FROM budgets AS budg
    WHERE budg.level = acct.level
);


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

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


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.level = emp.level
);


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

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


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.code = lne.code
);


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

SELECT name FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = budg.type
);


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

SELECT code FROM items AS lne
WHERE level IN (
    SELECT level FROM managers AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.code = cust.code
);


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

SELECT amount FROM requests AS ordr
WHERE id IN (
    SELECT id FROM shipments AS shp
    WHERE shp.type = ordr.type
);


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

SELECT value FROM services AS srvc
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.type = srvc.type
);


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

SELECT amount FROM services AS srvc
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.type = srvc.type
);


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.code = cust.code
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.type = txn.type
);


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

SELECT name FROM products AS prod
WHERE level IN (
    SELECT level FROM transactions AS txn
    WHERE txn.id = prod.id
);


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

SELECT name FROM staff AS empl
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.id = empl.id
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE code IN (
    SELECT code FROM services AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.type = dept.type
);


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

SELECT value FROM categories AS catg
WHERE type IN (
    SELECT type FROM items AS lne
    WHERE lne.code = catg.code
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.code = dept.code
);


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

SELECT value FROM sales AS sale
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.type = sale.type
);


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

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


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

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


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

SELECT name FROM products AS prod
WHERE value > (
    SELECT COUNT(value) FROM regions AS rgn
    WHERE rgn.level = prod.level
);


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

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


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

SELECT id FROM orders AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS txn
    WHERE txn.status = ord.status
);


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

SELECT name FROM accounts AS acct
WHERE amount > (
    SELECT MIN(amount) FROM schedules AS schd
    WHERE schd.level = acct.level
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = lne.type
);


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

SELECT amount FROM employees AS emp
WHERE amount > (
    SELECT MIN(amount) FROM products AS prod
    WHERE prod.status = emp.status
);


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

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


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

SELECT name FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = srvc.code
);


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

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


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

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


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.code = ordr.code
);


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

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM schedules AS schd
    WHERE schd.code = rgn.code
);


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

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


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

SELECT name FROM regions AS rgn
WHERE id IN (
    SELECT id FROM categories AS catg
    WHERE catg.id = rgn.id
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.status = dept.status
);


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

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


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

SELECT name FROM customers AS cust
WHERE value > (
    SELECT COUNT(value) FROM schedules AS schd
    WHERE schd.type = cust.type
);


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

SELECT salary FROM accounts AS acct
WHERE amount > (
    SELECT COUNT(value) FROM sales AS sale
    WHERE sale.code = acct.code
);


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

SELECT amount FROM departments AS dept
WHERE level IN (
    SELECT level FROM budgets AS budg
    WHERE budg.status = dept.status
);


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

SELECT name FROM categories AS catg
WHERE status IN (
    SELECT status FROM departments AS dept
    WHERE dept.level = catg.level
);


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

SELECT amount FROM warehouses AS whs
WHERE salary > (
    SELECT AVG(salary) FROM services AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT salary FROM regions AS rgn
WHERE amount > (
    SELECT SUM(salary) FROM managers AS mgr
    WHERE mgr.code = rgn.code
);


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

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


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

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


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

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


Prompt:
Schema:
  departments (alias: dept)(amount, date, level, status)
  employees(name, date, amount, level)
Task: Find id from departments where a matching record exists in employees with the same id.
SQL:

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


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

SELECT id FROM budgets AS budg
WHERE salary > (
    SELECT MIN(value) FROM employees AS emp
    WHERE emp.id = budg.id
);


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

SELECT code FROM staff AS empl
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.level = empl.level
);


Prompt:
Schema:
  orders (alias: ord)(id, amount, date, type)
  warehouses(type, id, level, amount)
Task: Retrieve amount from orders with amount above the SUM(value) of warehouses rows sharing the same type.
SQL:

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT SUM(value) FROM warehouses AS whs
    WHERE whs.type = ord.type
);


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

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


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

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


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

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


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

SELECT amount FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = budg.type
);


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

SELECT name FROM sales AS sale
WHERE value > (
    SELECT MAX(value) FROM managers AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT code FROM warehouses AS whs
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS txn
    WHERE txn.type = whs.type
);


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

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


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

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


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = whs.type
);


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

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


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

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


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

SELECT id FROM budgets AS budg
WHERE salary > (
    SELECT COUNT(value) FROM managers AS mgr
    WHERE mgr.status = budg.status
);


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

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


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

SELECT code FROM invoices AS inv
WHERE value > (
    SELECT SUM(value) FROM shipments AS shp
    WHERE shp.code = inv.code
);


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

SELECT salary FROM shipments AS shp
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.type = shp.type
);


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

SELECT salary FROM schedules AS schd
WHERE status IN (
    SELECT status FROM departments AS dept
    WHERE dept.id = schd.id
);


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

SELECT amount FROM warehouses AS whs
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS shp
    WHERE shp.status = whs.status
);


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = empl.type
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = sale.id
);


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

SELECT value FROM invoices AS inv
WHERE id IN (
    SELECT id FROM regions AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT code FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = ordr.code
);


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

SELECT value FROM managers AS mgr
WHERE code IN (
    SELECT code FROM regions AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = catg.code
);


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

SELECT salary FROM schedules AS schd
WHERE value > (
    SELECT SUM(amount) FROM budgets AS budg
    WHERE budg.code = schd.code
);


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

SELECT name FROM accounts AS acct
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.status = acct.status
);


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

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


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

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


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

SELECT salary FROM budgets AS budg
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.code = budg.code
);


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

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


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

SELECT value FROM transactions AS txn
WHERE type IN (
    SELECT type FROM services AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.code = prod.code
);


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

SELECT value FROM shipments AS shp
WHERE amount > (
    SELECT AVG(amount) FROM budgets AS budg
    WHERE budg.type = shp.type
);


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

SELECT code FROM shipments AS shp
WHERE id IN (
    SELECT id FROM services AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT amount FROM services AS srvc
WHERE status IN (
    SELECT status FROM schedules AS schd
    WHERE schd.level = srvc.level
);


Prompt:
Schema:
  requests (alias: ordr)(amount, value, salary, level)
  transactions(amount, id, date, level)
Task: Retrieve value from requests with amount above the MIN(value) of transactions rows sharing the same id.
SQL:

SELECT value FROM requests AS ordr
WHERE amount > (
    SELECT MIN(value) FROM transactions AS txn
    WHERE txn.id = ordr.id
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = acct.status
);


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

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT MIN(salary) FROM products AS prod
    WHERE prod.type = emp.type
);


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

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


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

SELECT salary FROM services AS srvc
WHERE level IN (
    SELECT level FROM regions AS rgn
    WHERE rgn.id = srvc.id
);


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

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


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.type = ord.type
);


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

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


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.status = catg.status
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = catg.id
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = ord.code
);


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

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


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

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT SUM(amount) FROM managers AS mgr
    WHERE mgr.type = cust.type
);


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

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


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

SELECT name FROM products AS prod
WHERE amount > (
    SELECT AVG(amount) FROM categories AS catg
    WHERE catg.code = prod.code
);