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

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


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT AVG(value) FROM orders AS tsk
    WHERE tsk.level = cust.level
);


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

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


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

SELECT amount FROM accounts AS acct
WHERE value > (
    SELECT MIN(amount) FROM branches AS cust
    WHERE cust.type = acct.type
);


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

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


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

SELECT name FROM regions AS rgn
WHERE status IN (
    SELECT status FROM products AS sale
    WHERE sale.id = rgn.id
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.id = mgr.id
);


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

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


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

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


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

SELECT code FROM projects AS prj
WHERE amount > (
    SELECT AVG(value) FROM managers AS tsk
    WHERE tsk.status = prj.status
);


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

SELECT amount FROM orders AS ord
WHERE status IN (
    SELECT status FROM sales AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM schedules AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT id FROM products AS prod
WHERE salary > (
    SELECT MIN(value) FROM sales AS cust
    WHERE cust.id = prod.id
);


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

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


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

SELECT value FROM employees AS emp
WHERE salary > (
    SELECT MAX(value) FROM tasks AS schd
    WHERE schd.level = emp.level
);


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

SELECT code FROM managers AS mgr
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.type = mgr.type
);


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

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


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

SELECT value FROM managers AS mgr
WHERE salary > (
    SELECT MAX(amount) FROM products AS dept
    WHERE dept.level = mgr.level
);


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

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT SUM(value) FROM schedules AS schd
    WHERE schd.status = lne.status
);


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

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


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

SELECT value FROM staff AS empl
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS inv
    WHERE inv.status = empl.status
);


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

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


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

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


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

SELECT value FROM sales AS sale
WHERE code IN (
    SELECT code FROM staff AS ord
    WHERE ord.type = sale.type
);


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

SELECT name FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM customers AS sale
    WHERE sale.status = tsk.status
);


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

SELECT value FROM products AS prod
WHERE salary > (
    SELECT SUM(value) FROM transactions AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM managers AS inv
    WHERE inv.type = txn.type
);


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

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


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.type = acct.type
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.id = rgn.id
);


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

SELECT code FROM departments AS dept
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS ord
    WHERE ord.level = dept.level
);


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

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


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

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


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

SELECT name FROM categories AS catg
WHERE type IN (
    SELECT type FROM items AS shp
    WHERE shp.type = catg.type
);


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

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


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

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


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

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


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

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


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

SELECT id FROM projects AS prj
WHERE type IN (
    SELECT type FROM schedules AS dept
    WHERE dept.level = prj.level
);


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

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


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.code = brc.code
);


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

SELECT value FROM schedules AS schd
WHERE code IN (
    SELECT code FROM projects AS shp
    WHERE shp.status = schd.status
);


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

SELECT amount FROM regions AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM branches AS shp
    WHERE shp.type = rgn.type
);


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

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


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

SELECT amount FROM managers AS mgr
WHERE status IN (
    SELECT status FROM branches AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT code FROM transactions AS txn
WHERE id IN (
    SELECT id FROM products AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT salary FROM accounts AS acct
WHERE code IN (
    SELECT code FROM shipments AS dept
    WHERE dept.code = acct.code
);


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.type = rgn.type
);


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

SELECT value FROM shipments AS shp
WHERE level IN (
    SELECT level FROM sales AS emp
    WHERE emp.id = shp.id
);


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

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


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

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


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

SELECT id FROM products AS prod
WHERE salary > (
    SELECT AVG(amount) FROM departments AS tsk
    WHERE tsk.status = prod.status
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.status = prod.status
);


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

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


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

SELECT name FROM requests AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS catg
    WHERE catg.status = ordr.status
);


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

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


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT MIN(amount) FROM schedules AS acct
    WHERE acct.type = shp.type
);


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

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


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

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


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

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


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

SELECT amount FROM customers AS cust
WHERE salary > (
    SELECT COUNT(amount) FROM tasks AS dept
    WHERE dept.id = cust.id
);


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

SELECT id FROM sales AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS mgr
    WHERE mgr.id = sale.id
);


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

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


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.level = empl.level
);


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

SELECT value FROM branches AS brc
WHERE id IN (
    SELECT id FROM transactions AS dept
    WHERE dept.type = brc.type
);


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

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


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

SELECT value FROM projects AS prj
WHERE value > (
    SELECT COUNT(amount) FROM schedules AS shp
    WHERE shp.status = prj.status
);


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

SELECT id FROM regions AS rgn
WHERE code IN (
    SELECT code FROM accounts AS brc
    WHERE brc.id = rgn.id
);


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

SELECT code FROM items AS lne
WHERE amount > (
    SELECT AVG(salary) FROM orders AS empl
    WHERE empl.status = lne.status
);


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

SELECT salary FROM accounts AS acct
WHERE level IN (
    SELECT level FROM customers AS sale
    WHERE sale.level = acct.level
);


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

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


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

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


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

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


Prompt:
Schema:
  orders (alias: ord)(salary, amount, value, id)
  requests(amount, id, date, code)
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 schd
    WHERE schd.status = ord.status
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM requests AS sale
    WHERE sale.level = prj.level
);


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

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


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

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.id = schd.id
);


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

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS shp
    WHERE shp.type = cust.type
);


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

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


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = txn.type
);


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

SELECT salary FROM products AS prod
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS tsk
    WHERE tsk.type = prod.type
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.level = cust.level
);


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

SELECT id FROM categories AS catg
WHERE value > (
    SELECT SUM(value) FROM branches AS schd
    WHERE schd.code = catg.code
);


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

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


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

SELECT salary FROM employees AS emp
WHERE amount > (
    SELECT MIN(value) FROM customers AS brc
    WHERE brc.type = emp.type
);


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

SELECT code FROM schedules AS schd
WHERE value > (
    SELECT MIN(salary) FROM products AS acct
    WHERE acct.code = schd.code
);


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

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


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

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


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

SELECT name FROM regions AS rgn
WHERE code IN (
    SELECT code FROM departments AS rgn
    WHERE rgn.type = rgn.type
);


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

SELECT salary FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM requests AS acct
    WHERE acct.level = tsk.level
);


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

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


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

SELECT id FROM transactions AS txn
WHERE code IN (
    SELECT code FROM requests AS brc
    WHERE brc.type = txn.type
);


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

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


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

SELECT value FROM branches AS brc
WHERE amount > (
    SELECT MIN(amount) FROM products AS cust
    WHERE cust.type = brc.type
);


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

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


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.level = catg.level
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM managers AS acct
    WHERE acct.id = catg.id
);


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

SELECT amount FROM staff AS empl
WHERE level IN (
    SELECT level FROM items AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM sales AS cust
    WHERE cust.status = catg.status
);


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

SELECT name FROM sales AS sale
WHERE status IN (
    SELECT status FROM items AS prod
    WHERE prod.code = sale.code
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.level = emp.level
);


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

SELECT code FROM projects AS prj
WHERE status IN (
    SELECT status FROM customers AS txn
    WHERE txn.type = prj.type
);


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

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


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

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


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

SELECT id FROM products AS prod
WHERE salary > (
    SELECT SUM(value) FROM items AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT code FROM staff AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT SUM(salary) FROM customers AS acct
    WHERE acct.level = catg.level
);


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

SELECT value FROM invoices AS inv
WHERE amount > (
    SELECT MAX(value) FROM schedules AS brc
    WHERE brc.level = inv.level
);


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

SELECT value FROM requests AS ordr
WHERE code IN (
    SELECT code FROM transactions AS ordr
    WHERE ordr.level = ordr.level
);


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

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


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.level = tsk.level
);


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

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


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM managers AS catg
    WHERE catg.type = inv.type
);


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

SELECT name FROM accounts AS acct
WHERE level IN (
    SELECT level FROM departments AS txn
    WHERE txn.code = acct.code
);


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

SELECT id FROM items AS lne
WHERE amount > (
    SELECT AVG(amount) FROM requests AS dept
    WHERE dept.status = lne.status
);


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

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM requests AS dept
    WHERE dept.type = schd.type
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS txn
    WHERE txn.status = emp.status
);


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

SELECT value FROM departments AS dept
WHERE amount > (
    SELECT SUM(salary) FROM products AS lne
    WHERE lne.level = dept.level
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.id = inv.id
);


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

SELECT code FROM branches AS brc
WHERE type IN (
    SELECT type FROM departments AS acct
    WHERE acct.status = brc.status
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.level = cust.level
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.status = catg.status
);


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

SELECT value FROM invoices AS inv
WHERE level IN (
    SELECT level FROM accounts AS dept
    WHERE dept.type = inv.type
);


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

SELECT salary FROM employees AS emp
WHERE value > (
    SELECT MAX(salary) FROM transactions AS shp
    WHERE shp.code = emp.code
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.level = ord.level
);


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

SELECT value FROM products AS prod
WHERE amount > (
    SELECT MAX(value) FROM transactions AS ordr
    WHERE ordr.status = prod.status
);


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

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


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM sales AS cust
    WHERE cust.type = empl.type
);


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

SELECT name FROM shipments AS shp
WHERE code IN (
    SELECT code FROM departments AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT id FROM sales AS sale
WHERE amount > (
    SELECT MIN(amount) FROM categories AS emp
    WHERE emp.level = sale.level
);


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

SELECT code FROM sales AS sale
WHERE code IN (
    SELECT code FROM transactions AS inv
    WHERE inv.level = sale.level
);


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

SELECT amount FROM staff AS empl
WHERE status IN (
    SELECT status FROM transactions AS prod
    WHERE prod.code = empl.code
);


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

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


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.id = ordr.id
);


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

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


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.status = inv.status
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS tsk
    WHERE tsk.code = lne.code
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = ord.level
);


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

SELECT id FROM orders AS ord
WHERE value > (
    SELECT MIN(value) FROM transactions AS empl
    WHERE empl.id = ord.id
);


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

SELECT value FROM sales AS sale
WHERE amount > (
    SELECT AVG(amount) FROM products AS brc
    WHERE brc.id = sale.id
);


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

SELECT value FROM regions AS rgn
WHERE status IN (
    SELECT status FROM orders AS sale
    WHERE sale.type = rgn.type
);


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT AVG(amount) FROM transactions AS emp
    WHERE emp.id = acct.id
);


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

SELECT amount FROM regions AS rgn
WHERE status IN (
    SELECT status FROM orders AS schd
    WHERE schd.id = rgn.id
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM managers AS cust
    WHERE cust.id = tsk.id
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE salary > (
    SELECT SUM(value) FROM transactions AS rgn
    WHERE rgn.type = tsk.type
);


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

SELECT amount FROM branches AS brc
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS acct
    WHERE acct.level = brc.level
);


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

SELECT value FROM sales AS sale
WHERE salary > (
    SELECT AVG(value) FROM projects AS txn
    WHERE txn.status = sale.status
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = acct.type
);


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

SELECT code FROM sales AS sale
WHERE level IN (
    SELECT level FROM tasks AS cust
    WHERE cust.status = sale.status
);


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

SELECT id FROM managers AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM transactions AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT id FROM managers AS mgr
WHERE type IN (
    SELECT type FROM schedules AS prj
    WHERE prj.id = mgr.id
);


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

SELECT name FROM branches AS brc
WHERE salary > (
    SELECT COUNT(value) FROM shipments AS mgr
    WHERE mgr.code = brc.code
);


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

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


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

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


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

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


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

SELECT salary FROM items AS lne
WHERE level IN (
    SELECT level FROM schedules AS tsk
    WHERE tsk.id = lne.id
);


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS inv
    WHERE inv.code = shp.code
);


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

SELECT id FROM shipments AS shp
WHERE status IN (
    SELECT status FROM employees AS empl
    WHERE empl.status = shp.status
);


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

SELECT value FROM staff AS empl
WHERE level IN (
    SELECT level FROM departments AS emp
    WHERE emp.status = empl.status
);


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

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = inv.status
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.level = txn.level
);


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

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


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

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


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM products AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT salary FROM managers AS mgr
WHERE level IN (
    SELECT level FROM items AS prj
    WHERE prj.type = mgr.type
);


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

SELECT name FROM schedules AS schd
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.id = schd.id
);


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

SELECT amount FROM accounts AS acct
WHERE salary > (
    SELECT AVG(salary) FROM employees AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT value FROM invoices AS inv
WHERE id IN (
    SELECT id FROM tasks AS prod
    WHERE prod.status = inv.status
);


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

SELECT amount FROM employees AS emp
WHERE code IN (
    SELECT code FROM projects AS acct
    WHERE acct.level = emp.level
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE level IN (
    SELECT level FROM categories AS inv
    WHERE inv.level = ordr.level
);


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

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


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

SELECT value FROM regions AS rgn
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS schd
    WHERE schd.type = rgn.type
);


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

SELECT id FROM employees AS emp
WHERE code IN (
    SELECT code FROM items AS txn
    WHERE txn.id = emp.id
);


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM sales AS empl
    WHERE empl.level = ord.level
);


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

SELECT salary FROM staff AS empl
WHERE code IN (
    SELECT code FROM projects AS ord
    WHERE ord.level = empl.level
);


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

SELECT salary FROM branches AS brc
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.status = brc.status
);


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

SELECT code FROM shipments AS shp
WHERE level IN (
    SELECT level FROM requests AS emp
    WHERE emp.code = shp.code
);


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

SELECT id FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM departments AS mgr
    WHERE mgr.id = tsk.id
);


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

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT MIN(salary) FROM orders AS prod
    WHERE prod.level = emp.level
);


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

SELECT amount FROM staff AS empl
WHERE status IN (
    SELECT status FROM schedules AS schd
    WHERE schd.level = empl.level
);


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

SELECT code FROM accounts AS acct
WHERE value > (
    SELECT COUNT(value) FROM items AS empl
    WHERE empl.level = acct.level
);


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

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


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

SELECT name FROM shipments AS shp
WHERE value > (
    SELECT MAX(value) FROM customers AS acct
    WHERE acct.type = shp.type
);


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

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


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.code = inv.code
);


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

SELECT value FROM invoices AS inv
WHERE salary > (
    SELECT SUM(value) FROM customers AS shp
    WHERE shp.type = inv.type
);


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

SELECT code FROM employees AS emp
WHERE value > (
    SELECT MAX(amount) FROM branches AS lne
    WHERE lne.type = emp.type
);


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

SELECT name FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.status = tsk.status
);


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

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


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

SELECT id FROM schedules AS schd
WHERE amount > (
    SELECT SUM(amount) FROM departments AS inv
    WHERE inv.code = schd.code
);


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT MAX(amount) FROM branches AS emp
    WHERE emp.status = catg.status
);


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

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


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.id = empl.id
);


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

SELECT value FROM orders AS ord
WHERE type IN (
    SELECT type FROM requests AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS catg
    WHERE catg.status = cust.status
);


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

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


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS prj
    WHERE prj.level = sale.level
);


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.level = dept.level
);


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

SELECT code FROM shipments AS shp
WHERE salary > (
    SELECT MAX(salary) FROM items AS inv
    WHERE inv.code = shp.code
);


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

SELECT amount FROM categories AS catg
WHERE level IN (
    SELECT level FROM requests AS shp
    WHERE shp.type = catg.type
);


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM schedules AS schd
    WHERE schd.level = shp.level
);


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

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


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM staff AS sale
    WHERE sale.code = brc.code
);


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS txn
    WHERE txn.status = catg.status
);


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

SELECT amount FROM accounts AS acct
WHERE status IN (
    SELECT status FROM shipments AS inv
    WHERE inv.id = acct.id
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.level = catg.level
);


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.id = brc.id
);


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

SELECT value FROM accounts AS acct
WHERE type IN (
    SELECT type FROM items AS schd
    WHERE schd.type = acct.type
);


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

SELECT id FROM items AS lne
WHERE level IN (
    SELECT level FROM orders AS shp
    WHERE shp.code = lne.code
);


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

SELECT amount FROM tasks AS tsk
WHERE value > (
    SELECT SUM(salary) FROM schedules AS inv
    WHERE inv.type = tsk.type
);


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM staff AS brc
    WHERE brc.status = cust.status
);


Prompt:
Schema:
  accounts (alias: acct)(code, salary, value, status)
  departments(amount, salary, type, status)
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 tsk
    WHERE tsk.status = acct.status
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE value > (
    SELECT MAX(salary) FROM requests AS emp
    WHERE emp.id = schd.id
);


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

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


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

SELECT code FROM accounts AS acct
WHERE amount > (
    SELECT COUNT(amount) FROM departments AS brc
    WHERE brc.code = acct.code
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS brc
    WHERE brc.type = empl.type
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.code = rgn.code
);


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

SELECT value FROM employees AS emp
WHERE code IN (
    SELECT code FROM requests AS prj
    WHERE prj.type = emp.type
);


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

SELECT id FROM products AS prod
WHERE value > (
    SELECT COUNT(value) FROM regions AS prj
    WHERE prj.level = prod.level
);


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

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


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

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


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

SELECT salary FROM customers AS cust
WHERE value > (
    SELECT MIN(amount) FROM regions AS cust
    WHERE cust.level = cust.level
);


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

SELECT code FROM customers AS cust
WHERE code IN (
    SELECT code FROM departments AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT name FROM products AS prod
WHERE id IN (
    SELECT id FROM sales AS acct
    WHERE acct.type = prod.type
);


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

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


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

SELECT value FROM items AS lne
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS prj
    WHERE prj.status = lne.status
);


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

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


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM requests AS schd
    WHERE schd.id = shp.id
);


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

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


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

SELECT salary FROM staff AS empl
WHERE code IN (
    SELECT code FROM items AS schd
    WHERE schd.code = empl.code
);


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

SELECT salary FROM products AS prod
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS schd
    WHERE schd.id = prod.id
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.code = mgr.code
);


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

SELECT id FROM branches AS brc
WHERE status IN (
    SELECT status FROM managers AS lne
    WHERE lne.id = brc.id
);


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.status = sale.status
);


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

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


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

SELECT name FROM projects AS prj
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.code = prj.code
);


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

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


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

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


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

SELECT value FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM items AS prod
    WHERE prod.type = tsk.type
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM schedules AS rgn
    WHERE rgn.status = tsk.status
);


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

SELECT amount FROM schedules AS schd
WHERE value > (
    SELECT COUNT(value) FROM requests AS brc
    WHERE brc.level = schd.level
);


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

SELECT id FROM departments AS dept
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS mgr
    WHERE mgr.type = dept.type
);


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

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


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

SELECT name FROM items AS lne
WHERE id IN (
    SELECT id FROM sales AS inv
    WHERE inv.id = lne.id
);


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

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


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM items AS empl
    WHERE empl.code = rgn.code
);


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

SELECT id FROM employees AS emp
WHERE value > (
    SELECT MIN(amount) FROM regions AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT code FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.type = mgr.type
);


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

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


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

SELECT amount FROM managers AS mgr
WHERE value > (
    SELECT COUNT(amount) FROM sales AS schd
    WHERE schd.code = mgr.code
);


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

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


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.status = cust.status
);


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

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


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

SELECT amount FROM staff AS empl
WHERE id IN (
    SELECT id FROM items AS tsk
    WHERE tsk.type = empl.type
);


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.status = brc.status
);


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

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


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

SELECT value FROM staff AS empl
WHERE id IN (
    SELECT id FROM transactions AS schd
    WHERE schd.code = empl.code
);


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

SELECT name FROM staff AS empl
WHERE type IN (
    SELECT type FROM regions AS dept
    WHERE dept.id = empl.id
);


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

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


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

SELECT value FROM regions AS rgn
WHERE code IN (
    SELECT code FROM shipments AS rgn
    WHERE rgn.code = rgn.code
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.code = txn.code
);


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT MAX(amount) FROM staff AS empl
    WHERE empl.status = rgn.status
);


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.level = acct.level
);


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

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


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

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


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

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


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

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


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.code = mgr.code
);


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

SELECT id FROM accounts AS acct
WHERE code IN (
    SELECT code FROM orders AS inv
    WHERE inv.id = acct.id
);


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

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


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT value FROM transactions AS txn
WHERE level IN (
    SELECT level FROM branches AS inv
    WHERE inv.status = txn.status
);


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

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


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

SELECT value FROM customers AS cust
WHERE salary > (
    SELECT SUM(value) FROM invoices AS brc
    WHERE brc.id = cust.id
);


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

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


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

SELECT id FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM employees AS rgn
    WHERE rgn.status = tsk.status
);


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

SELECT salary FROM departments AS dept
WHERE id IN (
    SELECT id FROM shipments AS sale
    WHERE sale.id = dept.id
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM managers AS schd
    WHERE schd.status = inv.status
);


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

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


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

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


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = prj.code
);


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

SELECT value FROM sales AS sale
WHERE code IN (
    SELECT code FROM projects AS schd
    WHERE schd.code = sale.code
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS tsk
    WHERE tsk.level = ordr.level
);


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

SELECT value FROM projects AS prj
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.type = prj.type
);


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

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


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

SELECT amount FROM sales AS sale
WHERE type IN (
    SELECT type FROM categories AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.status = schd.status
);


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

SELECT code FROM products AS prod
WHERE value > (
    SELECT AVG(salary) FROM categories AS acct
    WHERE acct.code = prod.code
);


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

SELECT amount FROM products AS prod
WHERE type IN (
    SELECT type FROM transactions AS brc
    WHERE brc.type = prod.type
);


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

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


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

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


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

SELECT salary FROM items AS lne
WHERE code IN (
    SELECT code FROM departments AS emp
    WHERE emp.level = lne.level
);