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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.code = prod.code
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.level = ord.level
);


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

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


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

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.status = inv.status
);


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

SELECT id FROM shipments AS shp
WHERE level IN (
    SELECT level FROM projects AS sale
    WHERE sale.type = shp.type
);


Prompt:
Schema:
  regions (alias: rgn)(salary, type, id, level)
  schedules(code, status, amount, level)
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 inv
    WHERE inv.status = rgn.status
);


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

SELECT value FROM categories AS catg
WHERE amount > (
    SELECT MIN(value) FROM invoices AS lne
    WHERE lne.code = catg.code
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = lne.status
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.code = sale.code
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.code = cust.code
);


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

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


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

SELECT id FROM sales AS sale
WHERE amount > (
    SELECT SUM(amount) FROM transactions AS tsk
    WHERE tsk.type = sale.type
);


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

SELECT amount FROM transactions AS txn
WHERE type IN (
    SELECT type FROM regions AS rgn
    WHERE rgn.status = txn.status
);


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

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


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

SELECT salary FROM departments AS dept
WHERE status IN (
    SELECT status FROM sales AS schd
    WHERE schd.level = dept.level
);


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

SELECT value FROM staff AS empl
WHERE type IN (
    SELECT type FROM accounts AS lne
    WHERE lne.level = empl.level
);


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

SELECT salary FROM projects AS prj
WHERE level IN (
    SELECT level FROM tasks AS acct
    WHERE acct.id = prj.id
);


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

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


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

SELECT id FROM transactions AS txn
WHERE salary > (
    SELECT MAX(value) FROM products AS ord
    WHERE ord.id = txn.id
);


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

SELECT id FROM transactions AS txn
WHERE amount > (
    SELECT AVG(value) FROM accounts AS txn
    WHERE txn.status = txn.status
);


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

SELECT value FROM accounts AS acct
WHERE type IN (
    SELECT type FROM invoices AS catg
    WHERE catg.level = acct.level
);


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS brc
    WHERE brc.level = ord.level
);


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.type = sale.type
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = sale.level
);


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

SELECT id FROM sales AS sale
WHERE status IN (
    SELECT status FROM regions AS prod
    WHERE prod.code = sale.code
);


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

SELECT code FROM schedules AS schd
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS lne
    WHERE lne.id = schd.id
);


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

SELECT salary FROM regions AS rgn
WHERE id IN (
    SELECT id FROM customers AS emp
    WHERE emp.code = rgn.code
);


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

SELECT amount FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.code = tsk.code
);


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

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


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

SELECT value FROM staff AS empl
WHERE salary > (
    SELECT AVG(value) FROM regions AS cust
    WHERE cust.id = empl.id
);


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

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


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

SELECT name FROM categories AS catg
WHERE value > (
    SELECT MIN(value) FROM managers AS ord
    WHERE ord.type = catg.type
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.level = empl.level
);


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

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


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.id = prj.id
);


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

SELECT id FROM accounts AS acct
WHERE salary > (
    SELECT AVG(amount) FROM invoices AS tsk
    WHERE tsk.level = acct.level
);


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

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


Prompt:
Schema:
  projects (alias: prj)(value, amount, salary, level)
  products(level, salary, value, id)
Task: Find salary from projects where value exceeds the maximum amount from products for the same type.
SQL:

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


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

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


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.id = schd.id
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS prj
    WHERE prj.status = sale.status
);


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

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


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

SELECT value FROM categories AS catg
WHERE code IN (
    SELECT code FROM orders AS schd
    WHERE schd.level = catg.level
);


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

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


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

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


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

SELECT salary FROM projects AS prj
WHERE salary > (
    SELECT MAX(amount) FROM schedules AS rgn
    WHERE rgn.level = prj.level
);


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

SELECT amount FROM schedules AS schd
WHERE id IN (
    SELECT id FROM requests AS shp
    WHERE shp.level = schd.level
);


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

SELECT value FROM branches AS brc
WHERE salary > (
    SELECT MAX(value) FROM departments AS acct
    WHERE acct.level = brc.level
);


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

SELECT name FROM branches AS brc
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS schd
    WHERE schd.level = brc.level
);


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

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


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

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


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

SELECT code FROM projects AS prj
WHERE value > (
    SELECT MAX(amount) FROM orders AS cust
    WHERE cust.level = prj.level
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM employees AS prj
    WHERE prj.type = brc.type
);


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

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


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM sales AS dept
    WHERE dept.code = emp.code
);


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

SELECT name FROM sales AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS prj
    WHERE prj.type = sale.type
);


Prompt:
Schema:
  tasks (alias: tsk)(level, name, amount, status)
  shipments(type, name, value, 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 txn
    WHERE txn.type = tsk.type
);


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

SELECT value FROM products AS prod
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.type = prod.type
);


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

SELECT amount FROM categories AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS dept
    WHERE dept.id = catg.id
);


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

SELECT code FROM managers AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM regions AS prj
    WHERE prj.type = mgr.type
);


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

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


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

SELECT code FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS brc
    WHERE brc.type = ordr.type
);


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

SELECT value FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM products AS dept
    WHERE dept.type = tsk.type
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.code = rgn.code
);


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

SELECT value FROM employees AS emp
WHERE type IN (
    SELECT type FROM regions AS brc
    WHERE brc.status = emp.status
);


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

SELECT value FROM branches AS brc
WHERE status IN (
    SELECT status FROM projects AS empl
    WHERE empl.code = brc.code
);


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

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


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

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


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

SELECT id FROM regions AS rgn
WHERE status IN (
    SELECT status FROM invoices AS catg
    WHERE catg.status = rgn.status
);


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

SELECT id FROM sales AS sale
WHERE amount > (
    SELECT MAX(salary) FROM schedules AS mgr
    WHERE mgr.level = sale.level
);


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

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


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM items AS sale
    WHERE sale.type = ord.type
);


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

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


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

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


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

SELECT value FROM requests AS ordr
WHERE id IN (
    SELECT id FROM employees AS ordr
    WHERE ordr.code = ordr.code
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.status = tsk.status
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.code = txn.code
);


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

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


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.status = sale.status
);


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

SELECT id FROM regions AS rgn
WHERE amount > (
    SELECT SUM(amount) FROM items AS empl
    WHERE empl.id = rgn.id
);


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

SELECT id FROM projects AS prj
WHERE value > (
    SELECT AVG(salary) FROM departments AS lne
    WHERE lne.type = prj.type
);


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.code = prj.code
);


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

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


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

SELECT salary FROM invoices AS inv
WHERE level IN (
    SELECT level FROM tasks AS sale
    WHERE sale.type = inv.type
);


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

SELECT value FROM items AS lne
WHERE id IN (
    SELECT id FROM managers AS catg
    WHERE catg.type = lne.type
);


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

SELECT name FROM branches AS brc
WHERE salary > (
    SELECT AVG(salary) FROM schedules AS inv
    WHERE inv.status = brc.status
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS prj
    WHERE prj.id = shp.id
);


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

SELECT amount FROM managers AS mgr
WHERE id IN (
    SELECT id FROM departments AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT name FROM branches AS brc
WHERE salary > (
    SELECT MAX(salary) FROM sales AS cust
    WHERE cust.status = brc.status
);


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

SELECT amount FROM schedules AS schd
WHERE level IN (
    SELECT level FROM tasks AS lne
    WHERE lne.code = schd.code
);


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

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


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

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


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

SELECT code FROM categories AS catg
WHERE value > (
    SELECT AVG(amount) FROM products AS lne
    WHERE lne.id = catg.id
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.code = prod.code
);


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

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


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

SELECT name FROM items AS lne
WHERE amount > (
    SELECT MIN(salary) FROM regions AS prj
    WHERE prj.id = lne.id
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS prj
    WHERE prj.level = txn.level
);


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

SELECT name FROM transactions AS txn
WHERE status IN (
    SELECT status FROM orders AS lne
    WHERE lne.id = txn.id
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM invoices AS brc
    WHERE brc.code = tsk.code
);


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM staff AS dept
    WHERE dept.status = brc.status
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.type = ordr.type
);


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

SELECT code FROM accounts AS acct
WHERE level IN (
    SELECT level FROM products AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT name FROM customers AS cust
WHERE value > (
    SELECT MAX(amount) FROM invoices AS emp
    WHERE emp.id = cust.id
);


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

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


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

SELECT salary FROM customers AS cust
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.status = cust.status
);


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

SELECT name FROM employees AS emp
WHERE type IN (
    SELECT type FROM branches AS brc
    WHERE brc.id = emp.id
);


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

SELECT name FROM customers AS cust
WHERE amount > (
    SELECT AVG(value) FROM projects AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT id FROM staff AS empl
WHERE code IN (
    SELECT code FROM projects AS tsk
    WHERE tsk.level = empl.level
);


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

SELECT amount FROM invoices AS inv
WHERE status IN (
    SELECT status FROM items AS acct
    WHERE acct.code = inv.code
);


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

SELECT value FROM transactions AS txn
WHERE value > (
    SELECT MAX(value) FROM projects AS prod
    WHERE prod.code = txn.code
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.code = shp.code
);


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

SELECT amount FROM products AS prod
WHERE status IN (
    SELECT status FROM managers AS catg
    WHERE catg.status = prod.status
);


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

SELECT id FROM projects AS prj
WHERE status IN (
    SELECT status FROM staff AS inv
    WHERE inv.code = prj.code
);


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.code = ordr.code
);


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM managers AS inv
    WHERE inv.code = dept.code
);


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

SELECT salary FROM sales AS sale
WHERE status IN (
    SELECT status FROM categories AS lne
    WHERE lne.id = sale.id
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM staff AS cust
    WHERE cust.id = acct.id
);


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

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


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

SELECT code FROM requests AS ordr
WHERE value > (
    SELECT MIN(salary) FROM projects AS inv
    WHERE inv.level = ordr.level
);


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

SELECT salary FROM requests AS ordr
WHERE value > (
    SELECT AVG(value) FROM branches AS cust
    WHERE cust.level = ordr.level
);


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

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


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

SELECT value FROM categories AS catg
WHERE type IN (
    SELECT type FROM regions AS shp
    WHERE shp.id = catg.id
);


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

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


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

SELECT id FROM projects AS prj
WHERE amount > (
    SELECT AVG(salary) FROM staff AS tsk
    WHERE tsk.id = prj.id
);


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

SELECT value FROM requests AS ordr
WHERE amount > (
    SELECT MAX(value) FROM items AS empl
    WHERE empl.level = ordr.level
);


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

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


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = tsk.level
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE salary > (
    SELECT SUM(salary) FROM sales AS ordr
    WHERE ordr.code = tsk.code
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.type = sale.type
);


Prompt:
Schema:
  items (alias: lne)(status, salary, date, level)
  schedules(name, code, status, level)
Task: Find amount from items where salary exceeds the count of salary from schedules for the same code.
SQL:

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


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS brc
    WHERE brc.id = ordr.id
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT salary FROM items AS lne
WHERE salary > (
    SELECT MIN(amount) FROM orders AS ord
    WHERE ord.id = lne.id
);


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

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


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

SELECT code FROM shipments AS shp
WHERE level IN (
    SELECT level FROM branches AS brc
    WHERE brc.code = shp.code
);


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

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


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.id = prj.id
);


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

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


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM requests AS mgr
    WHERE mgr.type = dept.type
);


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

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


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

SELECT code FROM regions AS rgn
WHERE salary > (
    SELECT AVG(value) FROM transactions AS empl
    WHERE empl.type = rgn.type
);


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

SELECT amount FROM transactions AS txn
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS empl
    WHERE empl.id = txn.id
);


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS brc
    WHERE brc.type = ord.type
);


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

SELECT name FROM requests AS ordr
WHERE level IN (
    SELECT level FROM categories AS catg
    WHERE catg.status = ordr.status
);


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

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


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

SELECT name FROM sales AS sale
WHERE value > (
    SELECT COUNT(value) FROM items AS txn
    WHERE txn.level = sale.level
);


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

SELECT salary FROM departments AS dept
WHERE value > (
    SELECT MIN(value) FROM regions AS prj
    WHERE prj.level = dept.level
);


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

SELECT value FROM regions AS rgn
WHERE status IN (
    SELECT status FROM projects AS sale
    WHERE sale.level = rgn.level
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.code = shp.code
);


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

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


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

SELECT amount FROM products AS prod
WHERE code IN (
    SELECT code FROM customers AS tsk
    WHERE tsk.code = prod.code
);


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

SELECT name FROM projects AS prj
WHERE amount > (
    SELECT MIN(value) FROM transactions AS inv
    WHERE inv.id = prj.id
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.code = prod.code
);


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

SELECT amount FROM accounts AS acct
WHERE id IN (
    SELECT id FROM schedules AS catg
    WHERE catg.id = acct.id
);


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

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


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

SELECT id FROM items AS lne
WHERE amount > (
    SELECT SUM(value) FROM transactions AS acct
    WHERE acct.id = lne.id
);


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.code = txn.code
);


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

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


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

SELECT value FROM schedules AS schd
WHERE amount > (
    SELECT SUM(value) FROM tasks AS brc
    WHERE brc.status = schd.status
);


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

SELECT id FROM tasks AS tsk
WHERE amount > (
    SELECT MIN(value) FROM invoices AS catg
    WHERE catg.type = tsk.type
);


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

SELECT code FROM schedules AS schd
WHERE code IN (
    SELECT code FROM items AS catg
    WHERE catg.level = schd.level
);


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

SELECT amount FROM departments AS dept
WHERE level IN (
    SELECT level FROM schedules AS emp
    WHERE emp.id = dept.id
);


Prompt:
Schema:
  departments (alias: dept)(status, type, date, amount)
  requests(amount, status, code, level)
Task: Find amount from departments where level appears in requests entries with matching type.
SQL:

SELECT amount FROM departments AS dept
WHERE level IN (
    SELECT level FROM requests AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT id FROM sales AS sale
WHERE level IN (
    SELECT level FROM projects AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.type = inv.type
);


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

SELECT value FROM customers AS cust
WHERE value > (
    SELECT AVG(salary) FROM shipments AS lne
    WHERE lne.level = cust.level
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM items AS shp
    WHERE shp.level = inv.level
);


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

SELECT value FROM branches AS brc
WHERE value > (
    SELECT MIN(amount) FROM categories AS schd
    WHERE schd.id = brc.id
);


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

SELECT code FROM projects AS prj
WHERE salary > (
    SELECT MAX(salary) FROM departments AS empl
    WHERE empl.status = prj.status
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = dept.id
);


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

SELECT value FROM orders AS ord
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS inv
    WHERE inv.type = ord.type
);


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

SELECT value FROM customers AS cust
WHERE status IN (
    SELECT status FROM products AS ord
    WHERE ord.status = cust.status
);


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

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


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

SELECT salary FROM staff AS empl
WHERE salary > (
    SELECT AVG(value) FROM regions AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT code FROM invoices AS inv
WHERE level IN (
    SELECT level FROM employees AS tsk
    WHERE tsk.status = inv.status
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS brc
    WHERE brc.level = prod.level
);


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.status = mgr.status
);


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

SELECT salary FROM requests AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS lne
    WHERE lne.code = ordr.code
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.status = rgn.status
);


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.code = empl.code
);


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

SELECT amount FROM invoices AS inv
WHERE salary > (
    SELECT COUNT(amount) FROM requests AS inv
    WHERE inv.status = inv.status
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT value FROM categories AS catg
WHERE id IN (
    SELECT id FROM orders AS txn
    WHERE txn.type = catg.type
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.code = tsk.code
);


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

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


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM managers AS prj
    WHERE prj.code = sale.code
);


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

SELECT value FROM items AS lne
WHERE type IN (
    SELECT type FROM requests AS prj
    WHERE prj.status = lne.status
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM sales AS txn
    WHERE txn.status = cust.status
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS brc
    WHERE brc.status = empl.status
);


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

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


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

SELECT name FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(value) FROM orders AS brc
    WHERE brc.level = shp.level
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.id = prod.id
);


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

SELECT code FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.type = brc.type
);


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

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM branches AS sale
    WHERE sale.level = cust.level
);


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

SELECT code FROM customers AS cust
WHERE level IN (
    SELECT level FROM shipments AS ord
    WHERE ord.type = cust.type
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS tsk
    WHERE tsk.id = ordr.id
);


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

SELECT code FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM items AS ord
    WHERE ord.status = ordr.status
);


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

SELECT value FROM departments AS dept
WHERE id IN (
    SELECT id FROM branches AS acct
    WHERE acct.status = dept.status
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS brc
    WHERE brc.code = rgn.code
);


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

SELECT value FROM tasks AS tsk
WHERE value > (
    SELECT SUM(salary) FROM invoices AS schd
    WHERE schd.type = tsk.type
);


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

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


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

SELECT code FROM products AS prod
WHERE salary > (
    SELECT SUM(salary) FROM departments AS empl
    WHERE empl.code = prod.code
);


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

SELECT code FROM customers AS cust
WHERE id IN (
    SELECT id FROM branches AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT id FROM invoices AS inv
WHERE salary > (
    SELECT AVG(amount) FROM categories AS inv
    WHERE inv.type = inv.type
);


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

SELECT code FROM departments AS dept
WHERE amount > (
    SELECT MAX(salary) FROM requests AS acct
    WHERE acct.level = dept.level
);


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

SELECT salary FROM staff AS empl
WHERE value > (
    SELECT MIN(salary) FROM departments AS catg
    WHERE catg.level = empl.level
);


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

SELECT id FROM shipments AS shp
WHERE level IN (
    SELECT level FROM staff AS catg
    WHERE catg.id = shp.id
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.type = tsk.type
);


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

SELECT amount FROM customers AS cust
WHERE id IN (
    SELECT id FROM employees AS rgn
    WHERE rgn.type = cust.type
);


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

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


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

SELECT code FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.status = brc.status
);


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

SELECT code FROM regions AS rgn
WHERE type IN (
    SELECT type FROM categories AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT name FROM products AS prod
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.level = prod.level
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.type = catg.type
);


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

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


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

SELECT value FROM shipments AS shp
WHERE salary > (
    SELECT MAX(salary) FROM requests AS txn
    WHERE txn.code = shp.code
);


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.id = brc.id
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM sales AS acct
    WHERE acct.type = empl.type
);


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

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


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.status = ordr.status
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM items AS cust
    WHERE cust.id = acct.id
);


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

SELECT amount FROM requests AS ordr
WHERE value > (
    SELECT MAX(salary) FROM invoices AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT code FROM staff AS empl
WHERE amount > (
    SELECT MAX(salary) FROM employees AS sale
    WHERE sale.status = empl.status
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE salary > (
    SELECT MAX(amount) FROM schedules AS lne
    WHERE lne.level = txn.level
);


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

SELECT amount FROM branches AS brc
WHERE value > (
    SELECT SUM(amount) FROM projects AS shp
    WHERE shp.code = brc.code
);


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.level = prj.level
);


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

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


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

SELECT name FROM staff AS empl
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS brc
    WHERE brc.code = empl.code
);


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

SELECT value FROM managers AS mgr
WHERE amount > (
    SELECT SUM(value) FROM branches AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT salary FROM items AS lne
WHERE code IN (
    SELECT code FROM invoices AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.code = rgn.code
);


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

SELECT name FROM sales AS sale
WHERE status IN (
    SELECT status FROM regions AS tsk
    WHERE tsk.level = sale.level
);


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

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


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.type = schd.type
);


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM categories AS brc
    WHERE brc.id = prj.id
);


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

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


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.code = ord.code
);


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

SELECT name FROM requests AS ordr
WHERE id IN (
    SELECT id FROM departments AS schd
    WHERE schd.status = ordr.status
);


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

SELECT value FROM categories AS catg
WHERE level IN (
    SELECT level FROM accounts AS ordr
    WHERE ordr.id = catg.id
);


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

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


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

SELECT name FROM products AS prod
WHERE id IN (
    SELECT id FROM projects AS tsk
    WHERE tsk.status = prod.status
);


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

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


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

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


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM customers AS brc
    WHERE brc.type = prj.type
);


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

SELECT name FROM employees AS emp
WHERE id IN (
    SELECT id FROM staff AS emp
    WHERE emp.level = emp.level
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE level IN (
    SELECT level FROM products AS dept
    WHERE dept.code = txn.code
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM staff AS inv
    WHERE inv.id = shp.id
);


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

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


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

SELECT value FROM categories AS catg
WHERE value > (
    SELECT SUM(salary) FROM managers AS txn
    WHERE txn.type = catg.type
);


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

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


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

SELECT salary FROM categories AS catg
WHERE level IN (
    SELECT level FROM branches AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.type = catg.type
);


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

SELECT name FROM transactions AS txn
WHERE value > (
    SELECT SUM(value) FROM branches AS prod
    WHERE prod.status = txn.status
);


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

SELECT salary FROM projects AS prj
WHERE id IN (
    SELECT id FROM shipments AS lne
    WHERE lne.level = prj.level
);


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

SELECT salary FROM schedules AS schd
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS txn
    WHERE txn.code = schd.code
);


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

SELECT id FROM staff AS empl
WHERE level IN (
    SELECT level FROM accounts AS shp
    WHERE shp.type = empl.type
);


Prompt:
Schema:
  categories (alias: catg)(type, level, date, salary)
  schedules(value, salary, level, date)
Task: Find code from categories where value exceeds the total value from schedules for the same status.
SQL:

SELECT code FROM categories AS catg
WHERE value > (
    SELECT SUM(value) FROM schedules AS sale
    WHERE sale.status = catg.status
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM items AS prod
    WHERE prod.code = sale.code
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE code IN (
    SELECT code FROM branches AS shp
    WHERE shp.id = mgr.id
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM managers AS catg
    WHERE catg.status = prod.status
);


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

SELECT code FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.level = prj.level
);


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

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


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS prj
    WHERE prj.level = inv.level
);


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

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


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

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


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

SELECT code FROM tasks AS tsk
WHERE amount > (
    SELECT AVG(salary) FROM departments AS txn
    WHERE txn.level = tsk.level
);


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

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


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.type = lne.type
);


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

SELECT salary FROM items AS lne
WHERE type IN (
    SELECT type FROM accounts AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.level = inv.level
);


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

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


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

SELECT code FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.code = tsk.code
);


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

SELECT name FROM invoices AS inv
WHERE type IN (
    SELECT type FROM projects AS lne
    WHERE lne.type = inv.type
);


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

SELECT code FROM departments AS dept
WHERE value > (
    SELECT SUM(value) FROM customers AS prod
    WHERE prod.level = dept.level
);


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

SELECT salary FROM regions AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM projects AS emp
    WHERE emp.type = rgn.type
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.type = shp.type
);


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

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


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.level = txn.level
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM schedules AS sale
    WHERE sale.type = mgr.type
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT value FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM categories AS ordr
    WHERE ordr.level = tsk.level
);


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

SELECT code FROM staff AS empl
WHERE level IN (
    SELECT level FROM categories AS inv
    WHERE inv.type = empl.type
);


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM managers AS prod
    WHERE prod.type = ordr.type
);


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

SELECT value FROM transactions AS txn
WHERE salary > (
    SELECT COUNT(amount) FROM schedules AS inv
    WHERE inv.id = txn.id
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.status = ordr.status
);


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

SELECT name FROM sales AS sale
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT name FROM staff AS empl
WHERE type IN (
    SELECT type FROM shipments AS inv
    WHERE inv.id = empl.id
);


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

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


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

SELECT id FROM categories AS catg
WHERE id IN (
    SELECT id FROM departments AS dept
    WHERE dept.code = catg.code
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.code = ordr.code
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS prj
    WHERE prj.id = inv.id
);