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

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT amount FROM requests AS ordr
WHERE id IN (
    SELECT id FROM transactions AS shp
    WHERE shp.status = ordr.status
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.level = cust.level
);


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

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


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

SELECT id FROM staff AS empl
WHERE level IN (
    SELECT level FROM sales AS acct
    WHERE acct.type = empl.type
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM staff AS shp
    WHERE shp.id = tsk.id
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.type = cust.type
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.level = rgn.level
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS tsk
    WHERE tsk.status = ord.status
);


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

SELECT amount FROM employees AS emp
WHERE level IN (
    SELECT level FROM staff AS acct
    WHERE acct.type = emp.type
);


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

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


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

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


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

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


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

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


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.code = catg.code
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.type = tsk.type
);


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

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


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

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


Prompt:
Schema:
  orders (alias: ord)(date, code, value, name)
  products(level, date, id, salary)
Task: Find salary from orders where value exceeds the count of salary from products for the same id.
SQL:

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


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

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


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

SELECT name FROM regions AS rgn
WHERE type IN (
    SELECT type FROM requests AS rgn
    WHERE rgn.code = rgn.code
);


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

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.level = inv.level
);


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

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


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

SELECT name FROM projects AS prj
WHERE value > (
    SELECT COUNT(value) FROM products AS txn
    WHERE txn.level = prj.level
);


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

SELECT amount FROM customers AS cust
WHERE level IN (
    SELECT level FROM tasks AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT value FROM branches AS brc
WHERE code IN (
    SELECT code FROM orders AS catg
    WHERE catg.status = brc.status
);


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

SELECT value FROM staff AS empl
WHERE value > (
    SELECT MIN(value) FROM products AS prod
    WHERE prod.level = empl.level
);


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

SELECT id FROM transactions AS txn
WHERE value > (
    SELECT MAX(value) FROM schedules AS emp
    WHERE emp.id = txn.id
);


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

SELECT amount FROM orders AS ord
WHERE type IN (
    SELECT type FROM categories AS inv
    WHERE inv.code = ord.code
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS brc
    WHERE brc.type = shp.type
);


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM sales AS prod
    WHERE prod.id = ord.id
);


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

SELECT code FROM items AS lne
WHERE code IN (
    SELECT code FROM branches AS tsk
    WHERE tsk.level = lne.level
);


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

SELECT name FROM schedules AS schd
WHERE id IN (
    SELECT id FROM employees AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM staff AS dept
    WHERE dept.level = inv.level
);


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

SELECT amount FROM projects AS prj
WHERE type IN (
    SELECT type FROM invoices AS rgn
    WHERE rgn.type = prj.type
);


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

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


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

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


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

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


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

SELECT amount FROM products AS prod
WHERE value > (
    SELECT SUM(salary) FROM invoices AS prod
    WHERE prod.status = prod.status
);


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

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


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

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


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

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS schd
    WHERE schd.id = ord.id
);


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

SELECT value FROM transactions AS txn
WHERE salary > (
    SELECT AVG(amount) FROM categories AS brc
    WHERE brc.id = txn.id
);


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

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


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

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


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

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


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS prj
    WHERE prj.status = empl.status
);


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

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


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.id = shp.id
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.status = empl.status
);


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

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


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

SELECT code FROM requests AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM products AS ordr
    WHERE ordr.code = ordr.code
);


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

SELECT code FROM shipments AS shp
WHERE value > (
    SELECT AVG(value) FROM items AS catg
    WHERE catg.status = shp.status
);


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

SELECT value FROM staff AS empl
WHERE amount > (
    SELECT COUNT(value) FROM items AS catg
    WHERE catg.code = empl.code
);


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

SELECT value FROM sales AS sale
WHERE value > (
    SELECT COUNT(value) FROM departments AS prj
    WHERE prj.level = sale.level
);


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

SELECT value FROM transactions AS txn
WHERE value > (
    SELECT MIN(value) FROM branches AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.code = mgr.code
);


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

SELECT name FROM managers AS mgr
WHERE salary > (
    SELECT MAX(amount) FROM employees AS schd
    WHERE schd.status = mgr.status
);


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

SELECT name FROM regions AS rgn
WHERE value > (
    SELECT MIN(value) FROM shipments AS inv
    WHERE inv.id = rgn.id
);


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

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


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

SELECT name FROM accounts AS acct
WHERE amount > (
    SELECT AVG(value) FROM schedules AS txn
    WHERE txn.type = acct.type
);


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

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


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

SELECT code FROM projects AS prj
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.code = prj.code
);


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

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


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

SELECT name FROM tasks AS tsk
WHERE salary > (
    SELECT SUM(amount) FROM schedules AS dept
    WHERE dept.status = tsk.status
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM staff AS emp
    WHERE emp.code = schd.code
);


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

SELECT amount FROM orders AS ord
WHERE code IN (
    SELECT code FROM departments AS catg
    WHERE catg.level = ord.level
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.code = ordr.code
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.status = empl.status
);


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

SELECT name FROM orders AS ord
WHERE type IN (
    SELECT type FROM branches AS acct
    WHERE acct.type = ord.type
);


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

SELECT code FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.status = prj.status
);


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

SELECT amount FROM accounts AS acct
WHERE level IN (
    SELECT level FROM sales AS ord
    WHERE ord.status = acct.status
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.status = empl.status
);


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM managers AS acct
    WHERE acct.level = sale.level
);


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

SELECT name FROM schedules AS schd
WHERE code IN (
    SELECT code FROM projects AS inv
    WHERE inv.status = schd.status
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM staff AS dept
    WHERE dept.code = lne.code
);


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

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


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.type = brc.type
);


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

SELECT name FROM customers AS cust
WHERE status IN (
    SELECT status FROM accounts AS emp
    WHERE emp.type = cust.type
);


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.level = cust.level
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.code = rgn.code
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.type = sale.type
);


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

SELECT salary FROM invoices AS inv
WHERE value > (
    SELECT SUM(value) FROM shipments AS ord
    WHERE ord.status = inv.status
);


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

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


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

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


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

SELECT amount FROM departments AS dept
WHERE type IN (
    SELECT type FROM schedules AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT amount FROM items AS lne
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS txn
    WHERE txn.code = lne.code
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM staff AS shp
    WHERE shp.status = acct.status
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.status = shp.status
);


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

SELECT name FROM staff AS empl
WHERE status IN (
    SELECT status FROM transactions AS inv
    WHERE inv.code = empl.code
);


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

SELECT id FROM requests AS ordr
WHERE value > (
    SELECT SUM(value) FROM tasks AS sale
    WHERE sale.code = ordr.code
);


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

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


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

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


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

SELECT code FROM categories AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM schedules AS shp
    WHERE shp.level = catg.level
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.status = lne.status
);


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

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


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

SELECT code FROM branches AS brc
WHERE status IN (
    SELECT status FROM sales AS inv
    WHERE inv.code = brc.code
);


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

SELECT value FROM departments AS dept
WHERE value > (
    SELECT MAX(salary) FROM orders AS inv
    WHERE inv.status = dept.status
);


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

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


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

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


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

SELECT code FROM branches AS brc
WHERE value > (
    SELECT AVG(salary) FROM departments AS tsk
    WHERE tsk.id = brc.id
);


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

SELECT salary FROM schedules AS schd
WHERE status IN (
    SELECT status FROM managers AS ordr
    WHERE ordr.id = schd.id
);


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

SELECT amount FROM managers AS mgr
WHERE status IN (
    SELECT status FROM sales AS prj
    WHERE prj.level = mgr.level
);


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

SELECT value FROM categories AS catg
WHERE level IN (
    SELECT level FROM orders AS dept
    WHERE dept.status = catg.status
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.status = acct.status
);


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = prj.id
);


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

SELECT code FROM schedules AS schd
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS emp
    WHERE emp.code = schd.code
);


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

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


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

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


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM transactions AS tsk
    WHERE tsk.code = catg.code
);


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

SELECT value FROM categories AS catg
WHERE salary > (
    SELECT AVG(value) FROM sales AS prj
    WHERE prj.status = catg.status
);


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

SELECT id FROM employees AS emp
WHERE type IN (
    SELECT type FROM items AS acct
    WHERE acct.code = emp.code
);


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

SELECT id FROM requests AS ordr
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS prod
    WHERE prod.level = ordr.level
);


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

SELECT id FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM employees AS mgr
    WHERE mgr.type = tsk.type
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM sales AS lne
    WHERE lne.type = dept.type
);


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

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


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM sales AS ordr
    WHERE ordr.code = empl.code
);


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

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


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.status = prod.status
);


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

SELECT amount FROM products AS prod
WHERE code IN (
    SELECT code FROM transactions AS acct
    WHERE acct.type = prod.type
);


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

SELECT id FROM accounts AS acct
WHERE salary > (
    SELECT SUM(value) FROM branches AS txn
    WHERE txn.code = acct.code
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM requests AS mgr
    WHERE mgr.code = shp.code
);


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM employees AS brc
    WHERE brc.code = prj.code
);


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

SELECT id FROM schedules AS schd
WHERE value > (
    SELECT MIN(salary) FROM requests AS inv
    WHERE inv.level = schd.level
);


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

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


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

SELECT id FROM departments AS dept
WHERE value > (
    SELECT MAX(salary) FROM customers AS inv
    WHERE inv.id = dept.id
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS tsk
    WHERE tsk.type = dept.type
);


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

SELECT id FROM regions AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM items AS shp
    WHERE shp.code = rgn.code
);


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

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


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

SELECT salary FROM sales AS sale
WHERE status IN (
    SELECT status FROM items AS prod
    WHERE prod.status = sale.status
);


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

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


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

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


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.level = schd.level
);


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

SELECT value FROM transactions AS txn
WHERE value > (
    SELECT MAX(value) FROM sales AS shp
    WHERE shp.status = txn.status
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.status = prod.status
);


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

SELECT id FROM accounts AS acct
WHERE code IN (
    SELECT code FROM invoices AS prj
    WHERE prj.type = acct.type
);


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

SELECT id FROM accounts AS acct
WHERE type IN (
    SELECT type FROM employees AS cust
    WHERE cust.id = acct.id
);


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

SELECT value FROM items AS lne
WHERE type IN (
    SELECT type FROM staff AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT value FROM transactions AS txn
WHERE status IN (
    SELECT status FROM employees AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.id = dept.id
);


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

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


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

SELECT code FROM departments AS dept
WHERE salary > (
    SELECT AVG(amount) FROM orders AS ord
    WHERE ord.type = dept.type
);


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

SELECT value FROM items AS lne
WHERE level IN (
    SELECT level FROM categories AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.status = lne.status
);


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

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


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

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


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM staff AS sale
    WHERE sale.status = tsk.status
);


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

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


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

SELECT code FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.level = mgr.level
);


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT SUM(amount) FROM tasks AS tsk
    WHERE tsk.code = emp.code
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM regions AS brc
    WHERE brc.id = tsk.id
);


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

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


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

SELECT name FROM regions AS rgn
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS lne
    WHERE lne.type = rgn.type
);


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

SELECT id FROM managers AS mgr
WHERE level IN (
    SELECT level FROM schedules AS brc
    WHERE brc.code = mgr.code
);


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

SELECT amount FROM transactions AS txn
WHERE status IN (
    SELECT status FROM employees AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT id FROM transactions AS txn
WHERE code IN (
    SELECT code FROM staff AS schd
    WHERE schd.type = txn.type
);


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

SELECT id FROM employees AS emp
WHERE level IN (
    SELECT level FROM products AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT amount FROM sales AS sale
WHERE type IN (
    SELECT type FROM transactions AS prod
    WHERE prod.status = sale.status
);


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

SELECT amount FROM invoices AS inv
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.level = inv.level
);


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

SELECT salary FROM sales AS sale
WHERE value > (
    SELECT MIN(value) FROM customers AS ord
    WHERE ord.type = sale.type
);


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

SELECT salary FROM tasks AS tsk
WHERE amount > (
    SELECT SUM(value) FROM shipments AS inv
    WHERE inv.type = tsk.type
);


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

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT MAX(salary) FROM managers AS txn
    WHERE txn.code = ord.code
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.status = ord.status
);


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

SELECT amount FROM requests AS ordr
WHERE level IN (
    SELECT level FROM customers AS prj
    WHERE prj.type = ordr.type
);


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

SELECT code FROM branches AS brc
WHERE salary > (
    SELECT AVG(amount) FROM categories AS ord
    WHERE ord.status = brc.status
);


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

SELECT id FROM accounts AS acct
WHERE status IN (
    SELECT status FROM transactions AS tsk
    WHERE tsk.id = acct.id
);


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

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


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

SELECT amount FROM departments AS dept
WHERE level IN (
    SELECT level FROM tasks AS rgn
    WHERE rgn.id = dept.id
);


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

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


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

SELECT code FROM schedules AS schd
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.level = schd.level
);


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

SELECT amount FROM transactions AS txn
WHERE salary > (
    SELECT COUNT(value) FROM projects AS dept
    WHERE dept.code = txn.code
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.level = catg.level
);


Prompt:
Schema:
  accounts (alias: acct)(salary, id, code, level)
  shipments(id, type, date, salary)
Task: Find id from accounts where value exceeds the count of salary from shipments for the same status.
SQL:

SELECT id FROM accounts AS acct
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS lne
    WHERE lne.status = acct.status
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.type = lne.type
);


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

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


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

SELECT id FROM invoices AS inv
WHERE type IN (
    SELECT type FROM items AS prj
    WHERE prj.level = inv.level
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.id = sale.id
);


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

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


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.code = prod.code
);


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

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


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.id = emp.id
);


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

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


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

SELECT code FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM sales AS acct
    WHERE acct.type = mgr.type
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.type = mgr.type
);


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

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


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

SELECT salary FROM branches AS brc
WHERE type IN (
    SELECT type FROM categories AS ordr
    WHERE ordr.level = brc.level
);


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

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


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS tsk
    WHERE tsk.id = emp.id
);


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

SELECT value FROM customers AS cust
WHERE status IN (
    SELECT status FROM tasks AS lne
    WHERE lne.id = cust.id
);


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

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


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.level = shp.level
);


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

SELECT salary FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM employees AS lne
    WHERE lne.code = tsk.code
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.level = emp.level
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE code IN (
    SELECT code FROM managers AS brc
    WHERE brc.level = txn.level
);


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

SELECT salary FROM customers AS cust
WHERE level IN (
    SELECT level FROM staff AS empl
    WHERE empl.id = cust.id
);


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

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


Prompt:
Schema:
  schedules (alias: schd)(type, status, level, date)
  shipments(date, amount, value, type)
Task: Retrieve amount from schedules with amount above the MAX(value) of shipments rows sharing the same status.
SQL:

SELECT amount FROM schedules AS schd
WHERE amount > (
    SELECT MAX(value) FROM shipments AS inv
    WHERE inv.status = schd.status
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS brc
    WHERE brc.status = shp.status
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM requests AS schd
    WHERE schd.id = brc.id
);


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

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


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

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


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

SELECT value FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM staff AS dept
    WHERE dept.status = tsk.status
);


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

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


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

SELECT value FROM branches AS brc
WHERE amount > (
    SELECT MAX(value) FROM schedules AS ord
    WHERE ord.code = brc.code
);


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS sale
    WHERE sale.code = catg.code
);


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

SELECT code FROM branches AS brc
WHERE salary > (
    SELECT AVG(salary) FROM staff AS lne
    WHERE lne.level = brc.level
);


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

SELECT value FROM sales AS sale
WHERE value > (
    SELECT MAX(salary) FROM projects AS ordr
    WHERE ordr.code = sale.code
);


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

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


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.status = emp.status
);


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

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


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

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT MAX(value) FROM projects AS ord
    WHERE ord.id = cust.id
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.level = lne.level
);


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

SELECT id FROM items AS lne
WHERE salary > (
    SELECT AVG(value) FROM categories AS dept
    WHERE dept.status = lne.status
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM requests AS sale
    WHERE sale.level = mgr.level
);


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

SELECT name FROM regions AS rgn
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.id = rgn.id
);


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

SELECT amount FROM employees AS emp
WHERE level IN (
    SELECT level FROM branches AS shp
    WHERE shp.status = emp.status
);


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

SELECT value FROM projects AS prj
WHERE id IN (
    SELECT id FROM branches AS lne
    WHERE lne.code = prj.code
);


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

SELECT salary FROM orders AS ord
WHERE level IN (
    SELECT level FROM employees AS inv
    WHERE inv.status = ord.status
);


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

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


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

SELECT code FROM managers AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS prod
    WHERE prod.level = mgr.level
);


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

SELECT value FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM departments AS inv
    WHERE inv.level = tsk.level
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.code = tsk.code
);


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

SELECT id FROM requests AS ordr
WHERE salary > (
    SELECT MAX(value) FROM tasks AS inv
    WHERE inv.id = ordr.id
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.type = mgr.type
);


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

SELECT id FROM employees AS emp
WHERE amount > (
    SELECT COUNT(value) FROM schedules AS txn
    WHERE txn.level = emp.level
);


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

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


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

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


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.level = shp.level
);


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

SELECT name FROM schedules AS schd
WHERE salary > (
    SELECT SUM(amount) FROM branches AS prj
    WHERE prj.status = schd.status
);


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

SELECT value FROM regions AS rgn
WHERE status IN (
    SELECT status FROM products AS tsk
    WHERE tsk.code = rgn.code
);


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

SELECT amount FROM sales AS sale
WHERE type IN (
    SELECT type FROM accounts AS lne
    WHERE lne.level = sale.level
);


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

SELECT value FROM transactions AS txn
WHERE value > (
    SELECT MIN(value) FROM items AS txn
    WHERE txn.type = txn.type
);


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

SELECT code FROM customers AS cust
WHERE id IN (
    SELECT id FROM employees AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.status = prj.status
);


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

SELECT code FROM categories AS catg
WHERE level IN (
    SELECT level FROM shipments AS prj
    WHERE prj.status = catg.status
);


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

SELECT id FROM regions AS rgn
WHERE amount > (
    SELECT COUNT(salary) FROM invoices AS acct
    WHERE acct.id = rgn.id
);


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

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


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

SELECT value FROM managers AS mgr
WHERE value > (
    SELECT COUNT(value) FROM staff AS emp
    WHERE emp.status = mgr.status
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.id = prod.id
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.type = cust.type
);


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

SELECT salary FROM accounts AS acct
WHERE salary > (
    SELECT MIN(salary) FROM employees AS emp
    WHERE emp.type = acct.type
);


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

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


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = cust.type
);


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

SELECT code FROM sales AS sale
WHERE amount > (
    SELECT AVG(amount) FROM regions AS emp
    WHERE emp.code = sale.code
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.type = ord.type
);


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

SELECT amount FROM orders AS ord
WHERE id IN (
    SELECT id FROM requests AS cust
    WHERE cust.id = ord.id
);


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

SELECT value FROM regions AS rgn
WHERE amount > (
    SELECT AVG(salary) FROM items AS prj
    WHERE prj.code = rgn.code
);


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

SELECT value FROM shipments AS shp
WHERE value > (
    SELECT MIN(value) FROM invoices AS schd
    WHERE schd.type = shp.type
);


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

SELECT code FROM branches AS brc
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.code = brc.code
);


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

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


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

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


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

SELECT value FROM requests AS ordr
WHERE code IN (
    SELECT code FROM projects AS tsk
    WHERE tsk.code = ordr.code
);


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

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


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

SELECT id FROM orders AS ord
WHERE value > (
    SELECT MIN(amount) FROM tasks AS brc
    WHERE brc.level = ord.level
);


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

SELECT name FROM accounts AS acct
WHERE amount > (
    SELECT MAX(value) FROM items AS cust
    WHERE cust.code = acct.code
);


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.code = sale.code
);


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

SELECT name FROM managers AS mgr
WHERE value > (
    SELECT AVG(value) FROM tasks AS emp
    WHERE emp.level = mgr.level
);


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

SELECT salary FROM invoices AS inv
WHERE salary > (
    SELECT COUNT(value) FROM projects AS sale
    WHERE sale.id = inv.id
);


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

SELECT id FROM shipments AS shp
WHERE status IN (
    SELECT status FROM products AS rgn
    WHERE rgn.status = shp.status
);


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

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


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

SELECT value FROM orders AS ord
WHERE salary > (
    SELECT MIN(salary) FROM schedules AS schd
    WHERE schd.type = ord.type
);


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

SELECT id FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM staff AS mgr
    WHERE mgr.type = tsk.type
);


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

SELECT value FROM invoices AS inv
WHERE type IN (
    SELECT type FROM requests AS ord
    WHERE ord.status = inv.status
);


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

SELECT value FROM employees AS emp
WHERE type IN (
    SELECT type FROM tasks AS inv
    WHERE inv.type = emp.type
);


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.status = brc.status
);


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

SELECT value FROM managers AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM schedules AS rgn
    WHERE rgn.type = mgr.type
);


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

SELECT salary FROM managers AS mgr
WHERE code IN (
    SELECT code FROM products AS acct
    WHERE acct.level = mgr.level
);


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

SELECT salary FROM regions AS rgn
WHERE value > (
    SELECT MIN(amount) FROM invoices AS schd
    WHERE schd.type = rgn.type
);


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

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


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS brc
    WHERE brc.level = schd.level
);


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

SELECT code FROM regions AS rgn
WHERE type IN (
    SELECT type FROM transactions AS brc
    WHERE brc.level = rgn.level
);


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

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


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM managers AS prj
    WHERE prj.type = tsk.type
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.id = cust.id
);


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

SELECT value FROM branches AS brc
WHERE value > (
    SELECT MIN(value) FROM tasks AS acct
    WHERE acct.status = brc.status
);


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

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


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

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


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

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


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

SELECT code FROM shipments AS shp
WHERE code IN (
    SELECT code FROM invoices AS catg
    WHERE catg.code = shp.code
);


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

SELECT salary FROM sales AS sale
WHERE id IN (
    SELECT id FROM managers AS inv
    WHERE inv.status = sale.status
);


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

SELECT code FROM transactions AS txn
WHERE level IN (
    SELECT level FROM regions AS dept
    WHERE dept.id = txn.id
);


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

SELECT value FROM products AS prod
WHERE salary > (
    SELECT COUNT(salary) FROM schedules AS inv
    WHERE inv.id = prod.id
);


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

SELECT value FROM employees AS emp
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS acct
    WHERE acct.level = emp.level
);


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

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


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

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


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

SELECT code FROM orders AS ord
WHERE salary > (
    SELECT AVG(value) FROM products AS sale
    WHERE sale.id = ord.id
);


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

SELECT name FROM projects AS prj
WHERE level IN (
    SELECT level FROM invoices AS emp
    WHERE emp.code = prj.code
);


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

SELECT value FROM items AS lne
WHERE code IN (
    SELECT code FROM categories AS shp
    WHERE shp.status = lne.status
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS prj
    WHERE prj.type = txn.type
);


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

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


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

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


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

SELECT salary FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM departments AS schd
    WHERE schd.type = tsk.type
);


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

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


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

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


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

SELECT id FROM tasks AS tsk
WHERE salary > (
    SELECT AVG(value) FROM products AS acct
    WHERE acct.code = tsk.code
);


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

SELECT code FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM staff AS schd
    WHERE schd.code = prj.code
);