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

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


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

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


Prompt:
Schema:
  requests (alias: ordr)(type, date, salary, amount)
  regions(code, amount, date, salary)
Task: Retrieve amount from requests with amount above the AVG(salary) of regions rows sharing the same level.
SQL:

SELECT amount FROM requests AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM regions AS rgn
    WHERE rgn.level = ordr.level
);


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

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


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

SELECT id FROM employees AS emp
WHERE status IN (
    SELECT status FROM departments AS dept
    WHERE dept.code = emp.code
);


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

SELECT amount FROM customers AS cust
WHERE salary > (
    SELECT MIN(value) FROM transactions AS txn
    WHERE txn.type = cust.type
);


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

SELECT value FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS inv
    WHERE inv.level = shp.level
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.code = emp.code
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.code = acct.code
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.id = rgn.id
);


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

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


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

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


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.status = ordr.status
);


Prompt:
Schema:
  budgets (alias: budg)(value, status, date, amount)
  accounts(code, level, value, amount)
Task: Retrieve name from budgets with value above the MIN(amount) of accounts rows sharing the same code.
SQL:

SELECT name FROM budgets AS budg
WHERE value > (
    SELECT MIN(amount) FROM accounts AS acct
    WHERE acct.code = budg.code
);


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

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


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

SELECT code FROM staff AS empl
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.type = empl.type
);


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

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


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.id = rgn.id
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.id = inv.id
);


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

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


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

SELECT value FROM items AS lne
WHERE value > (
    SELECT COUNT(value) FROM managers AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT name FROM services AS srvc
WHERE amount > (
    SELECT MIN(value) FROM requests AS ordr
    WHERE ordr.status = srvc.status
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.level = lne.level
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.type = prod.type
);


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

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


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

SELECT salary FROM services AS srvc
WHERE code IN (
    SELECT code FROM managers AS mgr
    WHERE mgr.level = srvc.level
);


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

SELECT amount FROM staff AS empl
WHERE code IN (
    SELECT code FROM services AS srvc
    WHERE srvc.type = empl.type
);


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

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


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

SELECT code FROM budgets AS budg
WHERE amount > (
    SELECT AVG(amount) FROM categories AS catg
    WHERE catg.id = budg.id
);


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

SELECT salary FROM orders AS ord
WHERE code IN (
    SELECT code FROM regions AS rgn
    WHERE rgn.status = ord.status
);


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

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


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

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


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.status = prod.status
);


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

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


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

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


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

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


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

SELECT value FROM managers AS mgr
WHERE type IN (
    SELECT type FROM schedules AS schd
    WHERE schd.level = mgr.level
);


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.id = ordr.id
);


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

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


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

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


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

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


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

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


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

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


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

SELECT code FROM schedules AS schd
WHERE value > (
    SELECT COUNT(amount) FROM items AS lne
    WHERE lne.code = schd.code
);


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

SELECT salary FROM customers AS cust
WHERE salary > (
    SELECT SUM(salary) FROM orders AS ord
    WHERE ord.status = cust.status
);


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

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


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

SELECT id FROM staff AS empl
WHERE salary > (
    SELECT MIN(amount) FROM schedules AS schd
    WHERE schd.code = empl.code
);


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

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


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

SELECT name FROM services AS srvc
WHERE id IN (
    SELECT id FROM regions AS rgn
    WHERE rgn.code = srvc.code
);


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

SELECT code FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = whs.status
);


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

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


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

SELECT code FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.level = srvc.level
);


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

SELECT salary FROM orders AS ord
WHERE id IN (
    SELECT id FROM transactions AS txn
    WHERE txn.status = ord.status
);


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

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


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

SELECT name FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.status = mgr.status
);


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

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


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

SELECT salary FROM customers AS cust
WHERE level IN (
    SELECT level FROM managers AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT id FROM shipments AS shp
WHERE code IN (
    SELECT code FROM products AS prod
    WHERE prod.level = shp.level
);


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

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


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

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


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = acct.code
);


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

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


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

SELECT name FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.type = whs.type
);


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

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


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.type = acct.type
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE level IN (
    SELECT level FROM transactions AS txn
    WHERE txn.status = mgr.status
);


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

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


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

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


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

SELECT salary FROM sales AS sale
WHERE value > (
    SELECT MIN(amount) FROM products AS prod
    WHERE prod.status = sale.status
);


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

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


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

SELECT id FROM employees AS emp
WHERE type IN (
    SELECT type FROM transactions AS txn
    WHERE txn.type = emp.type
);


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

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


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

SELECT name FROM services AS srvc
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.level = srvc.level
);


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

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


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

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


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

SELECT id FROM services AS srvc
WHERE value > (
    SELECT AVG(amount) FROM staff AS empl
    WHERE empl.status = srvc.status
);


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

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


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.status = cust.status
);


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

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


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

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


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

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


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

SELECT name FROM customers AS cust
WHERE value > (
    SELECT MIN(value) FROM requests AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT code FROM accounts AS acct
WHERE salary > (
    SELECT AVG(value) FROM requests AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT name FROM categories AS catg
WHERE code IN (
    SELECT code FROM invoices AS inv
    WHERE inv.code = catg.code
);


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

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


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

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


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = txn.level
);


Prompt:
Schema:
  shipments (alias: shp)(salary, name, level, status)
  schedules(level, status, value, amount)
Task: Retrieve amount from shipments with salary above the COUNT(value) of schedules rows sharing the same status.
SQL:

SELECT amount FROM shipments AS shp
WHERE salary > (
    SELECT COUNT(value) FROM schedules AS schd
    WHERE schd.status = shp.status
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = txn.status
);


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

SELECT salary FROM services AS srvc
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.status = srvc.status
);


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

SELECT name FROM staff AS empl
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.id = empl.id
);


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

SELECT code FROM services AS srvc
WHERE status IN (
    SELECT status FROM employees AS emp
    WHERE emp.status = srvc.status
);


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

SELECT value FROM warehouses AS whs
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.type = whs.type
);


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

SELECT salary FROM orders AS ord
WHERE amount > (
    SELECT SUM(amount) FROM budgets AS budg
    WHERE budg.code = ord.code
);


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

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


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

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


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

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


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

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


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.status = emp.status
);


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

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


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

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


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT amount FROM categories AS catg
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.type = catg.type
);


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

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


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

SELECT code FROM managers AS mgr
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.level = mgr.level
);


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

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


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

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


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

SELECT amount FROM services AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS inv
    WHERE inv.id = srvc.id
);


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

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


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = mgr.type
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.code = lne.code
);


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

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


Prompt:
Schema:
  staff (alias: empl)(amount, salary, type, name)
  budgets(date, name, level, amount)
Task: Retrieve amount from staff with amount above the AVG(amount) of budgets rows sharing the same type.
SQL:

SELECT amount FROM staff AS empl
WHERE amount > (
    SELECT AVG(amount) FROM budgets AS budg
    WHERE budg.type = empl.type
);


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

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


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

SELECT id FROM departments AS dept
WHERE value > (
    SELECT MAX(value) FROM accounts AS acct
    WHERE acct.id = dept.id
);


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

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


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

SELECT name FROM transactions AS txn
WHERE value > (
    SELECT MIN(salary) FROM orders AS ord
    WHERE ord.status = txn.status
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.code = ordr.code
);


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

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


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

SELECT salary FROM employees AS emp
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.type = emp.type
);


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

SELECT salary FROM invoices AS inv
WHERE code IN (
    SELECT code FROM sales AS sale
    WHERE sale.level = inv.level
);


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

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


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

SELECT salary FROM products AS prod
WHERE level IN (
    SELECT level FROM staff AS empl
    WHERE empl.status = prod.status
);


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

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


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT SUM(amount) FROM categories AS catg
    WHERE catg.status = shp.status
);


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT MAX(value) FROM categories AS catg
    WHERE catg.level = emp.level
);


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

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


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

SELECT code FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.type = whs.type
);


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

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


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

SELECT name FROM invoices AS inv
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.code = inv.code
);


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.id = empl.id
);


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

SELECT amount FROM budgets AS budg
WHERE value > (
    SELECT COUNT(amount) FROM products AS prod
    WHERE prod.id = budg.id
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = txn.status
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.code = inv.code
);


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

SELECT code FROM departments AS dept
WHERE amount > (
    SELECT COUNT(amount) FROM managers AS mgr
    WHERE mgr.id = dept.id
);


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

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


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

SELECT amount FROM departments AS dept
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS whs
    WHERE whs.code = dept.code
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.level = prod.level
);


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

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


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

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


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

SELECT salary FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM services AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT salary FROM orders AS ord
WHERE code IN (
    SELECT code FROM regions AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT id FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.level = srvc.level
);


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

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


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

SELECT code FROM managers AS mgr
WHERE salary > (
    SELECT MIN(value) FROM budgets AS budg
    WHERE budg.type = mgr.type
);


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

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


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

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


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

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


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

SELECT id FROM warehouses AS whs
WHERE code IN (
    SELECT code FROM sales AS sale
    WHERE sale.status = whs.status
);


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

SELECT code FROM transactions AS txn
WHERE amount > (
    SELECT MAX(value) FROM staff AS empl
    WHERE empl.level = txn.level
);


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

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


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

SELECT code FROM services AS srvc
WHERE value > (
    SELECT SUM(amount) FROM customers AS cust
    WHERE cust.level = srvc.level
);


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

SELECT name FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = srvc.code
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.code = inv.code
);


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

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


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

SELECT id FROM schedules AS schd
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.type = schd.type
);


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

SELECT name FROM categories AS catg
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.level = catg.level
);


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

SELECT amount FROM transactions AS txn
WHERE amount > (
    SELECT MAX(salary) FROM departments AS dept
    WHERE dept.id = txn.id
);


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

SELECT code FROM managers AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM schedules AS schd
    WHERE schd.id = mgr.id
);


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

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


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.level = ordr.level
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.level = dept.level
);


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

SELECT name FROM schedules AS schd
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.status = schd.status
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.status = prod.status
);


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

SELECT code FROM schedules AS schd
WHERE salary > (
    SELECT SUM(salary) FROM employees AS emp
    WHERE emp.type = schd.type
);


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

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


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

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


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

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


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.status = sale.status
);


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

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


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

SELECT value FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.type = budg.type
);


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

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


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT MIN(value) FROM requests AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT value FROM budgets AS budg
WHERE status IN (
    SELECT status FROM transactions AS txn
    WHERE txn.code = budg.code
);


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

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


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

SELECT value FROM budgets AS budg
WHERE value > (
    SELECT MAX(salary) FROM requests AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.type = shp.type
);


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

SELECT name FROM staff AS empl
WHERE amount > (
    SELECT SUM(salary) FROM departments AS dept
    WHERE dept.code = empl.code
);


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

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


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

SELECT name FROM categories AS catg
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS whs
    WHERE whs.type = catg.type
);


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

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


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = dept.level
);


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

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


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

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


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

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


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

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


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

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


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.id = prod.id
);


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

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


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

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


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

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


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

SELECT name FROM accounts AS acct
WHERE code IN (
    SELECT code FROM services AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = schd.status
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = dept.level
);


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

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


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

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


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

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


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

SELECT salary FROM departments AS dept
WHERE type IN (
    SELECT type FROM accounts AS acct
    WHERE acct.status = dept.status
);


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

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


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

SELECT name FROM staff AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS catg
    WHERE catg.type = empl.type
);


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

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


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.type = empl.type
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = rgn.id
);


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

SELECT code FROM orders AS ord
WHERE value > (
    SELECT MIN(amount) FROM regions AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.id = acct.id
);


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

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


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

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


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

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


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

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


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

SELECT code FROM services AS srvc
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.id = srvc.id
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.type = prod.type
);


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

SELECT id FROM staff AS empl
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.type = empl.type
);


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

SELECT name FROM managers AS mgr
WHERE value > (
    SELECT AVG(value) FROM invoices AS inv
    WHERE inv.id = mgr.id
);


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

SELECT amount FROM schedules AS schd
WHERE value > (
    SELECT MAX(value) FROM departments AS dept
    WHERE dept.type = schd.type
);


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

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT AVG(salary) FROM shipments AS shp
    WHERE shp.level = rgn.level
);


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

SELECT amount FROM budgets AS budg
WHERE value > (
    SELECT AVG(salary) FROM requests AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT value FROM warehouses AS whs
WHERE code IN (
    SELECT code FROM items AS lne
    WHERE lne.type = whs.type
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT salary FROM warehouses AS whs
WHERE id IN (
    SELECT id FROM budgets AS budg
    WHERE budg.status = whs.status
);


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = ordr.status
);


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

SELECT salary FROM employees AS emp
WHERE value > (
    SELECT MAX(salary) FROM customers AS cust
    WHERE cust.status = emp.status
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = cust.id
);


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

SELECT code FROM orders AS ord
WHERE status IN (
    SELECT status FROM managers AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT value FROM budgets AS budg
WHERE level IN (
    SELECT level FROM regions AS rgn
    WHERE rgn.code = budg.code
);


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

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


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = ord.level
);


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

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


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

SELECT amount FROM services AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS acct
    WHERE acct.status = srvc.status
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = schd.code
);


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

SELECT name FROM services AS srvc
WHERE id IN (
    SELECT id FROM managers AS mgr
    WHERE mgr.level = srvc.level
);


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

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


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

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


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

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


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT AVG(amount) FROM products AS prod
    WHERE prod.id = rgn.id
);


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

SELECT code FROM categories AS catg
WHERE salary > (
    SELECT SUM(salary) FROM employees AS emp
    WHERE emp.id = catg.id
);


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

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


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

SELECT id FROM requests AS ordr
WHERE value > (
    SELECT SUM(value) FROM products AS prod
    WHERE prod.level = ordr.level
);


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

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


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

SELECT amount FROM transactions AS txn
WHERE salary > (
    SELECT AVG(value) FROM invoices AS inv
    WHERE inv.status = txn.status
);


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

SELECT name FROM sales AS sale
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.level = sale.level
);


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

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


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = emp.code
);


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

SELECT amount FROM regions AS rgn
WHERE value > (
    SELECT MAX(value) FROM managers AS mgr
    WHERE mgr.status = rgn.status
);


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

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


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

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


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

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


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

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


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

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


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

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


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = schd.status
);


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

SELECT salary FROM categories AS catg
WHERE level IN (
    SELECT level FROM managers AS mgr
    WHERE mgr.status = catg.status
);


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

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


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

SELECT id FROM shipments AS shp
WHERE salary > (
    SELECT SUM(value) FROM accounts AS acct
    WHERE acct.type = shp.type
);


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

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


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

SELECT amount FROM accounts AS acct
WHERE amount > (
    SELECT MAX(salary) FROM categories AS catg
    WHERE catg.status = acct.status
);


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

SELECT name FROM accounts AS acct
WHERE amount > (
    SELECT SUM(value) FROM departments AS dept
    WHERE dept.id = acct.id
);


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

SELECT amount FROM budgets AS budg
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS acct
    WHERE acct.code = budg.code
);


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

SELECT name FROM staff AS empl
WHERE id IN (
    SELECT id FROM departments AS dept
    WHERE dept.status = empl.status
);


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

SELECT name FROM orders AS ord
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.id = ord.id
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.type = rgn.type
);


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

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


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

SELECT amount FROM regions AS rgn
WHERE value > (
    SELECT MIN(value) FROM managers AS mgr
    WHERE mgr.status = rgn.status
);


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

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


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

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


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

SELECT name FROM invoices AS inv
WHERE type IN (
    SELECT type FROM transactions AS txn
    WHERE txn.id = inv.id
);


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

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


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

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


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

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


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

SELECT id FROM shipments AS shp
WHERE salary > (
    SELECT AVG(amount) FROM staff AS empl
    WHERE empl.type = shp.type
);


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

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT COUNT(value) FROM managers AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.type = prod.type
);


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

SELECT name FROM managers AS mgr
WHERE salary > (
    SELECT MAX(salary) FROM regions AS rgn
    WHERE rgn.id = mgr.id
);


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

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


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

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


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

SELECT name FROM sales AS sale
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.code = sale.code
);


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

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


Prompt:
Schema:
  shipments (alias: shp)(level, date, salary, status)
  items(salary, level, date, code)
Task: Retrieve name from shipments with salary above the MIN(salary) of items rows sharing the same status.
SQL:

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT MIN(salary) FROM items AS lne
    WHERE lne.status = shp.status
);


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

SELECT name FROM services AS srvc
WHERE value > (
    SELECT MIN(value) FROM warehouses AS whs
    WHERE whs.code = srvc.code
);


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

SELECT code FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = mgr.code
);


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

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


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.status = dept.status
);


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

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


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

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


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

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


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.id = shp.id
);


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

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