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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.status = shp.status
);


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

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


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = inv.status
);


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

SELECT name FROM employees AS emp
WHERE salary > (
    SELECT MIN(value) FROM tasks AS ord
    WHERE ord.id = emp.id
);


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM requests AS tsk
    WHERE tsk.type = mgr.type
);


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

SELECT salary FROM orders AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS inv
    WHERE inv.code = ord.code
);


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

SELECT name FROM schedules AS schd
WHERE salary > (
    SELECT MIN(salary) FROM customers AS txn
    WHERE txn.id = schd.id
);


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

SELECT id FROM managers AS mgr
WHERE level IN (
    SELECT level FROM regions AS lne
    WHERE lne.level = mgr.level
);


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM shipments AS prj
    WHERE prj.code = ord.code
);


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

SELECT name FROM sales AS sale
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM staff AS tsk
    WHERE tsk.id = ord.id
);


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

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


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

SELECT amount FROM managers AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM schedules AS catg
    WHERE catg.type = mgr.type
);


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

SELECT code FROM accounts AS acct
WHERE code IN (
    SELECT code FROM products AS cust
    WHERE cust.status = acct.status
);


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

SELECT value FROM shipments AS shp
WHERE id IN (
    SELECT id FROM transactions AS inv
    WHERE inv.id = shp.id
);


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

SELECT code FROM sales AS sale
WHERE value > (
    SELECT MAX(salary) FROM regions AS acct
    WHERE acct.level = sale.level
);


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM sales AS ordr
    WHERE ordr.id = prod.id
);


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

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


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

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


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

SELECT id FROM projects AS prj
WHERE salary > (
    SELECT MAX(amount) FROM tasks AS empl
    WHERE empl.level = prj.level
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.id = emp.id
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.level = dept.level
);


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

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


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

SELECT salary FROM accounts AS acct
WHERE status IN (
    SELECT status FROM orders AS empl
    WHERE empl.level = acct.level
);


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

SELECT value FROM requests AS ordr
WHERE status IN (
    SELECT status FROM schedules AS prod
    WHERE prod.id = ordr.id
);


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

SELECT amount FROM shipments AS shp
WHERE value > (
    SELECT AVG(amount) FROM schedules AS tsk
    WHERE tsk.code = shp.code
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.status = tsk.status
);


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT MIN(salary) FROM branches AS sale
    WHERE sale.level = catg.level
);


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

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


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS tsk
    WHERE tsk.id = inv.id
);


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

SELECT amount FROM items AS lne
WHERE salary > (
    SELECT MIN(value) FROM staff AS ordr
    WHERE ordr.type = lne.type
);


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

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


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

SELECT name FROM invoices AS inv
WHERE value > (
    SELECT MAX(salary) FROM schedules AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM items AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT salary FROM transactions AS txn
WHERE value > (
    SELECT COUNT(value) FROM categories AS ordr
    WHERE ordr.type = txn.type
);


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

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


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

SELECT salary FROM projects AS prj
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS txn
    WHERE txn.status = prj.status
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.level = tsk.level
);


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

SELECT id FROM requests AS ordr
WHERE level IN (
    SELECT level FROM transactions AS empl
    WHERE empl.status = ordr.status
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT salary FROM regions AS rgn
WHERE level IN (
    SELECT level FROM shipments AS emp
    WHERE emp.id = rgn.id
);


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

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


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

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


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

SELECT id FROM staff AS empl
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS dept
    WHERE dept.type = empl.type
);


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

SELECT amount FROM managers AS mgr
WHERE value > (
    SELECT AVG(amount) FROM tasks AS schd
    WHERE schd.id = mgr.id
);


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

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


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

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS tsk
    WHERE tsk.type = ord.type
);


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

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


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

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


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

SELECT salary FROM schedules AS schd
WHERE amount > (
    SELECT SUM(salary) FROM employees AS sale
    WHERE sale.id = schd.id
);


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT MIN(value) FROM regions AS prj
    WHERE prj.status = cust.status
);


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

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


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.type = rgn.type
);


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

SELECT salary FROM categories AS catg
WHERE id IN (
    SELECT id FROM tasks AS catg
    WHERE catg.type = catg.type
);


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

SELECT name FROM schedules AS schd
WHERE value > (
    SELECT SUM(value) FROM requests AS shp
    WHERE shp.id = schd.id
);


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

SELECT value FROM items AS lne
WHERE level IN (
    SELECT level FROM departments AS ord
    WHERE ord.id = lne.id
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM schedules AS cust
    WHERE cust.status = rgn.status
);


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

SELECT value FROM requests AS ordr
WHERE status IN (
    SELECT status FROM transactions AS prod
    WHERE prod.status = ordr.status
);


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

SELECT id FROM products AS prod
WHERE status IN (
    SELECT status FROM customers AS brc
    WHERE brc.type = prod.type
);


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

SELECT code FROM employees AS emp
WHERE salary > (
    SELECT COUNT(value) FROM staff AS empl
    WHERE empl.type = emp.type
);


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

SELECT amount FROM items AS lne
WHERE status IN (
    SELECT status FROM projects AS sale
    WHERE sale.status = lne.status
);


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS brc
    WHERE brc.code = empl.code
);


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

SELECT name FROM employees AS emp
WHERE type IN (
    SELECT type FROM sales AS txn
    WHERE txn.level = emp.level
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(salary) FROM projects AS brc
    WHERE brc.level = tsk.level
);


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

SELECT amount FROM accounts AS acct
WHERE type IN (
    SELECT type FROM projects AS cust
    WHERE cust.type = acct.type
);


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM managers AS emp
    WHERE emp.type = ord.type
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM managers AS sale
    WHERE sale.type = acct.type
);


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

SELECT code FROM employees AS emp
WHERE status IN (
    SELECT status FROM regions AS ord
    WHERE ord.status = emp.status
);


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

SELECT salary FROM categories AS catg
WHERE id IN (
    SELECT id FROM employees AS inv
    WHERE inv.code = catg.code
);


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

SELECT salary FROM projects AS prj
WHERE salary > (
    SELECT COUNT(value) FROM customers AS emp
    WHERE emp.level = prj.level
);


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

SELECT amount FROM items AS lne
WHERE type IN (
    SELECT type FROM departments AS brc
    WHERE brc.type = lne.type
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM schedules AS prj
    WHERE prj.status = rgn.status
);


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS brc
    WHERE brc.status = emp.status
);


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

SELECT code FROM requests AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM sales AS tsk
    WHERE tsk.level = ordr.level
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.type = txn.type
);


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

SELECT code FROM items AS lne
WHERE level IN (
    SELECT level FROM projects AS prod
    WHERE prod.code = lne.code
);


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

SELECT id FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.type = brc.type
);


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

SELECT id FROM shipments AS shp
WHERE salary > (
    SELECT AVG(salary) FROM customers AS ordr
    WHERE ordr.code = shp.code
);


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

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


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

SELECT value FROM staff AS empl
WHERE salary > (
    SELECT MIN(salary) FROM customers AS tsk
    WHERE tsk.code = empl.code
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.level = catg.level
);


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

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


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

SELECT salary FROM branches AS brc
WHERE id IN (
    SELECT id FROM staff AS acct
    WHERE acct.id = brc.id
);


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

SELECT salary FROM schedules AS schd
WHERE code IN (
    SELECT code FROM categories AS ord
    WHERE ord.level = schd.level
);


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

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


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

SELECT value FROM categories AS catg
WHERE value > (
    SELECT AVG(value) FROM accounts AS emp
    WHERE emp.level = catg.level
);


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

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


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

SELECT id FROM transactions AS txn
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS ord
    WHERE ord.type = txn.type
);


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

SELECT name FROM requests AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM transactions AS shp
    WHERE shp.code = ordr.code
);


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

SELECT amount FROM managers AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM departments AS lne
    WHERE lne.level = mgr.level
);


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

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


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

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


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.level = catg.level
);


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

SELECT salary FROM projects AS prj
WHERE code IN (
    SELECT code FROM staff AS empl
    WHERE empl.type = prj.type
);


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

SELECT value FROM products AS prod
WHERE type IN (
    SELECT type FROM schedules AS prj
    WHERE prj.type = prod.type
);


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

SELECT salary FROM tasks AS tsk
WHERE salary > (
    SELECT AVG(amount) FROM regions AS sale
    WHERE sale.status = tsk.status
);


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

SELECT salary FROM shipments AS shp
WHERE salary > (
    SELECT SUM(salary) FROM staff AS brc
    WHERE brc.status = shp.status
);


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

SELECT code FROM projects AS prj
WHERE salary > (
    SELECT MAX(amount) FROM departments AS catg
    WHERE catg.level = prj.level
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.level = shp.level
);


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

SELECT amount FROM schedules AS schd
WHERE status IN (
    SELECT status FROM sales AS prj
    WHERE prj.level = schd.level
);


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

SELECT value FROM branches AS brc
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.status = brc.status
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.type = empl.type
);


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

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


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM requests AS empl
    WHERE empl.level = lne.level
);


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

SELECT amount FROM departments AS dept
WHERE id IN (
    SELECT id FROM sales AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM schedules AS inv
    WHERE inv.type = empl.type
);


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

SELECT name FROM shipments AS shp
WHERE value > (
    SELECT MIN(salary) FROM requests AS lne
    WHERE lne.level = shp.level
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.id = txn.id
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.level = dept.level
);


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

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


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

SELECT code FROM sales AS sale
WHERE code IN (
    SELECT code FROM employees AS prod
    WHERE prod.type = sale.type
);


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

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


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

SELECT value FROM departments AS dept
WHERE level IN (
    SELECT level FROM managers AS tsk
    WHERE tsk.id = dept.id
);


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

SELECT name FROM staff AS empl
WHERE id IN (
    SELECT id FROM branches AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT amount FROM orders AS ord
WHERE status IN (
    SELECT status FROM projects AS acct
    WHERE acct.id = ord.id
);


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

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


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

SELECT id FROM products AS prod
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.id = prod.id
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.level = tsk.level
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.code = dept.code
);


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

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


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

SELECT amount FROM orders AS ord
WHERE value > (
    SELECT MIN(salary) FROM shipments AS ord
    WHERE ord.code = ord.code
);


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.status = prod.status
);


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

SELECT id FROM sales AS sale
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS empl
    WHERE empl.id = sale.id
);


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT AVG(salary) FROM projects AS dept
    WHERE dept.level = emp.level
);


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

SELECT id FROM customers AS cust
WHERE salary > (
    SELECT SUM(amount) FROM products AS mgr
    WHERE mgr.code = cust.code
);


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

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


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

SELECT salary FROM products AS prod
WHERE value > (
    SELECT MAX(salary) FROM managers AS lne
    WHERE lne.code = prod.code
);


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

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


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM sales AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT SUM(salary) FROM staff AS cust
    WHERE cust.code = catg.code
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS brc
    WHERE brc.code = shp.code
);


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

SELECT name FROM projects AS prj
WHERE status IN (
    SELECT status FROM products AS txn
    WHERE txn.level = prj.level
);


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

SELECT amount FROM accounts AS acct
WHERE salary > (
    SELECT MIN(value) FROM categories AS tsk
    WHERE tsk.status = acct.status
);


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

SELECT value FROM branches AS brc
WHERE id IN (
    SELECT id FROM transactions AS mgr
    WHERE mgr.status = brc.status
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM sales AS acct
    WHERE acct.id = shp.id
);


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

SELECT id FROM items AS lne
WHERE salary > (
    SELECT SUM(salary) FROM branches AS empl
    WHERE empl.id = lne.id
);


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

SELECT amount FROM customers AS cust
WHERE id IN (
    SELECT id FROM shipments AS tsk
    WHERE tsk.level = cust.level
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.type = cust.type
);


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

SELECT amount FROM sales AS sale
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.type = sale.type
);


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

SELECT id FROM transactions AS txn
WHERE status IN (
    SELECT status FROM projects AS txn
    WHERE txn.id = txn.id
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = ord.status
);


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

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


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

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


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

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


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

SELECT value FROM customers AS cust
WHERE level IN (
    SELECT level FROM projects AS tsk
    WHERE tsk.code = cust.code
);


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = ordr.level
);


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

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


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

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


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

SELECT salary FROM invoices AS inv
WHERE salary > (
    SELECT MAX(salary) FROM employees AS emp
    WHERE emp.code = inv.code
);


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

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


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM staff AS sale
    WHERE sale.type = brc.type
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS brc
    WHERE brc.status = txn.status
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.status = mgr.status
);


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

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


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

SELECT name FROM items AS lne
WHERE id IN (
    SELECT id FROM projects AS shp
    WHERE shp.id = lne.id
);


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

SELECT amount FROM requests AS ordr
WHERE id IN (
    SELECT id FROM transactions AS tsk
    WHERE tsk.code = ordr.code
);


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

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


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

SELECT id FROM accounts AS acct
WHERE amount > (
    SELECT AVG(salary) FROM projects AS brc
    WHERE brc.type = acct.type
);


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

SELECT salary FROM managers AS mgr
WHERE type IN (
    SELECT type FROM customers AS catg
    WHERE catg.code = mgr.code
);


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

SELECT salary FROM staff AS empl
WHERE value > (
    SELECT MAX(value) FROM customers AS empl
    WHERE empl.level = empl.level
);


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

SELECT id FROM schedules AS schd
WHERE code IN (
    SELECT code FROM accounts AS tsk
    WHERE tsk.id = schd.id
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT salary FROM staff AS empl
WHERE salary > (
    SELECT MIN(salary) FROM projects AS dept
    WHERE dept.level = empl.level
);


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

SELECT salary FROM projects AS prj
WHERE id IN (
    SELECT id FROM requests AS dept
    WHERE dept.code = prj.code
);


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

SELECT amount FROM requests AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM items AS acct
    WHERE acct.code = ordr.code
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT name FROM orders AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS ord
    WHERE ord.type = ord.type
);


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

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


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

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


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

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


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

SELECT id FROM staff AS empl
WHERE amount > (
    SELECT MAX(amount) FROM departments AS schd
    WHERE schd.id = empl.id
);


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

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


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

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


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

SELECT salary FROM requests AS ordr
WHERE value > (
    SELECT MAX(salary) FROM items AS shp
    WHERE shp.status = ordr.status
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.level = ord.level
);


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

SELECT salary FROM items AS lne
WHERE value > (
    SELECT MAX(salary) FROM staff AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.type = ord.type
);


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

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


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.code = prj.code
);


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

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


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

SELECT code FROM customers AS cust
WHERE type IN (
    SELECT type FROM schedules AS empl
    WHERE empl.type = cust.type
);


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT AVG(salary) FROM items AS cust
    WHERE cust.id = emp.id
);


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

SELECT amount FROM invoices AS inv
WHERE code IN (
    SELECT code FROM transactions AS tsk
    WHERE tsk.type = inv.type
);


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

SELECT name FROM managers AS mgr
WHERE amount > (
    SELECT MIN(value) FROM projects AS ordr
    WHERE ordr.type = mgr.type
);


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

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


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

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


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

SELECT salary FROM requests AS ordr
WHERE id IN (
    SELECT id FROM transactions AS brc
    WHERE brc.level = ordr.level
);


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

SELECT id FROM projects AS prj
WHERE type IN (
    SELECT type FROM departments AS tsk
    WHERE tsk.id = prj.id
);


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

SELECT salary FROM schedules AS schd
WHERE value > (
    SELECT MAX(value) FROM shipments AS brc
    WHERE brc.level = schd.level
);


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

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


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

SELECT value FROM products AS prod
WHERE status IN (
    SELECT status FROM tasks AS prj
    WHERE prj.type = prod.type
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM managers AS cust
    WHERE cust.level = empl.level
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.id = cust.id
);


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

SELECT salary FROM departments AS dept
WHERE amount > (
    SELECT SUM(salary) FROM orders AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.code = empl.code
);


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

SELECT code FROM schedules AS schd
WHERE status IN (
    SELECT status FROM invoices AS lne
    WHERE lne.status = schd.status
);


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

SELECT value FROM accounts AS acct
WHERE code IN (
    SELECT code FROM categories AS ord
    WHERE ord.level = acct.level
);


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

SELECT name FROM categories AS catg
WHERE value > (
    SELECT MAX(salary) FROM invoices AS emp
    WHERE emp.id = catg.id
);


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

SELECT id FROM items AS lne
WHERE code IN (
    SELECT code FROM regions AS tsk
    WHERE tsk.code = lne.code
);


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

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


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

SELECT amount FROM requests AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM products AS sale
    WHERE sale.level = ordr.level
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.code = txn.code
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.type = cust.type
);


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

SELECT name FROM sales AS sale
WHERE salary > (
    SELECT MAX(salary) FROM products AS ord
    WHERE ord.status = sale.status
);


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

SELECT name FROM managers AS mgr
WHERE status IN (
    SELECT status FROM branches AS inv
    WHERE inv.id = mgr.id
);


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

SELECT salary FROM tasks AS tsk
WHERE value > (
    SELECT MAX(amount) FROM projects AS schd
    WHERE schd.level = tsk.level
);


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

SELECT amount FROM categories AS catg
WHERE amount > (
    SELECT MAX(value) FROM sales AS shp
    WHERE shp.id = catg.id
);


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

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


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

SELECT id FROM transactions AS txn
WHERE amount > (
    SELECT MIN(value) FROM managers AS lne
    WHERE lne.status = txn.status
);


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

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


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

SELECT id FROM accounts AS acct
WHERE type IN (
    SELECT type FROM projects AS catg
    WHERE catg.type = acct.type
);


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

SELECT amount FROM branches AS brc
WHERE salary > (
    SELECT SUM(value) FROM managers AS emp
    WHERE emp.level = brc.level
);


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

SELECT amount FROM requests AS ordr
WHERE level IN (
    SELECT level FROM accounts AS schd
    WHERE schd.status = ordr.status
);


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

SELECT amount FROM staff AS empl
WHERE type IN (
    SELECT type FROM tasks AS cust
    WHERE cust.level = empl.level
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM items AS empl
    WHERE empl.status = dept.status
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE value > (
    SELECT COUNT(amount) FROM products AS prod
    WHERE prod.type = mgr.type
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.id = inv.id
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.status = prj.status
);


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

SELECT amount FROM invoices AS inv
WHERE code IN (
    SELECT code FROM sales AS dept
    WHERE dept.type = inv.type
);


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

SELECT amount FROM managers AS mgr
WHERE value > (
    SELECT MIN(amount) FROM orders AS prj
    WHERE prj.type = mgr.type
);


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

SELECT salary FROM requests AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS emp
    WHERE emp.status = ordr.status
);


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

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


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

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


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

SELECT name FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM requests AS lne
    WHERE lne.type = tsk.type
);


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

SELECT id FROM projects AS prj
WHERE salary > (
    SELECT SUM(amount) FROM customers AS ord
    WHERE ord.type = prj.type
);


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

SELECT salary FROM accounts AS acct
WHERE code IN (
    SELECT code FROM categories AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS prj
    WHERE prj.level = emp.level
);


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

SELECT name FROM invoices AS inv
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS txn
    WHERE txn.code = inv.code
);


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

SELECT salary FROM accounts AS acct
WHERE salary > (
    SELECT SUM(amount) FROM branches AS schd
    WHERE schd.code = acct.code
);


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

SELECT amount FROM products AS prod
WHERE salary > (
    SELECT AVG(value) FROM employees AS prj
    WHERE prj.id = prod.id
);


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

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


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

SELECT name FROM customers AS cust
WHERE type IN (
    SELECT type FROM orders AS rgn
    WHERE rgn.code = cust.code
);


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

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


Prompt:
Schema:
  projects (alias: prj)(id, date, code, salary)
  employees(status, type, level, date)
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 dept
    WHERE dept.code = prj.code
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT code FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT code FROM managers AS mgr
WHERE type IN (
    SELECT type FROM items AS inv
    WHERE inv.type = mgr.type
);


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

SELECT id FROM regions AS rgn
WHERE id IN (
    SELECT id FROM products AS txn
    WHERE txn.id = rgn.id
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT salary FROM schedules AS schd
WHERE level IN (
    SELECT level FROM regions AS prj
    WHERE prj.id = schd.id
);


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

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


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

SELECT id FROM branches AS brc
WHERE status IN (
    SELECT status FROM categories AS dept
    WHERE dept.id = brc.id
);


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT MAX(value) FROM tasks AS schd
    WHERE schd.code = dept.code
);


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

SELECT name FROM employees AS emp
WHERE status IN (
    SELECT status FROM sales AS emp
    WHERE emp.type = emp.type
);


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

SELECT salary FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(amount) FROM managers AS shp
    WHERE shp.status = tsk.status
);


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

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


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

SELECT salary FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM projects AS empl
    WHERE empl.type = tsk.type
);


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

SELECT salary FROM regions AS rgn
WHERE level IN (
    SELECT level FROM accounts AS prj
    WHERE prj.status = rgn.status
);


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

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


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

SELECT name FROM customers AS cust
WHERE code IN (
    SELECT code FROM requests AS lne
    WHERE lne.code = cust.code
);


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

SELECT salary FROM customers AS cust
WHERE code IN (
    SELECT code FROM tasks AS dept
    WHERE dept.code = cust.code
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.type = ordr.type
);


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

SELECT value FROM accounts AS acct
WHERE amount > (
    SELECT MAX(value) FROM transactions AS lne
    WHERE lne.code = acct.code
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM managers AS shp
    WHERE shp.id = sale.id
);


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

SELECT name FROM schedules AS schd
WHERE type IN (
    SELECT type FROM orders AS acct
    WHERE acct.id = schd.id
);


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

SELECT salary FROM categories AS catg
WHERE level IN (
    SELECT level FROM orders AS ordr
    WHERE ordr.id = catg.id
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE code IN (
    SELECT code FROM requests AS emp
    WHERE emp.level = txn.level
);


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

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


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM managers AS ord
    WHERE ord.id = brc.id
);


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

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


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

SELECT name FROM accounts AS acct
WHERE id IN (
    SELECT id FROM managers AS tsk
    WHERE tsk.code = acct.code
);


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

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


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

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


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.status = lne.status
);


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

SELECT code FROM items AS lne
WHERE amount > (
    SELECT MAX(salary) FROM departments AS cust
    WHERE cust.level = lne.level
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.type = prod.type
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.type = ord.type
);


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

SELECT amount FROM items AS lne
WHERE code IN (
    SELECT code FROM regions AS brc
    WHERE brc.level = lne.level
);


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

SELECT code FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.type = tsk.type
);


Prompt:
Schema:
  accounts (alias: acct)(status, level, name, code)
  staff(salary, amount, code, level)
Task: Find salary from accounts where salary exceeds the total salary from staff for the same code.
SQL:

SELECT salary FROM accounts AS acct
WHERE salary > (
    SELECT SUM(salary) FROM staff AS prod
    WHERE prod.code = acct.code
);


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

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


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS tsk
    WHERE tsk.level = mgr.level
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS brc
    WHERE brc.type = txn.type
);


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

SELECT salary FROM orders AS ord
WHERE amount > (
    SELECT AVG(amount) FROM categories AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM schedules AS mgr
    WHERE mgr.type = empl.type
);


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

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


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

SELECT amount FROM employees AS emp
WHERE code IN (
    SELECT code FROM staff AS cust
    WHERE cust.type = emp.type
);


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

SELECT code FROM projects AS prj
WHERE id IN (
    SELECT id FROM orders AS tsk
    WHERE tsk.code = prj.code
);


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

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


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

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


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = emp.level
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT code FROM managers AS mgr
WHERE salary > (
    SELECT MIN(value) FROM shipments AS inv
    WHERE inv.code = mgr.code
);


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

SELECT salary FROM regions AS rgn
WHERE status IN (
    SELECT status FROM invoices AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT code FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM invoices AS ordr
    WHERE ordr.type = tsk.type
);


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

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


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

SELECT value FROM projects AS prj
WHERE type IN (
    SELECT type FROM staff AS prod
    WHERE prod.status = prj.status
);


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

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


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

SELECT salary FROM departments AS dept
WHERE salary > (
    SELECT COUNT(amount) FROM requests AS emp
    WHERE emp.id = dept.id
);


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

SELECT name FROM managers AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS shp
    WHERE shp.status = mgr.status
);


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

SELECT name FROM employees AS emp
WHERE type IN (
    SELECT type FROM sales AS txn
    WHERE txn.level = emp.level
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM staff AS brc
    WHERE brc.status = catg.status
);