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

SELECT id FROM managers AS mgr
WHERE value > (
    SELECT AVG(salary) FROM orders AS catg
    WHERE catg.type = mgr.type
);


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

SELECT name FROM customers AS cust
WHERE amount > (
    SELECT MAX(salary) FROM categories AS cust
    WHERE cust.code = cust.code
);


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

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


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM customers AS catg
    WHERE catg.type = ord.type
);


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

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


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

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


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM sales AS dept
    WHERE dept.status = ord.status
);


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

SELECT id FROM requests AS ordr
WHERE amount > (
    SELECT MAX(value) FROM departments AS cust
    WHERE cust.code = ordr.code
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM requests AS dept
    WHERE dept.type = inv.type
);


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

SELECT name FROM categories AS catg
WHERE code IN (
    SELECT code FROM branches AS lne
    WHERE lne.status = catg.status
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.code = lne.code
);


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

SELECT code FROM branches AS brc
WHERE code IN (
    SELECT code FROM shipments AS prj
    WHERE prj.type = brc.type
);


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

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


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

SELECT value FROM regions AS rgn
WHERE status IN (
    SELECT status FROM staff AS schd
    WHERE schd.level = rgn.level
);


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

SELECT code FROM requests AS ordr
WHERE type IN (
    SELECT type FROM staff AS tsk
    WHERE tsk.status = ordr.status
);


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

SELECT id FROM branches AS brc
WHERE level IN (
    SELECT level FROM departments AS prj
    WHERE prj.id = brc.id
);


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

SELECT id FROM staff AS empl
WHERE value > (
    SELECT COUNT(salary) FROM regions AS prj
    WHERE prj.level = empl.level
);


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

SELECT salary FROM orders AS ord
WHERE type IN (
    SELECT type FROM transactions AS shp
    WHERE shp.status = ord.status
);


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

SELECT salary FROM shipments AS shp
WHERE id IN (
    SELECT id FROM branches AS ord
    WHERE ord.code = shp.code
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.id = ord.id
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.type = inv.type
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM regions AS tsk
    WHERE tsk.type = tsk.type
);


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

SELECT code FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.status = brc.status
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.id = txn.id
);


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

SELECT id FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.code = brc.code
);


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

SELECT value FROM products AS prod
WHERE id IN (
    SELECT id FROM customers AS catg
    WHERE catg.level = prod.level
);


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

SELECT value FROM sales AS sale
WHERE salary > (
    SELECT MAX(value) FROM items AS prj
    WHERE prj.level = sale.level
);


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

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


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

SELECT code FROM sales AS sale
WHERE amount > (
    SELECT AVG(value) FROM employees AS schd
    WHERE schd.id = sale.id
);


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

SELECT salary FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM managers AS prod
    WHERE prod.level = tsk.level
);


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

SELECT amount FROM projects AS prj
WHERE code IN (
    SELECT code FROM categories AS rgn
    WHERE rgn.status = prj.status
);


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

SELECT id FROM managers AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM requests AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.status = shp.status
);


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

SELECT name FROM employees AS emp
WHERE id IN (
    SELECT id FROM departments AS sale
    WHERE sale.type = emp.type
);


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

SELECT amount FROM branches AS brc
WHERE value > (
    SELECT SUM(amount) FROM departments AS catg
    WHERE catg.status = brc.status
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.type = acct.type
);


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

SELECT name FROM departments AS dept
WHERE value > (
    SELECT COUNT(amount) FROM employees AS empl
    WHERE empl.level = dept.level
);


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

SELECT amount FROM categories AS catg
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS empl
    WHERE empl.level = catg.level
);


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

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


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

SELECT name FROM regions AS rgn
WHERE value > (
    SELECT MIN(amount) FROM tasks AS lne
    WHERE lne.type = rgn.type
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM items AS dept
    WHERE dept.id = shp.id
);


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

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


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

SELECT value FROM invoices AS inv
WHERE level IN (
    SELECT level FROM regions AS ordr
    WHERE ordr.status = inv.status
);


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

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


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

SELECT name FROM orders AS ord
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS sale
    WHERE sale.level = ord.level
);


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

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


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

SELECT value FROM categories AS catg
WHERE amount > (
    SELECT AVG(value) FROM regions AS brc
    WHERE brc.id = catg.id
);


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

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


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

SELECT code FROM transactions AS txn
WHERE amount > (
    SELECT MIN(amount) FROM schedules AS prod
    WHERE prod.code = txn.code
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.id = catg.id
);


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

SELECT salary FROM categories AS catg
WHERE code IN (
    SELECT code FROM schedules AS ord
    WHERE ord.type = catg.type
);


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

SELECT value FROM transactions AS txn
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS catg
    WHERE catg.id = txn.id
);


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

SELECT salary FROM items AS lne
WHERE value > (
    SELECT COUNT(value) FROM customers AS acct
    WHERE acct.status = lne.status
);


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

SELECT salary FROM projects AS prj
WHERE level IN (
    SELECT level FROM accounts AS dept
    WHERE dept.status = prj.status
);


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

SELECT value FROM staff AS empl
WHERE status IN (
    SELECT status FROM accounts AS mgr
    WHERE mgr.status = empl.status
);


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

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


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

SELECT code FROM transactions AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM requests AS ord
    WHERE ord.code = txn.code
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.level = ordr.level
);


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

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


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

SELECT salary FROM accounts AS acct
WHERE level IN (
    SELECT level FROM regions AS lne
    WHERE lne.level = acct.level
);


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

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


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.code = empl.code
);


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

SELECT code FROM products AS prod
WHERE type IN (
    SELECT type FROM tasks AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = lne.level
);


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

SELECT id FROM sales AS sale
WHERE type IN (
    SELECT type FROM tasks AS ord
    WHERE ord.level = sale.level
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM branches AS tsk
    WHERE tsk.id = prj.id
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.status = rgn.status
);


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

SELECT id FROM staff AS empl
WHERE salary > (
    SELECT AVG(value) FROM requests AS sale
    WHERE sale.level = empl.level
);


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

SELECT value FROM staff AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS tsk
    WHERE tsk.level = empl.level
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.id = prj.id
);


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

SELECT salary FROM customers AS cust
WHERE code IN (
    SELECT code FROM orders AS catg
    WHERE catg.code = cust.code
);


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

SELECT id FROM items AS lne
WHERE level IN (
    SELECT level FROM managers AS prj
    WHERE prj.id = lne.id
);


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

SELECT code FROM departments AS dept
WHERE value > (
    SELECT SUM(value) FROM products AS ordr
    WHERE ordr.code = dept.code
);


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

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


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

SELECT id FROM sales AS sale
WHERE amount > (
    SELECT COUNT(value) FROM projects AS schd
    WHERE schd.level = sale.level
);


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

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


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

SELECT value FROM products AS prod
WHERE level IN (
    SELECT level FROM customers AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.id = emp.id
);


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

SELECT value FROM sales AS sale
WHERE amount > (
    SELECT AVG(value) FROM orders AS tsk
    WHERE tsk.type = sale.type
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE salary > (
    SELECT SUM(amount) FROM items AS emp
    WHERE emp.code = txn.code
);


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

SELECT value FROM employees AS emp
WHERE code IN (
    SELECT code FROM invoices AS prod
    WHERE prod.type = emp.type
);


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

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


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

SELECT salary FROM departments AS dept
WHERE level IN (
    SELECT level FROM schedules AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT id FROM invoices AS inv
WHERE type IN (
    SELECT type FROM customers AS emp
    WHERE emp.code = inv.code
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM schedules AS empl
    WHERE empl.id = inv.id
);


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

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


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

SELECT value FROM invoices AS inv
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS sale
    WHERE sale.code = inv.code
);


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

SELECT amount FROM schedules AS schd
WHERE amount > (
    SELECT MIN(value) FROM employees AS schd
    WHERE schd.code = schd.code
);


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

SELECT code FROM items AS lne
WHERE salary > (
    SELECT SUM(salary) FROM products AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT value FROM shipments AS shp
WHERE code IN (
    SELECT code FROM employees AS prj
    WHERE prj.level = shp.level
);


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

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


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

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


Prompt:
Schema:
  sales (alias: sale)(amount, code, date, id)
  employees(amount, name, id, code)
Task: Find id from sales where salary exceeds the total salary from employees for the same id.
SQL:

SELECT id FROM sales AS sale
WHERE salary > (
    SELECT SUM(salary) FROM employees AS tsk
    WHERE tsk.id = sale.id
);


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

SELECT name FROM customers AS cust
WHERE code IN (
    SELECT code FROM items AS dept
    WHERE dept.level = cust.level
);


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

SELECT code FROM staff AS empl
WHERE amount > (
    SELECT AVG(amount) FROM customers AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.code = sale.code
);


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

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


Prompt:
Schema:
  requests (alias: ordr)(status, type, date, value)
  projects(level, status, date, amount)
Task: Retrieve amount from requests with salary above the MAX(value) of projects rows sharing the same status.
SQL:

SELECT amount FROM requests AS ordr
WHERE salary > (
    SELECT MAX(value) FROM projects AS ord
    WHERE ord.status = ordr.status
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.type = empl.type
);


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

SELECT name FROM invoices AS inv
WHERE salary > (
    SELECT SUM(salary) FROM projects AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT id FROM departments AS dept
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT name FROM projects AS prj
WHERE id IN (
    SELECT id FROM customers AS sale
    WHERE sale.level = prj.level
);


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

SELECT id FROM regions AS rgn
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.level = rgn.level
);


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

SELECT value FROM products AS prod
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS txn
    WHERE txn.level = prod.level
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.type = tsk.type
);


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

SELECT name FROM invoices AS inv
WHERE amount > (
    SELECT AVG(value) FROM requests AS prod
    WHERE prod.level = inv.level
);


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

SELECT salary FROM sales AS sale
WHERE salary > (
    SELECT MAX(value) FROM invoices AS dept
    WHERE dept.level = sale.level
);


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

SELECT value FROM products AS prod
WHERE level IN (
    SELECT level FROM orders AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.type = catg.type
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT salary FROM transactions AS txn
WHERE type IN (
    SELECT type FROM items AS empl
    WHERE empl.type = txn.type
);


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

SELECT salary FROM requests AS ordr
WHERE value > (
    SELECT SUM(amount) FROM items AS empl
    WHERE empl.id = ordr.id
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.status = cust.status
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT AVG(value) FROM managers AS cust
    WHERE cust.level = txn.level
);


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

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


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.code = prj.code
);


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

SELECT name FROM projects AS prj
WHERE id IN (
    SELECT id FROM transactions AS sale
    WHERE sale.type = prj.type
);


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

SELECT salary FROM schedules AS schd
WHERE type IN (
    SELECT type FROM accounts AS brc
    WHERE brc.level = schd.level
);


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

SELECT amount FROM orders AS ord
WHERE salary > (
    SELECT MAX(amount) FROM branches AS prj
    WHERE prj.level = ord.level
);


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

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


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

SELECT code FROM schedules AS schd
WHERE code IN (
    SELECT code FROM branches AS sale
    WHERE sale.status = schd.status
);


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

SELECT code FROM categories AS catg
WHERE id IN (
    SELECT id FROM managers AS cust
    WHERE cust.level = catg.level
);


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

SELECT salary FROM invoices AS inv
WHERE status IN (
    SELECT status FROM requests AS ord
    WHERE ord.id = inv.id
);


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT AVG(value) FROM items AS shp
    WHERE shp.id = catg.id
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.code = dept.code
);


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

SELECT amount FROM managers AS mgr
WHERE type IN (
    SELECT type FROM projects AS schd
    WHERE schd.status = mgr.status
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.type = prj.type
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM sales AS cust
    WHERE cust.code = ordr.code
);


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

SELECT salary FROM transactions AS txn
WHERE value > (
    SELECT MIN(amount) FROM accounts AS prj
    WHERE prj.id = txn.id
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT code FROM accounts AS acct
WHERE level IN (
    SELECT level FROM orders AS txn
    WHERE txn.type = acct.type
);


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

SELECT name FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM staff AS cust
    WHERE cust.type = mgr.type
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE status IN (
    SELECT status FROM invoices AS schd
    WHERE schd.status = txn.status
);


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

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


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

SELECT salary FROM departments AS dept
WHERE level IN (
    SELECT level FROM regions AS ord
    WHERE ord.code = dept.code
);


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

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


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

SELECT id FROM orders AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS catg
    WHERE catg.code = ord.code
);


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

SELECT amount FROM departments AS dept
WHERE type IN (
    SELECT type FROM staff AS mgr
    WHERE mgr.code = dept.code
);


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

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


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

SELECT name FROM accounts AS acct
WHERE code IN (
    SELECT code FROM departments AS ord
    WHERE ord.id = acct.id
);


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

SELECT amount FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM schedules AS prod
    WHERE prod.type = tsk.type
);


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

SELECT salary FROM items AS lne
WHERE salary > (
    SELECT MIN(salary) FROM staff AS prod
    WHERE prod.id = lne.id
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM items AS prod
    WHERE prod.level = tsk.level
);


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

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


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

SELECT id FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.type = lne.type
);


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

SELECT amount FROM projects AS prj
WHERE code IN (
    SELECT code FROM categories AS dept
    WHERE dept.status = prj.status
);


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

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


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT COUNT(salary) FROM items AS inv
    WHERE inv.status = emp.status
);


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

SELECT amount FROM orders AS ord
WHERE type IN (
    SELECT type FROM accounts AS mgr
    WHERE mgr.type = ord.type
);


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

SELECT name FROM customers AS cust
WHERE amount > (
    SELECT AVG(amount) FROM sales AS sale
    WHERE sale.id = cust.id
);


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

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


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

SELECT name FROM requests AS ordr
WHERE level IN (
    SELECT level FROM products AS sale
    WHERE sale.code = ordr.code
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT COUNT(amount) FROM branches AS prj
    WHERE prj.code = txn.code
);


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

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


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

SELECT salary FROM staff AS empl
WHERE salary > (
    SELECT COUNT(value) FROM managers AS tsk
    WHERE tsk.type = empl.type
);


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

SELECT code FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.type = brc.type
);


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

SELECT id FROM items AS lne
WHERE value > (
    SELECT MAX(amount) FROM staff AS prj
    WHERE prj.type = lne.type
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.level = acct.level
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM schedules AS ordr
    WHERE ordr.status = brc.status
);


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

SELECT amount FROM staff AS empl
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.level = empl.level
);


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

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


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

SELECT salary FROM projects AS prj
WHERE type IN (
    SELECT type FROM customers AS acct
    WHERE acct.status = prj.status
);


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

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


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

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


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

SELECT code FROM staff AS empl
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS inv
    WHERE inv.id = empl.id
);


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

SELECT name FROM categories AS catg
WHERE value > (
    SELECT MIN(value) FROM customers AS emp
    WHERE emp.code = catg.code
);


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

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


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

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


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

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


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

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


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

SELECT name FROM schedules AS schd
WHERE value > (
    SELECT AVG(value) FROM projects AS txn
    WHERE txn.level = schd.level
);


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.level = prod.level
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM orders AS txn
    WHERE txn.level = tsk.level
);


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

SELECT salary FROM products AS prod
WHERE id IN (
    SELECT id FROM managers AS prj
    WHERE prj.code = prod.code
);


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

SELECT code FROM requests AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM tasks AS empl
    WHERE empl.status = ordr.status
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.code = brc.code
);


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = empl.level
);


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

SELECT salary FROM projects AS prj
WHERE amount > (
    SELECT MIN(salary) FROM staff AS empl
    WHERE empl.status = prj.status
);


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

SELECT amount FROM orders AS ord
WHERE type IN (
    SELECT type FROM invoices AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT name FROM items AS lne
WHERE amount > (
    SELECT MIN(value) FROM requests AS emp
    WHERE emp.level = lne.level
);


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

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


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

SELECT id FROM requests AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM items AS prod
    WHERE prod.code = ordr.code
);


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

SELECT id FROM orders AS ord
WHERE value > (
    SELECT AVG(salary) FROM tasks AS prj
    WHERE prj.level = ord.level
);


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

SELECT value FROM orders AS ord
WHERE value > (
    SELECT COUNT(amount) FROM regions AS sale
    WHERE sale.type = ord.type
);


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

SELECT amount FROM branches AS brc
WHERE amount > (
    SELECT AVG(value) FROM orders AS cust
    WHERE cust.status = brc.status
);


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

SELECT value FROM orders AS ord
WHERE id IN (
    SELECT id FROM items AS empl
    WHERE empl.status = ord.status
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.id = schd.id
);


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

SELECT salary FROM branches AS brc
WHERE code IN (
    SELECT code FROM staff AS txn
    WHERE txn.level = brc.level
);


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

SELECT amount FROM categories AS catg
WHERE amount > (
    SELECT MAX(value) FROM tasks AS ord
    WHERE ord.level = catg.level
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.status = cust.status
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT id FROM categories AS catg
WHERE level IN (
    SELECT level FROM managers AS emp
    WHERE emp.code = catg.code
);


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

SELECT salary FROM sales AS sale
WHERE amount > (
    SELECT MAX(amount) FROM orders AS inv
    WHERE inv.status = sale.status
);


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

SELECT amount FROM schedules AS schd
WHERE type IN (
    SELECT type FROM customers AS tsk
    WHERE tsk.code = schd.code
);


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

SELECT name FROM sales AS sale
WHERE type IN (
    SELECT type FROM projects AS ordr
    WHERE ordr.id = sale.id
);


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

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


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

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


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

SELECT amount FROM shipments AS shp
WHERE level IN (
    SELECT level FROM departments AS shp
    WHERE shp.type = shp.type
);


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

SELECT salary FROM transactions AS txn
WHERE type IN (
    SELECT type FROM shipments AS tsk
    WHERE tsk.level = txn.level
);


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

SELECT amount FROM branches AS brc
WHERE value > (
    SELECT AVG(value) FROM shipments AS prod
    WHERE prod.id = brc.id
);


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

SELECT value FROM invoices AS inv
WHERE type IN (
    SELECT type FROM managers AS acct
    WHERE acct.type = inv.type
);


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

SELECT amount FROM accounts AS acct
WHERE code IN (
    SELECT code FROM orders AS prj
    WHERE prj.type = acct.type
);


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

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


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

SELECT name FROM schedules AS schd
WHERE salary > (
    SELECT MAX(amount) FROM orders AS prod
    WHERE prod.id = schd.id
);


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

SELECT amount FROM regions AS rgn
WHERE status IN (
    SELECT status FROM schedules AS ord
    WHERE ord.id = rgn.id
);


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

SELECT amount FROM schedules AS schd
WHERE level IN (
    SELECT level FROM managers AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT name FROM projects AS prj
WHERE status IN (
    SELECT status FROM staff AS dept
    WHERE dept.type = prj.type
);


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

SELECT amount FROM accounts AS acct
WHERE id IN (
    SELECT id FROM employees AS shp
    WHERE shp.level = acct.level
);


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

SELECT amount FROM shipments AS shp
WHERE code IN (
    SELECT code FROM managers AS dept
    WHERE dept.status = shp.status
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.type = catg.type
);


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

SELECT name FROM accounts AS acct
WHERE id IN (
    SELECT id FROM departments AS emp
    WHERE emp.id = acct.id
);


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

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


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.code = prj.code
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM requests AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT salary FROM projects AS prj
WHERE id IN (
    SELECT id FROM items AS empl
    WHERE empl.status = prj.status
);


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM sales AS acct
    WHERE acct.code = ord.code
);


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

SELECT code FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.type = prj.type
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM sales AS schd
    WHERE schd.type = acct.type
);


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

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


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

SELECT name FROM items AS lne
WHERE id IN (
    SELECT id FROM invoices AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM staff AS emp
    WHERE emp.code = catg.code
);


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

SELECT id FROM transactions AS txn
WHERE salary > (
    SELECT MAX(value) FROM staff AS prj
    WHERE prj.level = txn.level
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.level = emp.level
);


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

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


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

SELECT code FROM shipments AS shp
WHERE value > (
    SELECT MIN(salary) FROM staff AS txn
    WHERE txn.level = shp.level
);


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

SELECT name FROM requests AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS prj
    WHERE prj.code = ordr.code
);


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

SELECT id FROM accounts AS acct
WHERE type IN (
    SELECT type FROM schedules AS brc
    WHERE brc.status = acct.status
);


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

SELECT name FROM tasks AS tsk
WHERE salary > (
    SELECT AVG(amount) FROM employees AS lne
    WHERE lne.level = tsk.level
);


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

SELECT code FROM branches AS brc
WHERE amount > (
    SELECT AVG(amount) FROM orders AS ordr
    WHERE ordr.level = brc.level
);


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

SELECT salary FROM transactions AS txn
WHERE status IN (
    SELECT status FROM projects AS emp
    WHERE emp.code = txn.code
);


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

SELECT name FROM branches AS brc
WHERE type IN (
    SELECT type FROM managers AS dept
    WHERE dept.level = brc.level
);


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

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


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM staff AS shp
    WHERE shp.level = dept.level
);


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT COUNT(amount) FROM categories AS catg
    WHERE catg.level = cust.level
);


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS prj
    WHERE prj.level = txn.level
);


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

SELECT code FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.type = brc.type
);


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

SELECT name FROM requests AS ordr
WHERE value > (
    SELECT AVG(salary) FROM sales AS schd
    WHERE schd.status = ordr.status
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM schedules AS brc
    WHERE brc.id = lne.id
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.code = ord.code
);


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

SELECT amount FROM transactions AS txn
WHERE code IN (
    SELECT code FROM schedules AS schd
    WHERE schd.status = txn.status
);


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

SELECT salary FROM invoices AS inv
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.code = inv.code
);


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

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS ordr
    WHERE ordr.type = emp.type
);


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

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT id FROM projects AS prj
WHERE salary > (
    SELECT MAX(salary) FROM customers AS inv
    WHERE inv.id = prj.id
);


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

SELECT name FROM accounts AS acct
WHERE level IN (
    SELECT level FROM employees AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT value FROM orders AS ord
WHERE id IN (
    SELECT id FROM categories AS cust
    WHERE cust.level = ord.level
);


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

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


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

SELECT id FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = brc.level
);


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

SELECT amount FROM invoices AS inv
WHERE value > (
    SELECT MIN(salary) FROM projects AS sale
    WHERE sale.type = inv.type
);


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

SELECT id FROM shipments AS shp
WHERE value > (
    SELECT MAX(salary) FROM accounts AS brc
    WHERE brc.id = shp.id
);


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

SELECT id FROM orders AS ord
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS brc
    WHERE brc.code = ord.code
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM staff AS acct
    WHERE acct.level = emp.level
);


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

SELECT id FROM branches AS brc
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS acct
    WHERE acct.id = brc.id
);


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

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


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

SELECT code FROM staff AS empl
WHERE amount > (
    SELECT AVG(salary) FROM items AS dept
    WHERE dept.type = empl.type
);


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

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


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

SELECT salary FROM categories AS catg
WHERE id IN (
    SELECT id FROM schedules AS shp
    WHERE shp.code = catg.code
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS prj
    WHERE prj.type = empl.type
);


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

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


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

SELECT code FROM accounts AS acct
WHERE status IN (
    SELECT status FROM requests AS dept
    WHERE dept.status = acct.status
);


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

SELECT amount FROM orders AS ord
WHERE value > (
    SELECT COUNT(value) FROM employees AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM managers AS txn
    WHERE txn.level = dept.level
);


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

SELECT code FROM categories AS catg
WHERE salary > (
    SELECT SUM(amount) FROM regions AS schd
    WHERE schd.type = catg.type
);


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

SELECT id FROM managers AS mgr
WHERE value > (
    SELECT MAX(salary) FROM invoices AS prod
    WHERE prod.code = mgr.code
);


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

SELECT id FROM sales AS sale
WHERE value > (
    SELECT SUM(amount) FROM customers AS acct
    WHERE acct.id = sale.id
);


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

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


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

SELECT id FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM projects AS tsk
    WHERE tsk.code = brc.code
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM schedules AS catg
    WHERE catg.code = prod.code
);


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

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


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

SELECT amount FROM regions AS rgn
WHERE level IN (
    SELECT level FROM transactions AS dept
    WHERE dept.id = rgn.id
);


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

SELECT code FROM invoices AS inv
WHERE id IN (
    SELECT id FROM departments AS catg
    WHERE catg.status = inv.status
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.level = sale.level
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.level = lne.level
);


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

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


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

SELECT value FROM shipments AS shp
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS prod
    WHERE prod.level = shp.level
);


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

SELECT salary FROM branches AS brc
WHERE type IN (
    SELECT type FROM employees AS tsk
    WHERE tsk.level = brc.level
);


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

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


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.type = emp.type
);


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

SELECT value FROM sales AS sale
WHERE status IN (
    SELECT status FROM requests AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM managers AS prod
    WHERE prod.code = catg.code
);


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

SELECT id FROM branches AS brc
WHERE amount > (
    SELECT MAX(salary) FROM staff AS cust
    WHERE cust.type = brc.type
);


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

SELECT salary FROM projects AS prj
WHERE type IN (
    SELECT type FROM shipments AS ordr
    WHERE ordr.type = prj.type
);


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

SELECT name FROM managers AS mgr
WHERE salary > (
    SELECT MAX(amount) FROM schedules AS txn
    WHERE txn.type = mgr.type
);


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

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


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

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


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

SELECT name FROM customers AS cust
WHERE value > (
    SELECT AVG(value) FROM staff AS inv
    WHERE inv.code = cust.code
);


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

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


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

SELECT id FROM accounts AS acct
WHERE status IN (
    SELECT status FROM categories AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT salary FROM departments AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT name FROM employees AS emp
WHERE code IN (
    SELECT code FROM items AS ord
    WHERE ord.type = emp.type
);


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

SELECT name FROM schedules AS schd
WHERE salary > (
    SELECT MIN(amount) FROM managers AS prod
    WHERE prod.level = schd.level
);


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

SELECT id FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM sales AS cust
    WHERE cust.id = lne.id
);