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

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT MAX(amount) FROM staff AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT value FROM tasks AS tsk
WHERE amount > (
    SELECT COUNT(salary) FROM schedules AS prod
    WHERE prod.id = tsk.id
);


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

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT COUNT(value) FROM employees AS shp
    WHERE shp.level = cust.level
);


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

SELECT id FROM categories AS catg
WHERE status IN (
    SELECT status FROM departments AS schd
    WHERE schd.type = catg.type
);


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

SELECT id FROM projects AS prj
WHERE id IN (
    SELECT id FROM customers AS catg
    WHERE catg.id = prj.id
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT amount FROM categories AS catg
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.type = catg.type
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM items AS brc
    WHERE brc.type = tsk.type
);


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

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


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

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


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM items AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = sale.level
);


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

SELECT code FROM staff AS empl
WHERE amount > (
    SELECT AVG(amount) FROM sales AS shp
    WHERE shp.code = empl.code
);


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT AVG(amount) FROM branches AS dept
    WHERE dept.status = dept.status
);


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

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


Prompt:
Schema:
  employees (alias: emp)(salary, id, name, amount)
  schedules(value, amount, name, salary)
Task: Find amount from employees where salary exceeds the minimum value from schedules for the same id.
SQL:

SELECT amount FROM employees AS emp
WHERE salary > (
    SELECT MIN(value) FROM schedules AS inv
    WHERE inv.id = emp.id
);


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.status = emp.status
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.code = dept.code
);


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

SELECT id FROM invoices AS inv
WHERE salary > (
    SELECT COUNT(value) FROM products AS tsk
    WHERE tsk.code = inv.code
);


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

SELECT code FROM sales AS sale
WHERE level IN (
    SELECT level FROM accounts AS ord
    WHERE ord.level = sale.level
);


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

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


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

SELECT salary FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM invoices AS prod
    WHERE prod.id = tsk.id
);


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

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


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM tasks AS lne
    WHERE lne.level = ord.level
);


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

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


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

SELECT code FROM departments AS dept
WHERE code IN (
    SELECT code FROM products AS empl
    WHERE empl.level = dept.level
);


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

SELECT value FROM schedules AS schd
WHERE salary > (
    SELECT SUM(salary) FROM customers AS brc
    WHERE brc.type = schd.type
);


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

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


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

SELECT name FROM schedules AS schd
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT code FROM projects AS prj
WHERE status IN (
    SELECT status FROM items AS shp
    WHERE shp.level = prj.level
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS tsk
    WHERE tsk.id = shp.id
);


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

SELECT id FROM projects AS prj
WHERE level IN (
    SELECT level FROM transactions AS emp
    WHERE emp.type = prj.type
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.type = ordr.type
);


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

SELECT salary FROM schedules AS schd
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.level = schd.level
);


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

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


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

SELECT salary FROM shipments AS shp
WHERE id IN (
    SELECT id FROM tasks AS shp
    WHERE shp.type = shp.type
);


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

SELECT code FROM items AS lne
WHERE amount > (
    SELECT MIN(amount) FROM staff AS shp
    WHERE shp.id = lne.id
);


Prompt:
Schema:
  projects (alias: prj)(name, salary, amount, code)
  managers(level, type, amount, salary)
Task: Find value from projects where amount exceeds the total salary from managers for the same type.
SQL:

SELECT value FROM projects AS prj
WHERE amount > (
    SELECT SUM(salary) FROM managers AS ordr
    WHERE ordr.type = prj.type
);


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

SELECT value FROM regions AS rgn
WHERE code IN (
    SELECT code FROM projects AS inv
    WHERE inv.id = rgn.id
);


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

SELECT salary FROM regions AS rgn
WHERE id IN (
    SELECT id FROM staff AS lne
    WHERE lne.level = rgn.level
);


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

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


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

SELECT value FROM items AS lne
WHERE value > (
    SELECT MAX(value) FROM employees AS acct
    WHERE acct.type = lne.type
);


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

SELECT salary FROM sales AS sale
WHERE salary > (
    SELECT MIN(value) FROM schedules AS shp
    WHERE shp.code = sale.code
);


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

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


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

SELECT id FROM regions AS rgn
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.status = rgn.status
);


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

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


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

SELECT code FROM schedules AS schd
WHERE level IN (
    SELECT level FROM departments AS txn
    WHERE txn.status = schd.status
);


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

SELECT amount FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM invoices AS brc
    WHERE brc.level = tsk.level
);


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

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


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

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


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.level = acct.level
);


Prompt:
Schema:
  projects (alias: prj)(name, salary, amount, value)
  customers(salary, date, code, level)
Task: Find amount from projects where amount exceeds the count of value from customers for the same type.
SQL:

SELECT amount FROM projects AS prj
WHERE amount > (
    SELECT COUNT(value) FROM customers AS tsk
    WHERE tsk.type = prj.type
);


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

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


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

SELECT code FROM shipments AS shp
WHERE salary > (
    SELECT MAX(value) FROM accounts AS empl
    WHERE empl.status = shp.status
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.status = prod.status
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM managers AS lne
    WHERE lne.id = prj.id
);


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

SELECT amount FROM products AS prod
WHERE value > (
    SELECT AVG(amount) FROM employees AS schd
    WHERE schd.code = prod.code
);


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

SELECT id FROM requests AS ordr
WHERE type IN (
    SELECT type FROM orders AS acct
    WHERE acct.status = ordr.status
);


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

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


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS tsk
    WHERE tsk.code = schd.code
);


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

SELECT code FROM accounts AS acct
WHERE value > (
    SELECT COUNT(value) FROM transactions AS tsk
    WHERE tsk.id = acct.id
);


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

SELECT code FROM products AS prod
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.type = prod.type
);


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

SELECT salary FROM projects AS prj
WHERE type IN (
    SELECT type FROM items AS catg
    WHERE catg.status = prj.status
);


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

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


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT MAX(value) FROM requests AS shp
    WHERE shp.status = shp.status
);


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

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


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

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


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

SELECT name FROM staff AS empl
WHERE id IN (
    SELECT id FROM customers AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT code FROM items AS lne
WHERE salary > (
    SELECT AVG(salary) FROM sales AS tsk
    WHERE tsk.status = lne.status
);


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

SELECT amount FROM employees AS emp
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS txn
    WHERE txn.level = emp.level
);


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

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


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

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


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

SELECT salary FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.status = tsk.status
);


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

SELECT salary FROM branches AS brc
WHERE type IN (
    SELECT type FROM products AS inv
    WHERE inv.type = brc.type
);


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

SELECT name FROM invoices AS inv
WHERE code IN (
    SELECT code FROM accounts AS shp
    WHERE shp.id = inv.id
);


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT AVG(amount) FROM requests AS acct
    WHERE acct.type = shp.type
);


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

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


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

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


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

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


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM schedules AS ordr
    WHERE ordr.level = lne.level
);


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

SELECT amount FROM items AS lne
WHERE type IN (
    SELECT type FROM branches AS dept
    WHERE dept.id = lne.id
);


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT AVG(value) FROM sales AS emp
    WHERE emp.status = dept.status
);


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

SELECT amount FROM departments AS dept
WHERE status IN (
    SELECT status FROM categories AS empl
    WHERE empl.type = dept.type
);


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

SELECT id FROM categories AS catg
WHERE type IN (
    SELECT type FROM staff AS prod
    WHERE prod.level = catg.level
);


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

SELECT amount FROM products AS prod
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS acct
    WHERE acct.level = prod.level
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.type = inv.type
);


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

SELECT amount FROM requests AS ordr
WHERE status IN (
    SELECT status FROM categories AS prj
    WHERE prj.status = ordr.status
);


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

SELECT salary FROM shipments AS shp
WHERE status IN (
    SELECT status FROM orders AS emp
    WHERE emp.level = shp.level
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.type = prod.type
);


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

SELECT id FROM transactions AS txn
WHERE amount > (
    SELECT MAX(amount) FROM orders AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM staff AS catg
    WHERE catg.level = mgr.level
);


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

SELECT value FROM requests AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM regions AS ord
    WHERE ord.code = ordr.code
);


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

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS tsk
    WHERE tsk.type = empl.type
);


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

SELECT name FROM customers AS cust
WHERE salary > (
    SELECT MAX(salary) FROM employees AS empl
    WHERE empl.id = cust.id
);


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

SELECT amount FROM managers AS mgr
WHERE level IN (
    SELECT level FROM shipments AS mgr
    WHERE mgr.level = mgr.level
);


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

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


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

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


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

SELECT amount FROM transactions AS txn
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.level = txn.level
);


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

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


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

SELECT name FROM customers AS cust
WHERE id IN (
    SELECT id FROM departments AS shp
    WHERE shp.level = cust.level
);


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

SELECT code FROM schedules AS schd
WHERE value > (
    SELECT SUM(amount) FROM orders AS cust
    WHERE cust.code = schd.code
);


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

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


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

SELECT salary FROM categories AS catg
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.status = ordr.status
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.status = acct.status
);


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

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


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

SELECT name FROM accounts AS acct
WHERE level IN (
    SELECT level FROM transactions AS emp
    WHERE emp.code = acct.code
);


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

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


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.type = empl.type
);


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.type = acct.type
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT name FROM employees AS emp
WHERE salary > (
    SELECT SUM(salary) FROM sales AS prod
    WHERE prod.type = emp.type
);


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

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


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

SELECT id FROM regions AS rgn
WHERE salary > (
    SELECT SUM(salary) FROM orders AS prj
    WHERE prj.type = rgn.type
);


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

SELECT code FROM projects AS prj
WHERE salary > (
    SELECT AVG(salary) FROM requests AS mgr
    WHERE mgr.level = prj.level
);


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM sales AS inv
    WHERE inv.type = schd.type
);


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

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


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

SELECT id FROM regions AS rgn
WHERE type IN (
    SELECT type FROM transactions AS acct
    WHERE acct.type = rgn.type
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.status = shp.status
);


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

SELECT value FROM products AS prod
WHERE amount > (
    SELECT MAX(amount) FROM regions AS shp
    WHERE shp.level = prod.level
);


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

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


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

SELECT salary FROM departments AS dept
WHERE salary > (
    SELECT MAX(amount) FROM products AS tsk
    WHERE tsk.type = dept.type
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = cust.status
);


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

SELECT amount FROM branches AS brc
WHERE type IN (
    SELECT type FROM sales AS lne
    WHERE lne.status = brc.status
);


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

SELECT id FROM requests AS ordr
WHERE level IN (
    SELECT level FROM products AS prj
    WHERE prj.code = ordr.code
);


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

SELECT code FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM requests AS catg
    WHERE catg.id = tsk.id
);


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

SELECT amount FROM customers AS cust
WHERE level IN (
    SELECT level FROM transactions AS emp
    WHERE emp.level = cust.level
);


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

SELECT name FROM tasks AS tsk
WHERE value > (
    SELECT MIN(salary) FROM projects AS empl
    WHERE empl.code = tsk.code
);


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

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


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

SELECT value FROM shipments AS shp
WHERE salary > (
    SELECT MIN(value) FROM tasks AS cust
    WHERE cust.code = shp.code
);


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

SELECT salary FROM schedules AS schd
WHERE amount > (
    SELECT MAX(value) FROM sales AS shp
    WHERE shp.type = schd.type
);


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

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


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

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


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM staff AS txn
    WHERE txn.status = ord.status
);


Prompt:
Schema:
  accounts (alias: acct)(code, type, level, id)
  staff(date, code, salary, name)
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 schd
    WHERE schd.status = acct.status
);


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

SELECT name FROM items AS lne
WHERE id IN (
    SELECT id FROM requests AS catg
    WHERE catg.id = lne.id
);


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

SELECT id FROM orders AS ord
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS empl
    WHERE empl.type = ord.type
);


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

SELECT salary FROM orders AS ord
WHERE level IN (
    SELECT level FROM requests AS prj
    WHERE prj.level = ord.level
);


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

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


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.code = prod.code
);


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

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


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

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


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

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


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

SELECT code FROM products AS prod
WHERE salary > (
    SELECT MIN(value) FROM customers AS mgr
    WHERE mgr.code = prod.code
);


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

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


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

SELECT id FROM products AS prod
WHERE type IN (
    SELECT type FROM invoices AS ord
    WHERE ord.code = prod.code
);


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

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


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

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


Prompt:
Schema:
  employees (alias: emp)(level, name, code, date)
  shipments(name, id, date, type)
Task: Find id from employees where amount exceeds the maximum salary from shipments for the same level.
SQL:

SELECT id FROM employees AS emp
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS empl
    WHERE empl.level = emp.level
);


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

SELECT amount FROM departments AS dept
WHERE amount > (
    SELECT AVG(amount) FROM categories AS ord
    WHERE ord.id = dept.id
);


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

SELECT id FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM managers AS acct
    WHERE acct.status = brc.status
);


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT SUM(amount) FROM requests AS inv
    WHERE inv.code = shp.code
);


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

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT AVG(salary) FROM departments AS cust
    WHERE cust.id = lne.id
);


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

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


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

SELECT name FROM products AS prod
WHERE level IN (
    SELECT level FROM projects AS shp
    WHERE shp.status = prod.status
);


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

SELECT code FROM employees AS emp
WHERE code IN (
    SELECT code FROM categories AS prj
    WHERE prj.status = emp.status
);


Prompt:
Schema:
  sales (alias: sale)(amount, type, name, date)
  staff(salary, id, amount, date)
Task: Find id from sales where value exceeds the count of amount from staff for the same id.
SQL:

SELECT id FROM sales AS sale
WHERE value > (
    SELECT COUNT(amount) FROM staff AS shp
    WHERE shp.id = sale.id
);


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS txn
    WHERE txn.code = prj.code
);


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

SELECT value FROM projects AS prj
WHERE amount > (
    SELECT SUM(salary) FROM departments AS rgn
    WHERE rgn.code = prj.code
);


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

SELECT name FROM items AS lne
WHERE code IN (
    SELECT code FROM products AS brc
    WHERE brc.level = lne.level
);


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

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


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

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


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

SELECT name FROM projects AS prj
WHERE type IN (
    SELECT type FROM branches AS dept
    WHERE dept.id = prj.id
);


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

SELECT salary FROM regions AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM staff AS shp
    WHERE shp.status = rgn.status
);


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

SELECT amount FROM items AS lne
WHERE amount > (
    SELECT MAX(amount) FROM orders AS prod
    WHERE prod.id = lne.id
);


Prompt:
Schema:
  customers (alias: cust)(salary, amount, status, date)
  shipments(status, value, salary, date)
Task: Retrieve amount from customers with salary above the COUNT(value) of shipments rows sharing the same code.
SQL:

SELECT amount FROM customers AS cust
WHERE salary > (
    SELECT COUNT(value) FROM shipments AS emp
    WHERE emp.code = cust.code
);


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

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


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

SELECT code FROM accounts AS acct
WHERE type IN (
    SELECT type FROM customers AS empl
    WHERE empl.status = acct.status
);


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

SELECT value FROM products AS prod
WHERE level IN (
    SELECT level FROM tasks AS cust
    WHERE cust.level = prod.level
);


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

SELECT value FROM departments AS dept
WHERE status IN (
    SELECT status FROM products AS dept
    WHERE dept.status = dept.status
);


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

SELECT salary FROM branches AS brc
WHERE code IN (
    SELECT code FROM departments AS empl
    WHERE empl.code = brc.code
);


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

SELECT value FROM employees AS emp
WHERE id IN (
    SELECT id FROM branches AS prod
    WHERE prod.code = emp.code
);


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

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


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

SELECT value FROM transactions AS txn
WHERE value > (
    SELECT SUM(salary) FROM projects AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS dept
    WHERE dept.status = shp.status
);


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

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


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

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


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

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


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

SELECT amount FROM requests AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM sales AS empl
    WHERE empl.type = ordr.type
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.id = catg.id
);


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

SELECT amount FROM invoices AS inv
WHERE type IN (
    SELECT type FROM tasks AS prj
    WHERE prj.code = inv.code
);


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

SELECT code FROM customers AS cust
WHERE id IN (
    SELECT id FROM categories AS emp
    WHERE emp.id = cust.id
);


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

SELECT amount FROM requests AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM products AS tsk
    WHERE tsk.level = ordr.level
);


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

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


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT value FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM projects AS txn
    WHERE txn.level = tsk.level
);


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

SELECT value FROM transactions AS txn
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.status = txn.status
);


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

SELECT amount FROM staff AS empl
WHERE status IN (
    SELECT status FROM sales AS emp
    WHERE emp.type = empl.type
);


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

SELECT value FROM items AS lne
WHERE level IN (
    SELECT level FROM branches AS ord
    WHERE ord.status = lne.status
);


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

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


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS brc
    WHERE brc.code = prod.code
);


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

SELECT id FROM accounts AS acct
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.level = acct.level
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.code = ord.code
);


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

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


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM staff AS acct
    WHERE acct.type = prj.type
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.status = prod.status
);


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

SELECT name FROM accounts AS acct
WHERE code IN (
    SELECT code FROM staff AS shp
    WHERE shp.code = acct.code
);


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

SELECT id FROM items AS lne
WHERE value > (
    SELECT COUNT(salary) FROM sales AS sale
    WHERE sale.level = lne.level
);


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

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


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

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


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM requests AS shp
    WHERE shp.code = empl.code
);


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

SELECT name FROM accounts AS acct
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS acct
    WHERE acct.code = acct.code
);


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

SELECT code FROM sales AS sale
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT value FROM managers AS mgr
WHERE salary > (
    SELECT SUM(value) FROM schedules AS emp
    WHERE emp.level = mgr.level
);


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

SELECT salary FROM invoices AS inv
WHERE status IN (
    SELECT status FROM accounts AS empl
    WHERE empl.id = inv.id
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.status = prj.status
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.level = schd.level
);


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

SELECT id FROM categories AS catg
WHERE type IN (
    SELECT type FROM projects AS prj
    WHERE prj.status = catg.status
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM tasks AS brc
    WHERE brc.code = prj.code
);


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

SELECT salary FROM items AS lne
WHERE status IN (
    SELECT status FROM invoices AS sale
    WHERE sale.code = lne.code
);


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

SELECT amount FROM projects AS prj
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.type = prj.type
);


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

SELECT salary FROM accounts AS acct
WHERE value > (
    SELECT SUM(value) FROM invoices AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM schedules AS dept
    WHERE dept.code = prj.code
);


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

SELECT amount FROM employees AS emp
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS acct
    WHERE acct.level = emp.level
);


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.level = mgr.level
);


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

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


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

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


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

SELECT amount FROM invoices AS inv
WHERE value > (
    SELECT AVG(salary) FROM categories AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT name FROM customers AS cust
WHERE value > (
    SELECT SUM(value) FROM regions AS tsk
    WHERE tsk.level = cust.level
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.id = sale.id
);


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

SELECT name FROM products AS prod
WHERE code IN (
    SELECT code FROM managers AS empl
    WHERE empl.code = prod.code
);


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

SELECT name FROM staff AS empl
WHERE amount > (
    SELECT MIN(salary) FROM regions AS txn
    WHERE txn.level = empl.level
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.type = txn.type
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM sales AS shp
    WHERE shp.code = empl.code
);


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

SELECT value FROM orders AS ord
WHERE value > (
    SELECT MAX(value) FROM transactions AS prj
    WHERE prj.type = ord.type
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.type = prj.type
);


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

SELECT code FROM schedules AS schd
WHERE status IN (
    SELECT status FROM employees AS prj
    WHERE prj.code = schd.code
);


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

SELECT id FROM transactions AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM products AS acct
    WHERE acct.level = txn.level
);


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

SELECT code FROM invoices AS inv
WHERE status IN (
    SELECT status FROM managers AS prj
    WHERE prj.status = inv.status
);


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

SELECT id FROM regions AS rgn
WHERE type IN (
    SELECT type FROM managers AS ord
    WHERE ord.code = rgn.code
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.type = acct.type
);


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

SELECT value FROM sales AS sale
WHERE value > (
    SELECT AVG(salary) FROM requests AS cust
    WHERE cust.id = sale.id
);


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

SELECT id FROM branches AS brc
WHERE value > (
    SELECT AVG(amount) FROM employees AS inv
    WHERE inv.level = brc.level
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = schd.level
);


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

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


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.code = empl.code
);


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

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


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.level = rgn.level
);


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

SELECT value FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM managers AS emp
    WHERE emp.type = tsk.type
);


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

SELECT salary FROM projects AS prj
WHERE code IN (
    SELECT code FROM tasks AS catg
    WHERE catg.level = prj.level
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.status = catg.status
);


Prompt:
Schema:
  customers (alias: cust)(value, level, id, date)
  employees(level, status, amount, type)
Task: Find amount from customers where value exceeds the minimum amount from employees for the same type.
SQL:

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


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

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


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

SELECT amount FROM invoices AS inv
WHERE value > (
    SELECT COUNT(salary) FROM sales AS brc
    WHERE brc.code = inv.code
);


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

SELECT amount FROM departments AS dept
WHERE amount > (
    SELECT AVG(value) FROM products AS ordr
    WHERE ordr.id = dept.id
);


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

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


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

SELECT name FROM regions AS rgn
WHERE code IN (
    SELECT code FROM items AS acct
    WHERE acct.id = rgn.id
);


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

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


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.id = acct.id
);


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

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


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.level = sale.level
);


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

SELECT name FROM orders AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS lne
    WHERE lne.status = ord.status
);


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM staff AS schd
    WHERE schd.status = rgn.status
);


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

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT MAX(amount) FROM projects AS mgr
    WHERE mgr.type = shp.type
);


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

SELECT amount FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM sales AS inv
    WHERE inv.level = tsk.level
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS brc
    WHERE brc.level = dept.level
);


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

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


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

SELECT code FROM projects AS prj
WHERE salary > (
    SELECT MIN(amount) FROM sales AS cust
    WHERE cust.id = prj.id
);


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

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


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

SELECT value FROM branches AS brc
WHERE value > (
    SELECT AVG(value) FROM products AS lne
    WHERE lne.id = brc.id
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.type = inv.type
);


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

SELECT id FROM invoices AS inv
WHERE code IN (
    SELECT code FROM categories AS ord
    WHERE ord.type = inv.type
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM requests AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.type = brc.type
);


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

SELECT id FROM regions AS rgn
WHERE level IN (
    SELECT level FROM tasks AS empl
    WHERE empl.id = rgn.id
);


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

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


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

SELECT amount FROM staff AS empl
WHERE id IN (
    SELECT id FROM departments AS inv
    WHERE inv.status = empl.status
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.type = ordr.type
);


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

SELECT name FROM orders AS ord
WHERE level IN (
    SELECT level FROM schedules AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT id FROM departments AS dept
WHERE status IN (
    SELECT status FROM customers AS schd
    WHERE schd.code = dept.code
);


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

SELECT id FROM products AS prod
WHERE code IN (
    SELECT code FROM items AS dept
    WHERE dept.id = prod.id
);


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT AVG(amount) FROM categories AS txn
    WHERE txn.status = dept.status
);


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

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


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

SELECT name FROM sales AS sale
WHERE level IN (
    SELECT level FROM employees AS inv
    WHERE inv.type = sale.type
);


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

SELECT id FROM branches AS brc
WHERE id IN (
    SELECT id FROM transactions AS empl
    WHERE empl.id = brc.id
);


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

SELECT value FROM schedules AS schd
WHERE salary > (
    SELECT MAX(amount) FROM orders AS prj
    WHERE prj.type = schd.type
);


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

SELECT code FROM customers AS cust
WHERE code IN (
    SELECT code FROM categories AS brc
    WHERE brc.type = cust.type
);


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

SELECT salary FROM requests AS ordr
WHERE level IN (
    SELECT level FROM accounts AS empl
    WHERE empl.status = ordr.status
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT value FROM projects AS prj
WHERE amount > (
    SELECT MAX(value) FROM orders AS dept
    WHERE dept.status = prj.status
);


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

SELECT code FROM products AS prod
WHERE value > (
    SELECT MAX(salary) FROM orders AS tsk
    WHERE tsk.id = prod.id
);


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

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


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

SELECT salary FROM orders AS ord
WHERE type IN (
    SELECT type FROM categories AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.code = acct.code
);


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

SELECT value FROM branches AS brc
WHERE code IN (
    SELECT code FROM items AS acct
    WHERE acct.type = brc.type
);


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

SELECT salary FROM schedules AS schd
WHERE type IN (
    SELECT type FROM requests AS lne
    WHERE lne.code = schd.code
);


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

SELECT value FROM accounts AS acct
WHERE value > (
    SELECT MAX(amount) FROM products AS cust
    WHERE cust.id = acct.id
);


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

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


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

SELECT amount FROM sales AS sale
WHERE code IN (
    SELECT code FROM products AS sale
    WHERE sale.level = sale.level
);


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

SELECT id FROM invoices AS inv
WHERE value > (
    SELECT MAX(salary) FROM sales AS acct
    WHERE acct.type = inv.type
);


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

SELECT code FROM categories AS catg
WHERE code IN (
    SELECT code FROM orders AS tsk
    WHERE tsk.code = catg.code
);


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

SELECT name FROM shipments AS shp
WHERE amount > (
    SELECT AVG(salary) FROM departments AS emp
    WHERE emp.level = shp.level
);


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

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


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT SUM(salary) FROM staff AS emp
    WHERE emp.level = rgn.level
);


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

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


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.status = ord.status
);