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

SELECT salary FROM managers AS mgr
WHERE amount > (
    SELECT AVG(salary) FROM items AS lne
    WHERE lne.id = mgr.id
);


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

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


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

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


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

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


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

SELECT name FROM managers AS mgr
WHERE code IN (
    SELECT code FROM staff AS empl
    WHERE empl.code = mgr.code
);


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT MIN(value) FROM branches AS brc
    WHERE brc.type = emp.type
);


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

SELECT code FROM transactions AS txn
WHERE code IN (
    SELECT code FROM categories AS catg
    WHERE catg.level = txn.level
);


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

SELECT id FROM accounts AS acct
WHERE amount > (
    SELECT MIN(amount) FROM items AS lne
    WHERE lne.id = acct.id
);


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

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


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

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


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

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


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

SELECT code FROM departments AS dept
WHERE value > (
    SELECT SUM(salary) FROM managers AS mgr
    WHERE mgr.status = dept.status
);


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

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


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

SELECT salary FROM staff AS empl
WHERE type IN (
    SELECT type FROM sales AS sale
    WHERE sale.id = empl.id
);


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

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


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

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


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

SELECT value FROM shipments AS shp
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.level = shp.level
);


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

SELECT amount FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = tsk.code
);


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.code = ord.code
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE status IN (
    SELECT status FROM tasks AS tsk
    WHERE tsk.level = txn.level
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.status = empl.status
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = lne.code
);


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

SELECT amount FROM invoices AS inv
WHERE id IN (
    SELECT id FROM managers AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = emp.level
);


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

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


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

SELECT value FROM products AS prod
WHERE level IN (
    SELECT level FROM branches AS brc
    WHERE brc.type = prod.type
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.id = ordr.id
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = brc.status
);


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

SELECT value FROM departments AS dept
WHERE value > (
    SELECT COUNT(value) FROM managers AS mgr
    WHERE mgr.id = dept.id
);


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

SELECT salary FROM products AS prod
WHERE id IN (
    SELECT id FROM staff AS empl
    WHERE empl.code = prod.code
);


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

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


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

SELECT value FROM invoices AS inv
WHERE type IN (
    SELECT type FROM projects AS prj
    WHERE prj.status = inv.status
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = lne.code
);


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

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


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

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


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

SELECT salary FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM items AS lne
    WHERE lne.code = tsk.code
);


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

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


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

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


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

SELECT amount FROM schedules AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS emp
    WHERE emp.status = schd.status
);


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

SELECT value FROM employees AS emp
WHERE salary > (
    SELECT SUM(salary) FROM departments AS dept
    WHERE dept.id = emp.id
);


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

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


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

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


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

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


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

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


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.type = emp.type
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.id = ord.id
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.level = rgn.level
);


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = prj.type
);


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

SELECT name FROM staff AS empl
WHERE value > (
    SELECT COUNT(value) FROM sales AS sale
    WHERE sale.code = empl.code
);


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

SELECT id FROM employees AS emp
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.status = emp.status
);


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

SELECT code FROM transactions AS txn
WHERE id IN (
    SELECT id FROM schedules AS schd
    WHERE schd.type = txn.type
);


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

SELECT code FROM schedules AS schd
WHERE status IN (
    SELECT status FROM managers AS mgr
    WHERE mgr.id = schd.id
);


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

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


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

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


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.id = inv.id
);


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

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


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

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


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

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


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

SELECT salary FROM invoices AS inv
WHERE salary > (
    SELECT AVG(salary) FROM shipments AS shp
    WHERE shp.type = inv.type
);


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

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


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

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


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

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


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

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


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.code = cust.code
);


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

SELECT value FROM regions AS rgn
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.status = rgn.status
);


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

SELECT id FROM requests AS ordr
WHERE type IN (
    SELECT type FROM branches AS brc
    WHERE brc.type = ordr.type
);


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

SELECT salary FROM products AS prod
WHERE code IN (
    SELECT code FROM branches AS brc
    WHERE brc.status = prod.status
);


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

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


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

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


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

SELECT value FROM customers AS cust
WHERE code IN (
    SELECT code FROM tasks AS tsk
    WHERE tsk.type = cust.type
);


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

SELECT name FROM orders AS ord
WHERE type IN (
    SELECT type FROM regions AS rgn
    WHERE rgn.type = ord.type
);


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

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


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

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


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

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


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

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


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

SELECT amount FROM requests AS ordr
WHERE status IN (
    SELECT status FROM schedules AS schd
    WHERE schd.type = ordr.type
);


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

SELECT value FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(value) FROM shipments AS shp
    WHERE shp.type = tsk.type
);


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

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


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

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


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

SELECT code FROM departments AS dept
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.id = dept.id
);


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

SELECT value FROM staff AS empl
WHERE code IN (
    SELECT code FROM sales AS sale
    WHERE sale.status = empl.status
);


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

SELECT amount FROM sales AS sale
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.type = sale.type
);


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

SELECT code FROM categories AS catg
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.id = catg.id
);


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

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


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

SELECT code FROM tasks AS tsk
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS txn
    WHERE txn.type = tsk.type
);


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

SELECT value FROM departments AS dept
WHERE code IN (
    SELECT code FROM schedules AS schd
    WHERE schd.level = dept.level
);


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

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


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

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


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

SELECT code FROM regions AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM staff AS empl
    WHERE empl.level = rgn.level
);


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

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


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.level = ordr.level
);


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

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


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

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


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = schd.id
);


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

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


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

SELECT code FROM employees AS emp
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS tsk
    WHERE tsk.code = emp.code
);


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

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


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

SELECT id FROM requests AS ordr
WHERE type IN (
    SELECT type FROM schedules AS schd
    WHERE schd.status = ordr.status
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = schd.status
);


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

SELECT amount FROM accounts AS acct
WHERE amount > (
    SELECT MIN(amount) FROM regions AS rgn
    WHERE rgn.id = acct.id
);


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

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


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

SELECT id FROM tasks AS tsk
WHERE value > (
    SELECT COUNT(salary) FROM items AS lne
    WHERE lne.code = tsk.code
);


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

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


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

SELECT value FROM branches AS brc
WHERE code IN (
    SELECT code FROM employees AS emp
    WHERE emp.type = brc.type
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.type = prod.type
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE amount > (
    SELECT COUNT(value) FROM requests AS ordr
    WHERE ordr.type = schd.type
);


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

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


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

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


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT value FROM invoices AS inv
WHERE salary > (
    SELECT MAX(value) FROM staff AS empl
    WHERE empl.id = inv.id
);


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

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


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

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


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

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


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.type = schd.type
);


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

SELECT salary FROM customers AS cust
WHERE type IN (
    SELECT type FROM managers AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT amount FROM accounts AS acct
WHERE amount > (
    SELECT AVG(amount) FROM orders AS ord
    WHERE ord.code = acct.code
);


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

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


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

SELECT id FROM sales AS sale
WHERE value > (
    SELECT SUM(value) FROM managers AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT id FROM categories AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM items AS lne
    WHERE lne.id = catg.id
);


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

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


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.status = prj.status
);


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

SELECT id FROM branches AS brc
WHERE value > (
    SELECT AVG(salary) FROM sales AS sale
    WHERE sale.code = brc.code
);


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

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.code = mgr.code
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = cust.status
);


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

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


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

SELECT code FROM employees AS emp
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.id = emp.id
);


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

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


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

SELECT salary FROM accounts AS acct
WHERE value > (
    SELECT MAX(amount) FROM products AS prod
    WHERE prod.code = acct.code
);


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

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


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

SELECT name FROM items AS lne
WHERE amount > (
    SELECT MIN(amount) FROM projects AS prj
    WHERE prj.level = lne.level
);


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

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


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

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


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

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


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = rgn.status
);


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.type = empl.type
);


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

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


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

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


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = ordr.level
);


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

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


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

SELECT name FROM orders AS ord
WHERE type IN (
    SELECT type FROM regions AS rgn
    WHERE rgn.status = ord.status
);


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

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


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

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


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

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


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

SELECT amount FROM sales AS sale
WHERE code IN (
    SELECT code FROM managers AS mgr
    WHERE mgr.code = sale.code
);


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

SELECT value FROM categories AS catg
WHERE value > (
    SELECT SUM(salary) FROM employees AS emp
    WHERE emp.level = catg.level
);


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

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


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

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


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

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


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT AVG(amount) FROM invoices AS inv
    WHERE inv.code = rgn.code
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.code = dept.code
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = lne.type
);


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

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


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

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


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

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


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

SELECT id FROM employees AS emp
WHERE value > (
    SELECT COUNT(value) FROM orders AS ord
    WHERE ord.id = emp.id
);


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

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


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

SELECT salary FROM items AS lne
WHERE type IN (
    SELECT type FROM sales AS sale
    WHERE sale.type = lne.type
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.status = prod.status
);


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

SELECT value FROM employees AS emp
WHERE salary > (
    SELECT SUM(amount) FROM managers AS mgr
    WHERE mgr.type = emp.type
);


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

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


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

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


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

SELECT name FROM branches AS brc
WHERE salary > (
    SELECT MAX(amount) FROM sales AS sale
    WHERE sale.code = brc.code
);


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

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


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

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


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

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = inv.type
);


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

SELECT name FROM orders AS ord
WHERE salary > (
    SELECT AVG(amount) FROM staff AS empl
    WHERE empl.status = ord.status
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = shp.code
);


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

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


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

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


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

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


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

SELECT salary FROM regions AS rgn
WHERE status IN (
    SELECT status FROM schedules AS schd
    WHERE schd.status = rgn.status
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.type = acct.type
);


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

SELECT amount FROM sales AS sale
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.status = sale.status
);


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

SELECT amount FROM schedules AS schd
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.type = schd.type
);


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

SELECT salary FROM items AS lne
WHERE value > (
    SELECT MIN(value) FROM invoices AS inv
    WHERE inv.type = lne.type
);


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

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


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

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


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

SELECT name FROM regions AS rgn
WHERE value > (
    SELECT SUM(amount) FROM requests AS ordr
    WHERE ordr.type = rgn.type
);


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

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


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

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


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

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


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

SELECT name FROM accounts AS acct
WHERE salary > (
    SELECT MAX(amount) FROM staff AS empl
    WHERE empl.type = acct.type
);


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

SELECT salary FROM shipments AS shp
WHERE type IN (
    SELECT type FROM regions AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT amount FROM invoices AS inv
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.type = inv.type
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.status = lne.status
);


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

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


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

SELECT value FROM accounts AS acct
WHERE level IN (
    SELECT level FROM sales AS sale
    WHERE sale.status = acct.status
);


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

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


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = brc.type
);


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

SELECT salary FROM departments AS dept
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.type = dept.type
);


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

SELECT id FROM branches AS brc
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.code = brc.code
);


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

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


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

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


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT MIN(salary) FROM requests AS ordr
    WHERE ordr.status = prj.status
);


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

SELECT name FROM managers AS mgr
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.status = mgr.status
);


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

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


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

SELECT amount FROM transactions AS txn
WHERE code IN (
    SELECT code FROM orders AS ord
    WHERE ord.code = txn.code
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.status = txn.status
);


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

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


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

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


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = sale.status
);


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

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


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

SELECT name FROM items AS lne
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.status = lne.status
);


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

SELECT value FROM customers AS cust
WHERE amount > (
    SELECT COUNT(salary) FROM requests AS ordr
    WHERE ordr.id = cust.id
);


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

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


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

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


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

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


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

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


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT AVG(salary) FROM branches AS brc
    WHERE brc.type = shp.type
);


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

SELECT name FROM products AS prod
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS tsk
    WHERE tsk.code = prod.code
);


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

SELECT amount FROM customers AS cust
WHERE value > (
    SELECT MAX(salary) FROM accounts AS acct
    WHERE acct.code = cust.code
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.level = tsk.level
);


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

SELECT code FROM projects AS prj
WHERE level IN (
    SELECT level FROM managers AS mgr
    WHERE mgr.id = prj.id
);


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

SELECT amount FROM sales AS sale
WHERE type IN (
    SELECT type FROM branches AS brc
    WHERE brc.status = sale.status
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = shp.id
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.type = ord.type
);


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

SELECT salary FROM projects AS prj
WHERE salary > (
    SELECT COUNT(value) FROM departments AS dept
    WHERE dept.status = prj.status
);


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

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


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

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


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.status = acct.status
);


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.id = txn.id
);


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

SELECT value FROM branches AS brc
WHERE status IN (
    SELECT status FROM managers AS mgr
    WHERE mgr.type = brc.type
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.id = lne.id
);


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.level = emp.level
);


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

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


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

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


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

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


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

SELECT amount FROM products AS prod
WHERE amount > (
    SELECT SUM(value) FROM staff AS empl
    WHERE empl.type = prod.type
);


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

SELECT name FROM invoices AS inv
WHERE salary > (
    SELECT SUM(amount) FROM schedules AS schd
    WHERE schd.id = inv.id
);


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

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


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

SELECT salary FROM orders AS ord
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.type = ord.type
);


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS shp
    WHERE shp.level = catg.level
);


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

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


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

SELECT value FROM departments AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM schedules AS schd
    WHERE schd.code = dept.code
);


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

SELECT name FROM shipments AS shp
WHERE id IN (
    SELECT id FROM invoices AS inv
    WHERE inv.id = shp.id
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.code = prod.code
);


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

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


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

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


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

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


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.type = catg.type
);


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

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


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.level = dept.level
);


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

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


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

SELECT name FROM schedules AS schd
WHERE salary > (
    SELECT MIN(salary) FROM regions AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.type = shp.type
);


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

SELECT amount FROM invoices AS inv
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.id = inv.id
);


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

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.status = empl.status
);


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

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


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = brc.level
);


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

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


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

SELECT salary FROM regions AS rgn
WHERE amount > (
    SELECT MAX(value) FROM branches AS brc
    WHERE brc.id = rgn.id
);


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

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


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

SELECT name FROM schedules AS schd
WHERE code IN (
    SELECT code FROM categories AS catg
    WHERE catg.code = schd.code
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.id = dept.id
);


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

SELECT value FROM sales AS sale
WHERE amount > (
    SELECT AVG(salary) FROM projects AS prj
    WHERE prj.level = sale.level
);


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

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


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

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT AVG(value) FROM staff AS empl
    WHERE empl.code = shp.code
);


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

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


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

SELECT id FROM departments AS dept
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.status = dept.status
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = inv.id
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.level = txn.level
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.status = prj.status
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = mgr.status
);


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

SELECT code FROM transactions AS txn
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS tsk
    WHERE tsk.id = txn.id
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = ordr.status
);


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

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


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = ordr.type
);


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

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


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = brc.status
);


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

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


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

SELECT value FROM sales AS sale
WHERE amount > (
    SELECT SUM(salary) FROM branches AS brc
    WHERE brc.code = sale.code
);


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

SELECT salary FROM customers AS cust
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.code = cust.code
);


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

SELECT amount FROM staff AS empl
WHERE id IN (
    SELECT id FROM sales AS sale
    WHERE sale.type = empl.type
);


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT AVG(value) FROM managers AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT name FROM invoices AS inv
WHERE level IN (
    SELECT level FROM tasks AS tsk
    WHERE tsk.status = inv.status
);


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

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


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

SELECT name FROM transactions AS txn
WHERE value > (
    SELECT AVG(salary) FROM products AS prod
    WHERE prod.level = txn.level
);


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

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


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

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


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

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


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = brc.code
);


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

SELECT amount FROM staff AS empl
WHERE amount > (
    SELECT SUM(value) FROM accounts AS acct
    WHERE acct.level = empl.level
);


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

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


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

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


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

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


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

SELECT salary FROM customers AS cust
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.status = cust.status
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = rgn.status
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.level = tsk.level
);


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

SELECT amount FROM shipments AS shp
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.code = shp.code
);


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT MIN(salary) FROM products AS prod
    WHERE prod.level = catg.level
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT code FROM managers AS mgr
WHERE value > (
    SELECT MAX(value) FROM orders AS ord
    WHERE ord.status = mgr.status
);