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

SELECT salary FROM customers AS cust
WHERE code IN (
    SELECT code FROM regions AS tsk
    WHERE tsk.type = cust.type
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM sales AS tsk
    WHERE tsk.code = prod.code
);


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

SELECT value FROM accounts AS acct
WHERE value > (
    SELECT SUM(value) FROM managers AS prj
    WHERE prj.code = acct.code
);


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

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


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

SELECT name FROM requests AS ordr
WHERE amount > (
    SELECT SUM(amount) FROM departments AS dept
    WHERE dept.code = ordr.code
);


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

SELECT name FROM customers AS cust
WHERE salary > (
    SELECT MAX(value) FROM regions AS mgr
    WHERE mgr.level = cust.level
);


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

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


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT AVG(salary) FROM categories AS sale
    WHERE sale.level = shp.level
);


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

SELECT salary FROM requests AS ordr
WHERE status IN (
    SELECT status FROM employees AS schd
    WHERE schd.level = ordr.level
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.level = txn.level
);


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

SELECT amount FROM managers AS mgr
WHERE amount > (
    SELECT SUM(value) FROM items AS ord
    WHERE ord.code = mgr.code
);


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT SUM(salary) FROM shipments AS dept
    WHERE dept.code = rgn.code
);


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

SELECT amount FROM invoices AS inv
WHERE id IN (
    SELECT id FROM requests AS tsk
    WHERE tsk.level = inv.level
);


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

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


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

SELECT amount FROM managers AS mgr
WHERE amount > (
    SELECT MIN(salary) FROM requests AS prod
    WHERE prod.status = mgr.status
);


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

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


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM sales AS empl
    WHERE empl.level = shp.level
);


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

SELECT code FROM orders AS ord
WHERE level IN (
    SELECT level FROM departments AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT amount FROM regions AS rgn
WHERE value > (
    SELECT AVG(amount) FROM transactions AS schd
    WHERE schd.id = rgn.id
);


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

SELECT id FROM transactions AS txn
WHERE salary > (
    SELECT MIN(salary) FROM sales AS lne
    WHERE lne.code = txn.code
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM requests AS prod
    WHERE prod.type = rgn.type
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS prj
    WHERE prj.type = rgn.type
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.id = ord.id
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM staff AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT salary FROM transactions AS txn
WHERE level IN (
    SELECT level FROM categories AS lne
    WHERE lne.level = txn.level
);


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

SELECT value FROM sales AS sale
WHERE id IN (
    SELECT id FROM customers AS empl
    WHERE empl.id = sale.id
);


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

SELECT code FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM sales AS ord
    WHERE ord.level = tsk.level
);


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

SELECT name FROM items AS lne
WHERE value > (
    SELECT MAX(value) FROM regions AS schd
    WHERE schd.level = lne.level
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.type = txn.type
);


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

SELECT id FROM employees AS emp
WHERE value > (
    SELECT MAX(salary) FROM accounts AS empl
    WHERE empl.status = emp.status
);


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

SELECT salary FROM items AS lne
WHERE type IN (
    SELECT type FROM branches AS catg
    WHERE catg.level = lne.level
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.type = lne.type
);


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

SELECT amount FROM invoices AS inv
WHERE code IN (
    SELECT code FROM requests AS txn
    WHERE txn.id = inv.id
);


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

SELECT salary FROM invoices AS inv
WHERE value > (
    SELECT AVG(salary) FROM items AS acct
    WHERE acct.code = inv.code
);


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

SELECT salary FROM schedules AS schd
WHERE level IN (
    SELECT level FROM shipments AS prj
    WHERE prj.type = schd.type
);


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

SELECT salary FROM schedules AS schd
WHERE id IN (
    SELECT id FROM regions AS catg
    WHERE catg.code = schd.code
);


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.type = empl.type
);


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

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


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

SELECT name FROM sales AS sale
WHERE value > (
    SELECT MIN(salary) FROM orders AS brc
    WHERE brc.status = sale.status
);


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

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


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

SELECT amount FROM invoices AS inv
WHERE code IN (
    SELECT code FROM projects AS prod
    WHERE prod.id = inv.id
);


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

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = dept.id
);


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

SELECT value FROM projects AS prj
WHERE id IN (
    SELECT id FROM requests AS rgn
    WHERE rgn.level = prj.level
);


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

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


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.id = shp.id
);


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

SELECT salary FROM transactions AS txn
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT name FROM sales AS sale
WHERE code IN (
    SELECT code FROM projects AS catg
    WHERE catg.id = sale.id
);


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

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


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

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


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

SELECT id FROM branches AS brc
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS sale
    WHERE sale.code = brc.code
);


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

SELECT name FROM projects AS prj
WHERE value > (
    SELECT MAX(salary) FROM employees AS lne
    WHERE lne.code = prj.code
);


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

SELECT amount FROM managers AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM customers AS cust
    WHERE cust.status = mgr.status
);


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

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT AVG(value) FROM schedules AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT name FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = mgr.status
);


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

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


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

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


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

SELECT value FROM orders AS ord
WHERE amount > (
    SELECT MIN(value) FROM transactions AS cust
    WHERE cust.status = ord.status
);


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

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


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

SELECT salary FROM products AS prod
WHERE status IN (
    SELECT status FROM sales AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM staff AS schd
    WHERE schd.code = emp.code
);


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

SELECT code FROM items AS lne
WHERE id IN (
    SELECT id FROM managers AS dept
    WHERE dept.type = lne.type
);


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

SELECT name FROM items AS lne
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS catg
    WHERE catg.level = lne.level
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT name FROM branches AS brc
WHERE amount > (
    SELECT AVG(value) FROM projects AS catg
    WHERE catg.id = brc.id
);


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

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


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

SELECT value FROM accounts AS acct
WHERE salary > (
    SELECT SUM(salary) FROM departments AS ord
    WHERE ord.status = acct.status
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.level = emp.level
);


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

SELECT code FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM schedules AS rgn
    WHERE rgn.type = tsk.type
);


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

SELECT name FROM categories AS catg
WHERE amount > (
    SELECT MAX(salary) FROM products AS brc
    WHERE brc.status = catg.status
);


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

SELECT code FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM invoices AS acct
    WHERE acct.id = tsk.id
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM requests AS tsk
    WHERE tsk.status = sale.status
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.type = prj.type
);


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

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


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

SELECT id FROM regions AS rgn
WHERE level IN (
    SELECT level FROM requests AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM sales AS cust
    WHERE cust.level = shp.level
);


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

SELECT id FROM employees AS emp
WHERE type IN (
    SELECT type FROM projects AS inv
    WHERE inv.level = emp.level
);


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

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


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.id = brc.id
);


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS brc
    WHERE brc.status = acct.status
);


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

SELECT amount FROM departments AS dept
WHERE type IN (
    SELECT type FROM employees AS prod
    WHERE prod.code = dept.code
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.code = tsk.code
);


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

SELECT value FROM accounts AS acct
WHERE level IN (
    SELECT level FROM branches AS shp
    WHERE shp.level = acct.level
);


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

SELECT name FROM invoices AS inv
WHERE amount > (
    SELECT SUM(salary) FROM orders AS inv
    WHERE inv.level = inv.level
);


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

SELECT name FROM departments AS dept
WHERE status IN (
    SELECT status FROM managers AS schd
    WHERE schd.status = dept.status
);


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

SELECT name FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM shipments AS shp
    WHERE shp.level = tsk.level
);


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

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT SUM(amount) FROM managers AS inv
    WHERE inv.level = shp.level
);


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

SELECT salary FROM tasks AS tsk
WHERE salary > (
    SELECT AVG(value) FROM sales AS sale
    WHERE sale.level = tsk.level
);


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

SELECT name FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS tsk
    WHERE tsk.type = mgr.type
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.id = tsk.id
);


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

SELECT name FROM categories AS catg
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS lne
    WHERE lne.type = catg.type
);


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

SELECT value FROM projects AS prj
WHERE salary > (
    SELECT AVG(salary) FROM schedules AS tsk
    WHERE tsk.type = prj.type
);


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

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


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

SELECT amount FROM items AS lne
WHERE amount > (
    SELECT AVG(amount) FROM staff AS acct
    WHERE acct.status = lne.status
);


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

SELECT id FROM employees AS emp
WHERE level IN (
    SELECT level FROM accounts AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT id FROM products AS prod
WHERE level IN (
    SELECT level FROM orders AS dept
    WHERE dept.type = prod.type
);


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

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


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

SELECT amount FROM accounts AS acct
WHERE type IN (
    SELECT type FROM customers AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT code FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(amount) FROM managers AS ordr
    WHERE ordr.id = tsk.id
);


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

SELECT amount FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM requests AS lne
    WHERE lne.id = tsk.id
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM staff AS prod
    WHERE prod.type = brc.type
);


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

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


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

SELECT amount FROM schedules AS schd
WHERE id IN (
    SELECT id FROM accounts AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT amount FROM departments AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM staff AS prod
    WHERE prod.code = dept.code
);


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

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


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

SELECT amount FROM regions AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM departments AS emp
    WHERE emp.code = rgn.code
);


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

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


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

SELECT name FROM transactions AS txn
WHERE code IN (
    SELECT code FROM accounts AS tsk
    WHERE tsk.level = txn.level
);


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

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


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

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


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

SELECT amount FROM sales AS sale
WHERE type IN (
    SELECT type FROM regions AS dept
    WHERE dept.type = sale.type
);


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

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


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

SELECT amount FROM accounts AS acct
WHERE status IN (
    SELECT status FROM projects AS prod
    WHERE prod.level = acct.level
);


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

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT MAX(salary) FROM regions AS prod
    WHERE prod.status = cust.status
);


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

SELECT amount FROM requests AS ordr
WHERE amount > (
    SELECT MAX(salary) FROM departments AS acct
    WHERE acct.type = ordr.type
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM sales AS txn
    WHERE txn.level = lne.level
);


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

SELECT code FROM shipments AS shp
WHERE type IN (
    SELECT type FROM items AS emp
    WHERE emp.type = shp.type
);


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

SELECT name FROM invoices AS inv
WHERE code IN (
    SELECT code FROM branches AS tsk
    WHERE tsk.code = inv.code
);


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

SELECT amount FROM accounts AS acct
WHERE status IN (
    SELECT status FROM departments AS prj
    WHERE prj.level = acct.level
);


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

SELECT value FROM departments AS dept
WHERE code IN (
    SELECT code FROM transactions AS prj
    WHERE prj.id = dept.id
);


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

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT MAX(value) FROM staff AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT value FROM customers AS cust
WHERE status IN (
    SELECT status FROM shipments AS sale
    WHERE sale.status = cust.status
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM schedules AS dept
    WHERE dept.type = acct.type
);


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

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


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

SELECT code FROM staff AS empl
WHERE salary > (
    SELECT COUNT(salary) FROM branches AS lne
    WHERE lne.id = empl.id
);


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

SELECT salary FROM products AS prod
WHERE level IN (
    SELECT level FROM managers AS schd
    WHERE schd.status = prod.status
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.code = acct.code
);


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

SELECT name FROM managers AS mgr
WHERE level IN (
    SELECT level FROM projects AS brc
    WHERE brc.level = mgr.level
);


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

SELECT id FROM tasks AS tsk
WHERE amount > (
    SELECT SUM(amount) FROM invoices AS cust
    WHERE cust.type = tsk.type
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM requests AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT name FROM shipments AS shp
WHERE type IN (
    SELECT type FROM tasks AS tsk
    WHERE tsk.status = shp.status
);


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

SELECT code FROM employees AS emp
WHERE value > (
    SELECT COUNT(salary) FROM schedules AS brc
    WHERE brc.status = emp.status
);


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

SELECT code FROM invoices AS inv
WHERE level IN (
    SELECT level FROM projects AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM requests AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT amount FROM orders AS ord
WHERE code IN (
    SELECT code FROM products AS sale
    WHERE sale.id = ord.id
);


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

SELECT amount FROM branches AS brc
WHERE value > (
    SELECT MIN(salary) FROM employees AS acct
    WHERE acct.id = brc.id
);


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.status = empl.status
);


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

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


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

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


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

SELECT amount FROM transactions AS txn
WHERE amount > (
    SELECT MAX(amount) FROM orders AS acct
    WHERE acct.status = txn.status
);


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

SELECT amount FROM employees AS emp
WHERE status IN (
    SELECT status FROM tasks AS inv
    WHERE inv.id = emp.id
);


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

SELECT amount FROM staff AS empl
WHERE salary > (
    SELECT SUM(amount) FROM orders AS txn
    WHERE txn.type = empl.type
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.type = dept.type
);


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

SELECT name FROM departments AS dept
WHERE type IN (
    SELECT type FROM sales AS inv
    WHERE inv.status = dept.status
);


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

SELECT code FROM staff AS empl
WHERE code IN (
    SELECT code FROM sales AS dept
    WHERE dept.level = empl.level
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM items AS inv
    WHERE inv.status = txn.status
);


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

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


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

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


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.id = dept.id
);


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

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


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

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


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

SELECT salary FROM projects AS prj
WHERE level IN (
    SELECT level FROM departments AS lne
    WHERE lne.code = prj.code
);


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

SELECT amount FROM invoices AS inv
WHERE salary > (
    SELECT MIN(salary) FROM schedules AS mgr
    WHERE mgr.type = inv.type
);


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

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


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

SELECT value FROM managers AS mgr
WHERE level IN (
    SELECT level FROM shipments AS catg
    WHERE catg.type = mgr.type
);


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

SELECT salary FROM regions AS rgn
WHERE value > (
    SELECT MAX(amount) FROM customers AS acct
    WHERE acct.status = rgn.status
);


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

SELECT code FROM categories AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM managers AS ord
    WHERE ord.id = catg.id
);


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

SELECT id FROM staff AS empl
WHERE value > (
    SELECT AVG(amount) FROM accounts AS tsk
    WHERE tsk.level = empl.level
);


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

SELECT value FROM orders AS ord
WHERE code IN (
    SELECT code FROM staff AS brc
    WHERE brc.status = ord.status
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS brc
    WHERE brc.type = acct.type
);


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

SELECT salary FROM transactions AS txn
WHERE salary > (
    SELECT AVG(value) FROM sales AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM sales AS mgr
    WHERE mgr.code = catg.code
);


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

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


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

SELECT value FROM employees AS emp
WHERE salary > (
    SELECT AVG(salary) FROM orders AS catg
    WHERE catg.status = emp.status
);


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

SELECT amount FROM employees AS emp
WHERE value > (
    SELECT SUM(amount) FROM shipments AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT name FROM orders AS ord
WHERE amount > (
    SELECT SUM(salary) FROM requests AS prj
    WHERE prj.code = ord.code
);


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

SELECT id FROM employees AS emp
WHERE salary > (
    SELECT AVG(salary) FROM sales AS prj
    WHERE prj.status = emp.status
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.id = ordr.id
);


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

SELECT code FROM shipments AS shp
WHERE salary > (
    SELECT COUNT(value) FROM projects AS tsk
    WHERE tsk.id = shp.id
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM items AS empl
    WHERE empl.type = prod.type
);


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

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


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

SELECT amount FROM requests AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS rgn
    WHERE rgn.status = ordr.status
);


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

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


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

SELECT code FROM invoices AS inv
WHERE amount > (
    SELECT MAX(salary) FROM orders AS prj
    WHERE prj.level = inv.level
);


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

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


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

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.id = empl.id
);


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

SELECT salary FROM sales AS sale
WHERE status IN (
    SELECT status FROM tasks AS tsk
    WHERE tsk.type = sale.type
);


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

SELECT value FROM managers AS mgr
WHERE status IN (
    SELECT status FROM shipments AS lne
    WHERE lne.code = mgr.code
);


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

SELECT salary FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM branches AS ordr
    WHERE ordr.id = tsk.id
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.level = emp.level
);


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

SELECT salary FROM products AS prod
WHERE salary > (
    SELECT COUNT(salary) FROM sales AS catg
    WHERE catg.type = prod.type
);


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

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM items AS sale
    WHERE sale.code = schd.code
);


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

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


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

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


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.id = dept.id
);


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

SELECT amount FROM transactions AS txn
WHERE status IN (
    SELECT status FROM schedules AS emp
    WHERE emp.id = txn.id
);


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

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


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

SELECT amount FROM schedules AS schd
WHERE salary > (
    SELECT SUM(salary) FROM products AS cust
    WHERE cust.type = schd.type
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = catg.type
);


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

SELECT code FROM categories AS catg
WHERE salary > (
    SELECT SUM(salary) FROM items AS acct
    WHERE acct.code = catg.code
);


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

SELECT salary FROM shipments AS shp
WHERE status IN (
    SELECT status FROM branches AS emp
    WHERE emp.code = shp.code
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.type = prj.type
);


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

SELECT salary FROM managers AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM products AS schd
    WHERE schd.code = mgr.code
);


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

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


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.type = schd.type
);


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

SELECT value FROM schedules AS schd
WHERE id IN (
    SELECT id FROM requests AS txn
    WHERE txn.type = schd.type
);


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

SELECT code FROM transactions AS txn
WHERE code IN (
    SELECT code FROM accounts AS ordr
    WHERE ordr.code = txn.code
);


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

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


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

SELECT code FROM branches AS brc
WHERE salary > (
    SELECT MAX(value) FROM transactions AS shp
    WHERE shp.id = brc.id
);


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

SELECT id FROM orders AS ord
WHERE value > (
    SELECT MAX(amount) FROM staff AS prod
    WHERE prod.type = ord.type
);


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

SELECT id FROM employees AS emp
WHERE salary > (
    SELECT MIN(salary) FROM orders AS acct
    WHERE acct.status = emp.status
);


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

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


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

SELECT id FROM projects AS prj
WHERE id IN (
    SELECT id FROM invoices AS empl
    WHERE empl.type = prj.type
);


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

SELECT value FROM items AS lne
WHERE status IN (
    SELECT status FROM tasks AS prod
    WHERE prod.status = lne.status
);


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

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


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

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


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

SELECT salary FROM branches AS brc
WHERE salary > (
    SELECT AVG(amount) FROM requests AS sale
    WHERE sale.status = brc.status
);


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

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


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

SELECT amount FROM items AS lne
WHERE id IN (
    SELECT id FROM regions AS prj
    WHERE prj.id = lne.id
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.id = ord.id
);


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

SELECT id FROM accounts AS acct
WHERE amount > (
    SELECT SUM(amount) FROM projects AS dept
    WHERE dept.level = acct.level
);


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

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


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

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


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM staff AS brc
    WHERE brc.id = dept.id
);


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

SELECT id FROM tasks AS tsk
WHERE amount > (
    SELECT SUM(amount) FROM orders AS tsk
    WHERE tsk.status = tsk.status
);


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

SELECT id FROM managers AS mgr
WHERE level IN (
    SELECT level FROM orders AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT value FROM schedules AS schd
WHERE value > (
    SELECT AVG(value) FROM branches AS prj
    WHERE prj.type = schd.type
);


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS prj
    WHERE prj.code = empl.code
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = dept.id
);


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

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


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

SELECT code FROM categories AS catg
WHERE salary > (
    SELECT MIN(salary) FROM schedules AS txn
    WHERE txn.id = catg.id
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.type = emp.type
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS prj
    WHERE prj.status = mgr.status
);


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

SELECT name FROM categories AS catg
WHERE value > (
    SELECT AVG(salary) FROM staff AS brc
    WHERE brc.code = catg.code
);


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

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


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

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


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.id = sale.id
);


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

SELECT code FROM departments AS dept
WHERE amount > (
    SELECT MAX(salary) FROM employees AS prod
    WHERE prod.code = dept.code
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.id = catg.id
);


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM schedules AS prod
    WHERE prod.level = prj.level
);


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

SELECT id FROM products AS prod
WHERE level IN (
    SELECT level FROM staff AS shp
    WHERE shp.code = prod.code
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM schedules AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT name FROM categories AS catg
WHERE type IN (
    SELECT type FROM tasks AS prj
    WHERE prj.type = catg.type
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.id = catg.id
);


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

SELECT id FROM transactions AS txn
WHERE type IN (
    SELECT type FROM items AS brc
    WHERE brc.status = txn.status
);


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

SELECT amount FROM departments AS dept
WHERE amount > (
    SELECT COUNT(salary) FROM products AS rgn
    WHERE rgn.level = dept.level
);


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

SELECT name FROM transactions AS txn
WHERE value > (
    SELECT COUNT(amount) FROM branches AS tsk
    WHERE tsk.type = txn.type
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.type = txn.type
);


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

SELECT name FROM items AS lne
WHERE salary > (
    SELECT SUM(salary) FROM shipments AS txn
    WHERE txn.level = lne.level
);


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

SELECT value FROM categories AS catg
WHERE id IN (
    SELECT id FROM requests AS acct
    WHERE acct.code = catg.code
);


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

SELECT amount FROM managers AS mgr
WHERE code IN (
    SELECT code FROM tasks AS mgr
    WHERE mgr.type = mgr.type
);


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

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


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

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


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

SELECT code FROM managers AS mgr
WHERE amount > (
    SELECT SUM(value) FROM accounts AS prod
    WHERE prod.type = mgr.type
);


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

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


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM sales AS prj
    WHERE prj.level = emp.level
);


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

SELECT value FROM tasks AS tsk
WHERE value > (
    SELECT MIN(value) FROM employees AS prj
    WHERE prj.id = tsk.id
);


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

SELECT salary FROM transactions AS txn
WHERE salary > (
    SELECT AVG(salary) FROM orders AS txn
    WHERE txn.id = txn.id
);


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

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


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

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


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

SELECT code FROM categories AS catg
WHERE id IN (
    SELECT id FROM requests AS schd
    WHERE schd.type = catg.type
);


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

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


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.type = tsk.type
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM requests AS cust
    WHERE cust.id = dept.id
);


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

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


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM staff AS cust
    WHERE cust.type = shp.type
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.type = empl.type
);


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

SELECT salary FROM projects AS prj
WHERE type IN (
    SELECT type FROM tasks AS schd
    WHERE schd.status = prj.status
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS acct
    WHERE acct.code = emp.code
);


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT SUM(amount) FROM orders AS prod
    WHERE prod.id = acct.id
);


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

SELECT amount FROM accounts AS acct
WHERE salary > (
    SELECT MAX(value) FROM managers AS schd
    WHERE schd.type = acct.type
);


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

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


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

SELECT value FROM staff AS empl
WHERE id IN (
    SELECT id FROM requests AS catg
    WHERE catg.status = empl.status
);


Prompt:
Schema:
  staff (alias: empl)(amount, value, name, date)
  schedules(status, code, value, level)
Task: Find code from staff where value exceeds the total value from schedules for the same type.
SQL:

SELECT code FROM staff AS empl
WHERE value > (
    SELECT SUM(value) FROM schedules AS brc
    WHERE brc.type = empl.type
);


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

SELECT value FROM staff AS empl
WHERE type IN (
    SELECT type FROM shipments AS sale
    WHERE sale.level = empl.level
);


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

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


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.type = lne.type
);


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

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


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.level = sale.level
);


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

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


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

SELECT amount FROM transactions AS txn
WHERE salary > (
    SELECT AVG(amount) FROM projects AS emp
    WHERE emp.status = txn.status
);


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

SELECT id FROM accounts AS acct
WHERE type IN (
    SELECT type FROM orders AS sale
    WHERE sale.type = acct.type
);


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

SELECT code FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM branches AS catg
    WHERE catg.id = tsk.id
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM staff AS dept
    WHERE dept.status = mgr.status
);


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

SELECT value FROM accounts AS acct
WHERE value > (
    SELECT COUNT(value) FROM tasks AS prod
    WHERE prod.type = acct.type
);


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

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


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

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


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

SELECT salary FROM requests AS ordr
WHERE level IN (
    SELECT level FROM schedules AS catg
    WHERE catg.code = ordr.code
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.type = lne.type
);


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

SELECT salary FROM employees AS emp
WHERE type IN (
    SELECT type FROM customers AS emp
    WHERE emp.level = emp.level
);


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.type = dept.type
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE salary > (
    SELECT MIN(value) FROM shipments AS prj
    WHERE prj.id = schd.id
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM staff AS tsk
    WHERE tsk.code = rgn.code
);


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

SELECT salary FROM requests AS ordr
WHERE type IN (
    SELECT type FROM projects AS emp
    WHERE emp.status = ordr.status
);


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

SELECT id FROM transactions AS txn
WHERE level IN (
    SELECT level FROM managers AS empl
    WHERE empl.id = txn.id
);


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

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


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

SELECT salary FROM products AS prod
WHERE level IN (
    SELECT level FROM accounts AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.code = mgr.code
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.code = shp.code
);


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

SELECT name FROM sales AS sale
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS schd
    WHERE schd.type = sale.type
);


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

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


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

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


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

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


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.id = catg.id
);