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

SELECT code FROM schedules AS schd
WHERE level IN (
    SELECT level FROM shipments AS inv
    WHERE inv.id = schd.id
);


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

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


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.level = prj.level
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS prj
    WHERE prj.code = txn.code
);


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

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


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

SELECT id FROM customers AS cust
WHERE salary > (
    SELECT AVG(salary) FROM items AS lne
    WHERE lne.status = cust.status
);


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

SELECT value FROM sales AS sale
WHERE salary > (
    SELECT MAX(amount) FROM requests AS brc
    WHERE brc.type = sale.type
);


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

SELECT id FROM employees AS emp
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.code = emp.code
);


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

SELECT value FROM tasks AS tsk
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS schd
    WHERE schd.status = tsk.status
);


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

SELECT code FROM accounts AS acct
WHERE value > (
    SELECT MIN(value) FROM schedules AS shp
    WHERE shp.type = acct.type
);


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

SELECT code FROM schedules AS schd
WHERE type IN (
    SELECT type FROM invoices AS prj
    WHERE prj.code = schd.code
);


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

SELECT code FROM departments AS dept
WHERE salary > (
    SELECT SUM(amount) FROM employees AS ord
    WHERE ord.status = dept.status
);


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

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


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

SELECT value FROM invoices AS inv
WHERE salary > (
    SELECT MAX(value) FROM branches AS catg
    WHERE catg.status = inv.status
);


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

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


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

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


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

SELECT name FROM customers AS cust
WHERE code IN (
    SELECT code FROM regions AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM managers AS rgn
    WHERE rgn.level = prj.level
);


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

SELECT id FROM invoices AS inv
WHERE status IN (
    SELECT status FROM categories AS tsk
    WHERE tsk.id = inv.id
);


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

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


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

SELECT code FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM categories AS inv
    WHERE inv.level = tsk.level
);


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

SELECT salary FROM staff AS empl
WHERE type IN (
    SELECT type FROM requests AS empl
    WHERE empl.status = empl.status
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.code = acct.code
);


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

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


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

SELECT value FROM projects AS prj
WHERE salary > (
    SELECT MIN(value) FROM orders AS txn
    WHERE txn.level = prj.level
);


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

SELECT amount FROM sales AS sale
WHERE type IN (
    SELECT type FROM requests AS ord
    WHERE ord.code = sale.code
);


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

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


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

SELECT code FROM schedules AS schd
WHERE code IN (
    SELECT code FROM branches AS cust
    WHERE cust.level = schd.level
);


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

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


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

SELECT name FROM staff AS empl
WHERE value > (
    SELECT AVG(value) FROM orders AS ord
    WHERE ord.id = empl.id
);


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

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


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

SELECT code FROM departments AS dept
WHERE id IN (
    SELECT id FROM shipments AS inv
    WHERE inv.type = dept.type
);


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS tsk
    WHERE tsk.type = empl.type
);


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

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


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM sales AS cust
    WHERE cust.code = brc.code
);


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

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


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

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


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

SELECT code FROM branches AS brc
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS lne
    WHERE lne.level = brc.level
);


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

SELECT value FROM staff AS empl
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.status = empl.status
);


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

SELECT name FROM invoices AS inv
WHERE amount > (
    SELECT SUM(value) FROM departments AS sale
    WHERE sale.status = inv.status
);


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.code = brc.code
);


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

SELECT code FROM accounts AS acct
WHERE id IN (
    SELECT id FROM sales AS txn
    WHERE txn.id = acct.id
);


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

SELECT amount FROM requests AS ordr
WHERE type IN (
    SELECT type FROM branches AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT id FROM projects AS prj
WHERE level IN (
    SELECT level FROM shipments AS cust
    WHERE cust.type = prj.type
);


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

SELECT value FROM requests AS ordr
WHERE value > (
    SELECT COUNT(value) FROM staff AS prod
    WHERE prod.id = ordr.id
);


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

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


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

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


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

SELECT amount FROM managers AS mgr
WHERE amount > (
    SELECT SUM(value) FROM requests AS inv
    WHERE inv.status = mgr.status
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM items AS catg
    WHERE catg.id = prod.id
);


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

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


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

SELECT name FROM regions AS rgn
WHERE id IN (
    SELECT id FROM customers AS tsk
    WHERE tsk.id = rgn.id
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.status = mgr.status
);


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.code = dept.code
);


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

SELECT name FROM departments AS dept
WHERE id IN (
    SELECT id FROM orders AS lne
    WHERE lne.code = dept.code
);


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

SELECT id FROM departments AS dept
WHERE salary > (
    SELECT COUNT(value) FROM transactions AS prj
    WHERE prj.type = dept.type
);


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

SELECT amount FROM shipments AS shp
WHERE id IN (
    SELECT id FROM items AS lne
    WHERE lne.type = shp.type
);


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

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


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

SELECT code FROM branches AS brc
WHERE value > (
    SELECT COUNT(value) FROM projects AS prj
    WHERE prj.status = brc.status
);


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

SELECT salary FROM branches AS brc
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS inv
    WHERE inv.code = brc.code
);


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS tsk
    WHERE tsk.type = rgn.type
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.type = mgr.type
);


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

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


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

SELECT amount FROM regions AS rgn
WHERE code IN (
    SELECT code FROM tasks AS acct
    WHERE acct.id = rgn.id
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT AVG(salary) FROM sales AS ord
    WHERE ord.id = txn.id
);


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM items AS mgr
    WHERE mgr.id = sale.id
);


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

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


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

SELECT amount FROM requests AS ordr
WHERE level IN (
    SELECT level FROM tasks AS shp
    WHERE shp.code = ordr.code
);


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

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


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM sales AS dept
    WHERE dept.type = empl.type
);


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

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


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

SELECT id FROM managers AS mgr
WHERE code IN (
    SELECT code FROM regions AS ord
    WHERE ord.status = mgr.status
);


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

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


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.status = catg.status
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.status = mgr.status
);


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

SELECT code FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.type = brc.type
);


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

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


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.level = sale.level
);


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

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


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

SELECT amount FROM schedules AS schd
WHERE id IN (
    SELECT id FROM branches AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.code = inv.code
);


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

SELECT value FROM customers AS cust
WHERE amount > (
    SELECT MAX(amount) FROM departments AS empl
    WHERE empl.type = cust.type
);


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

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


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

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


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

SELECT salary FROM employees AS emp
WHERE status IN (
    SELECT status FROM items AS rgn
    WHERE rgn.id = emp.id
);


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

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


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

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


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

SELECT code FROM departments AS dept
WHERE level IN (
    SELECT level FROM managers AS catg
    WHERE catg.status = dept.status
);


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

SELECT id FROM requests AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM items AS empl
    WHERE empl.type = ordr.type
);


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

SELECT code FROM staff AS empl
WHERE status IN (
    SELECT status FROM employees AS lne
    WHERE lne.code = empl.code
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT id FROM regions AS rgn
WHERE status IN (
    SELECT status FROM requests AS tsk
    WHERE tsk.status = rgn.status
);


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

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


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

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


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

SELECT value FROM departments AS dept
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS prod
    WHERE prod.status = dept.status
);


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

SELECT name FROM categories AS catg
WHERE id IN (
    SELECT id FROM sales AS cust
    WHERE cust.level = catg.level
);


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

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


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

SELECT amount FROM schedules AS schd
WHERE amount > (
    SELECT MIN(salary) FROM projects AS txn
    WHERE txn.level = schd.level
);


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

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


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

SELECT code FROM staff AS empl
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS prj
    WHERE prj.code = empl.code
);


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

SELECT value FROM customers AS cust
WHERE type IN (
    SELECT type FROM sales AS cust
    WHERE cust.level = cust.level
);


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

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


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

SELECT value FROM customers AS cust
WHERE type IN (
    SELECT type FROM requests AS cust
    WHERE cust.type = cust.type
);


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

SELECT amount FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM customers AS inv
    WHERE inv.code = tsk.code
);


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

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


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

SELECT value FROM products AS prod
WHERE code IN (
    SELECT code FROM invoices AS schd
    WHERE schd.level = prod.level
);


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

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


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

SELECT name FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM requests AS schd
    WHERE schd.level = mgr.level
);


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

SELECT salary FROM regions AS rgn
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.id = rgn.id
);


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

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


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.level = prj.level
);


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

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


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM items AS emp
    WHERE emp.code = brc.code
);


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

SELECT name FROM transactions AS txn
WHERE value > (
    SELECT AVG(salary) FROM managers AS catg
    WHERE catg.type = txn.type
);


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

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


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

SELECT id FROM orders AS ord
WHERE value > (
    SELECT SUM(amount) FROM shipments AS lne
    WHERE lne.type = ord.type
);


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

SELECT name FROM branches AS brc
WHERE status IN (
    SELECT status FROM accounts AS ord
    WHERE ord.code = brc.code
);


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

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


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

SELECT value FROM shipments AS shp
WHERE type IN (
    SELECT type FROM managers AS cust
    WHERE cust.code = shp.code
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.level = rgn.level
);


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

SELECT salary FROM regions AS rgn
WHERE value > (
    SELECT SUM(salary) FROM branches AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM sales AS ord
    WHERE ord.id = emp.id
);


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

SELECT id FROM invoices AS inv
WHERE salary > (
    SELECT MAX(value) FROM products AS prj
    WHERE prj.code = inv.code
);


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

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


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

SELECT id FROM items AS lne
WHERE status IN (
    SELECT status FROM tasks AS ord
    WHERE ord.type = lne.type
);


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

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


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

SELECT value FROM requests AS ordr
WHERE value > (
    SELECT AVG(value) FROM branches AS lne
    WHERE lne.type = ordr.type
);


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

SELECT id FROM regions AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM products AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.id = empl.id
);


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

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


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT MAX(value) FROM managers AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM schedules AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.type = inv.type
);


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

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


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

SELECT id FROM customers AS cust
WHERE salary > (
    SELECT AVG(value) FROM items AS acct
    WHERE acct.level = cust.level
);


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

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


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

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


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.level = schd.level
);


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

SELECT value FROM sales AS sale
WHERE value > (
    SELECT MAX(value) FROM products AS dept
    WHERE dept.level = sale.level
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM managers AS schd
    WHERE schd.type = shp.type
);


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

SELECT code FROM products AS prod
WHERE salary > (
    SELECT COUNT(amount) FROM sales AS rgn
    WHERE rgn.code = prod.code
);


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

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


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

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


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

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


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

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


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

SELECT code FROM transactions AS txn
WHERE code IN (
    SELECT code FROM staff AS shp
    WHERE shp.id = txn.id
);


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

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


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

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


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.level = prj.level
);


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

SELECT name FROM customers AS cust
WHERE salary > (
    SELECT SUM(salary) FROM staff AS prod
    WHERE prod.level = cust.level
);


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

SELECT id FROM products AS prod
WHERE level IN (
    SELECT level FROM schedules AS tsk
    WHERE tsk.id = prod.id
);


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT MIN(value) FROM schedules AS rgn
    WHERE rgn.id = emp.id
);


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

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


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

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


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM managers AS rgn
    WHERE rgn.type = prod.type
);


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

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


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

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


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

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


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

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


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

SELECT id FROM regions AS rgn
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS dept
    WHERE dept.code = rgn.code
);


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

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


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

SELECT name FROM requests AS ordr
WHERE amount > (
    SELECT MAX(salary) FROM employees AS rgn
    WHERE rgn.code = ordr.code
);


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

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


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

SELECT value FROM sales AS sale
WHERE level IN (
    SELECT level FROM projects AS inv
    WHERE inv.level = sale.level
);


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

SELECT value FROM orders AS ord
WHERE amount > (
    SELECT MAX(amount) FROM customers AS schd
    WHERE schd.code = ord.code
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT code FROM managers AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM schedules AS catg
    WHERE catg.status = mgr.status
);


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

SELECT salary FROM managers AS mgr
WHERE value > (
    SELECT SUM(salary) FROM products AS schd
    WHERE schd.type = mgr.type
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.type = ord.type
);


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

SELECT name FROM invoices AS inv
WHERE salary > (
    SELECT SUM(value) FROM sales AS schd
    WHERE schd.code = inv.code
);


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

SELECT id FROM regions AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM employees AS sale
    WHERE sale.code = rgn.code
);


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

SELECT id FROM requests AS ordr
WHERE amount > (
    SELECT SUM(amount) FROM schedules AS ord
    WHERE ord.level = ordr.level
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.code = prj.code
);


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

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


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

SELECT code FROM schedules AS schd
WHERE value > (
    SELECT MAX(value) FROM departments AS shp
    WHERE shp.type = schd.type
);


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

SELECT salary FROM tasks AS tsk
WHERE salary > (
    SELECT MAX(salary) FROM categories AS dept
    WHERE dept.code = tsk.code
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.id = shp.id
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.level = sale.level
);


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT amount FROM departments AS dept
WHERE status IN (
    SELECT status FROM products AS rgn
    WHERE rgn.id = dept.id
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.level = shp.level
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.level = dept.level
);


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

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


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

SELECT code FROM shipments AS shp
WHERE type IN (
    SELECT type FROM managers AS acct
    WHERE acct.code = shp.code
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.code = schd.code
);


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

SELECT salary FROM categories AS catg
WHERE code IN (
    SELECT code FROM items AS mgr
    WHERE mgr.code = catg.code
);


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

SELECT amount FROM accounts AS acct
WHERE value > (
    SELECT MAX(amount) FROM customers AS ord
    WHERE ord.level = acct.level
);


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

SELECT amount FROM transactions AS txn
WHERE id IN (
    SELECT id FROM regions AS schd
    WHERE schd.status = txn.status
);


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT SUM(amount) FROM sales AS brc
    WHERE brc.code = catg.code
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.level = ordr.level
);


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

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


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

SELECT value FROM transactions AS txn
WHERE code IN (
    SELECT code FROM tasks AS ord
    WHERE ord.code = txn.code
);


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

SELECT value FROM products AS prod
WHERE code IN (
    SELECT code FROM customers AS empl
    WHERE empl.status = prod.status
);


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

SELECT value FROM branches AS brc
WHERE status IN (
    SELECT status FROM invoices AS dept
    WHERE dept.status = brc.status
);


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

SELECT value FROM categories AS catg
WHERE level IN (
    SELECT level FROM managers AS ord
    WHERE ord.code = catg.code
);


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

SELECT value FROM orders AS ord
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS catg
    WHERE catg.type = ord.type
);


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

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


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT AVG(value) FROM transactions AS acct
    WHERE acct.type = prj.type
);


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

SELECT code FROM schedules AS schd
WHERE salary > (
    SELECT SUM(amount) FROM staff AS prod
    WHERE prod.level = schd.level
);


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

SELECT name FROM invoices AS inv
WHERE level IN (
    SELECT level FROM sales AS emp
    WHERE emp.status = inv.status
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM staff AS shp
    WHERE shp.status = catg.status
);


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT SUM(salary) FROM items AS tsk
    WHERE tsk.level = rgn.level
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.type = schd.type
);


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

SELECT value FROM items AS lne
WHERE status IN (
    SELECT status FROM products AS ordr
    WHERE ordr.level = lne.level
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.type = inv.type
);


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

SELECT code FROM employees AS emp
WHERE amount > (
    SELECT SUM(value) FROM staff AS tsk
    WHERE tsk.type = emp.type
);


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

SELECT code FROM departments AS dept
WHERE value > (
    SELECT COUNT(amount) FROM items AS brc
    WHERE brc.id = dept.id
);


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

SELECT code FROM staff AS empl
WHERE status IN (
    SELECT status FROM managers AS brc
    WHERE brc.level = empl.level
);


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

SELECT value FROM categories AS catg
WHERE id IN (
    SELECT id FROM sales AS sale
    WHERE sale.status = catg.status
);


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

SELECT amount FROM accounts AS acct
WHERE salary > (
    SELECT AVG(value) FROM categories AS shp
    WHERE shp.code = acct.code
);


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

SELECT name FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.type = mgr.type
);


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

SELECT value FROM requests AS ordr
WHERE status IN (
    SELECT status FROM staff AS sale
    WHERE sale.id = ordr.id
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.status = txn.status
);


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT SUM(value) FROM tasks AS lne
    WHERE lne.code = acct.code
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS tsk
    WHERE tsk.type = catg.type
);


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

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


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

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


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.status = catg.status
);


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

SELECT code FROM invoices AS inv
WHERE value > (
    SELECT SUM(amount) FROM products AS acct
    WHERE acct.id = inv.id
);


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

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


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT value FROM managers AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM schedules AS dept
    WHERE dept.type = mgr.type
);


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

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


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

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


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

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


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM items AS ord
    WHERE ord.status = catg.status
);


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

SELECT name FROM invoices AS inv
WHERE value > (
    SELECT COUNT(amount) FROM branches AS brc
    WHERE brc.status = inv.status
);


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.id = ord.id
);


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.id = sale.id
);


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

SELECT salary FROM projects AS prj
WHERE amount > (
    SELECT SUM(value) FROM orders AS shp
    WHERE shp.id = prj.id
);


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

SELECT salary FROM orders AS ord
WHERE level IN (
    SELECT level FROM invoices AS ord
    WHERE ord.status = ord.status
);


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

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


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

SELECT amount FROM invoices AS inv
WHERE level IN (
    SELECT level FROM sales AS emp
    WHERE emp.status = inv.status
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS prod
    WHERE prod.code = emp.code
);


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

SELECT salary FROM schedules AS schd
WHERE code IN (
    SELECT code FROM requests AS catg
    WHERE catg.type = schd.type
);


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

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


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

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


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

SELECT amount FROM invoices AS inv
WHERE code IN (
    SELECT code FROM shipments AS emp
    WHERE emp.code = inv.code
);


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

SELECT name FROM managers AS mgr
WHERE value > (
    SELECT AVG(salary) FROM categories AS inv
    WHERE inv.code = mgr.code
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT MIN(salary) FROM departments AS mgr
    WHERE mgr.id = txn.id
);


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

SELECT id FROM branches AS brc
WHERE amount > (
    SELECT MIN(amount) FROM items AS rgn
    WHERE rgn.status = brc.status
);


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

SELECT code FROM customers AS cust
WHERE status IN (
    SELECT status FROM tasks AS acct
    WHERE acct.id = cust.id
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.code = inv.code
);


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

SELECT salary FROM transactions AS txn
WHERE status IN (
    SELECT status FROM departments AS sale
    WHERE sale.code = txn.code
);


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

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


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

SELECT name FROM transactions AS txn
WHERE id IN (
    SELECT id FROM invoices AS prod
    WHERE prod.status = txn.status
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = catg.id
);


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

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


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

SELECT amount FROM invoices AS inv
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.level = inv.level
);


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

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


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

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


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

SELECT name FROM schedules AS schd
WHERE amount > (
    SELECT MAX(amount) FROM departments AS prod
    WHERE prod.status = schd.status
);


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

SELECT name FROM projects AS prj
WHERE value > (
    SELECT COUNT(amount) FROM accounts AS rgn
    WHERE rgn.code = prj.code
);


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

SELECT code FROM regions AS rgn
WHERE type IN (
    SELECT type FROM projects AS emp
    WHERE emp.status = rgn.status
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM sales AS prod
    WHERE prod.level = txn.level
);


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

SELECT name FROM items AS lne
WHERE value > (
    SELECT SUM(amount) FROM accounts AS sale
    WHERE sale.status = lne.status
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS brc
    WHERE brc.id = emp.id
);


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

SELECT amount FROM projects AS prj
WHERE amount > (
    SELECT MIN(salary) FROM categories AS ordr
    WHERE ordr.id = prj.id
);


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

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


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

SELECT id FROM employees AS emp
WHERE id IN (
    SELECT id FROM products AS tsk
    WHERE tsk.id = emp.id
);


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

SELECT value FROM customers AS cust
WHERE type IN (
    SELECT type FROM managers AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT value FROM sales AS sale
WHERE value > (
    SELECT MIN(value) FROM projects AS cust
    WHERE cust.status = sale.status
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM managers AS lne
    WHERE lne.status = shp.status
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.type = schd.type
);


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

SELECT id FROM managers AS mgr
WHERE id IN (
    SELECT id FROM sales AS cust
    WHERE cust.type = mgr.type
);


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

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


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

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


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

SELECT id FROM staff AS empl
WHERE value > (
    SELECT SUM(amount) FROM products AS mgr
    WHERE mgr.level = empl.level
);


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

SELECT name FROM transactions AS txn
WHERE type IN (
    SELECT type FROM accounts AS dept
    WHERE dept.id = txn.id
);


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

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


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

SELECT value FROM managers AS mgr
WHERE amount > (
    SELECT SUM(value) FROM categories AS inv
    WHERE inv.level = mgr.level
);


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

SELECT value FROM regions AS rgn
WHERE code IN (
    SELECT code FROM tasks AS emp
    WHERE emp.type = rgn.type
);


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

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


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

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


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

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


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

SELECT salary FROM categories AS catg
WHERE id IN (
    SELECT id FROM customers AS shp
    WHERE shp.status = catg.status
);


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

SELECT value FROM orders AS ord
WHERE id IN (
    SELECT id FROM departments AS prod
    WHERE prod.id = ord.id
);


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

SELECT amount FROM schedules AS schd
WHERE salary > (
    SELECT AVG(value) FROM departments AS mgr
    WHERE mgr.code = schd.code
);


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

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


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

SELECT salary FROM orders AS ord
WHERE level IN (
    SELECT level FROM transactions AS shp
    WHERE shp.status = ord.status
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.level = acct.level
);


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

SELECT amount FROM transactions AS txn
WHERE type IN (
    SELECT type FROM managers AS dept
    WHERE dept.status = txn.status
);


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

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


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

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


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM staff AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT code FROM invoices AS inv
WHERE amount > (
    SELECT MAX(amount) FROM categories AS ord
    WHERE ord.type = inv.type
);


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

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


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

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


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

SELECT amount FROM shipments AS shp
WHERE status IN (
    SELECT status FROM transactions AS lne
    WHERE lne.code = shp.code
);


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

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


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

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


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

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


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

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


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT amount FROM orders AS ord
WHERE value > (
    SELECT COUNT(salary) FROM branches AS prod
    WHERE prod.code = ord.code
);