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

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


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

SELECT salary FROM staff AS empl
WHERE value > (
    SELECT COUNT(amount) FROM sales AS sale
    WHERE sale.type = empl.type
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT MIN(value) FROM branches AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT code FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.id = mgr.id
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.id = txn.id
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS tsk
    WHERE tsk.type = prod.type
);


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

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


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

SELECT value FROM tasks AS tsk
WHERE amount > (
    SELECT AVG(value) FROM customers AS txn
    WHERE txn.type = tsk.type
);


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

SELECT salary FROM sales AS sale
WHERE code IN (
    SELECT code FROM schedules AS shp
    WHERE shp.status = sale.status
);


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

SELECT salary FROM schedules AS schd
WHERE status IN (
    SELECT status FROM items AS prj
    WHERE prj.type = schd.type
);


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

SELECT salary FROM employees AS emp
WHERE amount > (
    SELECT MIN(amount) FROM items AS ord
    WHERE ord.code = emp.code
);


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

SELECT id FROM invoices AS inv
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS dept
    WHERE dept.status = inv.status
);


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

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


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

SELECT value FROM managers AS mgr
WHERE level IN (
    SELECT level FROM customers AS schd
    WHERE schd.code = mgr.code
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS tsk
    WHERE tsk.id = empl.id
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM items AS prj
    WHERE prj.level = dept.level
);


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

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


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

SELECT salary FROM shipments AS shp
WHERE salary > (
    SELECT MIN(amount) FROM products AS tsk
    WHERE tsk.id = shp.id
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.level = schd.level
);


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

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


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM schedules AS prj
    WHERE prj.level = catg.level
);


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

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


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

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


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

SELECT value FROM projects AS prj
WHERE value > (
    SELECT MAX(amount) FROM managers AS brc
    WHERE brc.id = prj.id
);


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

SELECT value FROM categories AS catg
WHERE id IN (
    SELECT id FROM customers AS tsk
    WHERE tsk.id = catg.id
);


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

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM categories AS lne
    WHERE lne.type = cust.type
);


Prompt:
Schema:
  products (alias: prod)(date, status, amount, name)
  categories(status, code, amount, date)
Task: Find name from products where value exceeds the count of amount from categories for the same type.
SQL:

SELECT name FROM products AS prod
WHERE value > (
    SELECT COUNT(amount) FROM categories AS lne
    WHERE lne.type = prod.type
);


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

SELECT value FROM staff AS empl
WHERE value > (
    SELECT SUM(value) FROM tasks AS dept
    WHERE dept.id = empl.id
);


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

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


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

SELECT salary FROM staff AS empl
WHERE value > (
    SELECT SUM(salary) FROM accounts AS sale
    WHERE sale.code = empl.code
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.level = lne.level
);


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

SELECT value FROM orders AS ord
WHERE value > (
    SELECT MIN(value) FROM products AS lne
    WHERE lne.level = ord.level
);


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

SELECT name FROM regions AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM departments AS prj
    WHERE prj.type = rgn.type
);


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

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


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

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


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM schedules AS emp
    WHERE emp.level = tsk.level
);


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

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


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

SELECT name FROM accounts AS acct
WHERE id IN (
    SELECT id FROM departments AS cust
    WHERE cust.code = acct.code
);


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

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


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

SELECT salary FROM projects AS prj
WHERE status IN (
    SELECT status FROM customers AS mgr
    WHERE mgr.level = prj.level
);


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

SELECT id FROM orders AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS rgn
    WHERE rgn.status = ord.status
);


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

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


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

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


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

SELECT id FROM branches AS brc
WHERE value > (
    SELECT SUM(salary) FROM requests AS emp
    WHERE emp.code = brc.code
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.type = prod.type
);


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

SELECT salary FROM managers AS mgr
WHERE value > (
    SELECT SUM(value) FROM regions AS lne
    WHERE lne.id = mgr.id
);


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

SELECT amount FROM branches AS brc
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.status = brc.status
);


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

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


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

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


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

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


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM schedules AS inv
    WHERE inv.level = acct.level
);


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT AVG(value) FROM orders AS schd
    WHERE schd.id = shp.id
);


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

SELECT salary FROM projects AS prj
WHERE salary > (
    SELECT MAX(amount) FROM staff AS inv
    WHERE inv.code = prj.code
);


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

SELECT value FROM categories AS catg
WHERE level IN (
    SELECT level FROM items AS inv
    WHERE inv.id = catg.id
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.type = brc.type
);


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

SELECT name FROM orders AS ord
WHERE type IN (
    SELECT type FROM tasks AS dept
    WHERE dept.id = ord.id
);


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS acct
    WHERE acct.type = shp.type
);


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

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


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

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


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

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


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

SELECT amount FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.level = tsk.level
);


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

SELECT name FROM managers AS mgr
WHERE id IN (
    SELECT id FROM customers AS mgr
    WHERE mgr.id = mgr.id
);


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

SELECT name FROM employees AS emp
WHERE level IN (
    SELECT level FROM sales AS prod
    WHERE prod.status = emp.status
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM staff AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT salary FROM regions AS rgn
WHERE code IN (
    SELECT code FROM staff AS txn
    WHERE txn.status = rgn.status
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM staff AS dept
    WHERE dept.type = tsk.type
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.id = mgr.id
);


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

SELECT value FROM sales AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM schedules AS lne
    WHERE lne.status = sale.status
);


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

SELECT id FROM regions AS rgn
WHERE salary > (
    SELECT COUNT(value) FROM products AS inv
    WHERE inv.level = rgn.level
);


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

SELECT amount FROM orders AS ord
WHERE value > (
    SELECT MAX(salary) FROM transactions AS dept
    WHERE dept.status = ord.status
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.status = ordr.status
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.type = txn.type
);


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

SELECT amount FROM employees AS emp
WHERE type IN (
    SELECT type FROM projects AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT value FROM categories AS catg
WHERE status IN (
    SELECT status FROM departments AS rgn
    WHERE rgn.status = catg.status
);


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

SELECT amount FROM items AS lne
WHERE id IN (
    SELECT id FROM sales AS rgn
    WHERE rgn.code = lne.code
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM schedules AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT salary FROM departments AS dept
WHERE level IN (
    SELECT level FROM staff AS emp
    WHERE emp.status = dept.status
);


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

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


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

SELECT id FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.code = lne.code
);


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

SELECT code FROM staff AS empl
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM sales AS brc
    WHERE brc.level = schd.level
);


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

SELECT id FROM staff AS empl
WHERE value > (
    SELECT AVG(value) FROM shipments AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT MIN(salary) FROM sales AS lne
    WHERE lne.status = emp.status
);


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.level = emp.level
);


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

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


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

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


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.code = rgn.code
);


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

SELECT name FROM branches AS brc
WHERE amount > (
    SELECT SUM(amount) FROM staff AS sale
    WHERE sale.id = brc.id
);


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

SELECT id FROM staff AS empl
WHERE type IN (
    SELECT type FROM regions AS catg
    WHERE catg.level = empl.level
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM managers AS prod
    WHERE prod.code = empl.code
);


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

SELECT amount FROM requests AS ordr
WHERE id IN (
    SELECT id FROM sales AS tsk
    WHERE tsk.code = ordr.code
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM sales AS prod
    WHERE prod.type = ord.type
);


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

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


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

SELECT amount FROM customers AS cust
WHERE value > (
    SELECT MAX(salary) FROM shipments AS prj
    WHERE prj.level = cust.level
);


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

SELECT code FROM products AS prod
WHERE value > (
    SELECT SUM(salary) FROM sales AS txn
    WHERE txn.type = prod.type
);


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

SELECT salary FROM projects AS prj
WHERE status IN (
    SELECT status FROM staff AS cust
    WHERE cust.code = prj.code
);


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

SELECT code FROM products AS prod
WHERE value > (
    SELECT COUNT(value) FROM sales AS acct
    WHERE acct.status = prod.status
);


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

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


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

SELECT code FROM products AS prod
WHERE salary > (
    SELECT MIN(value) FROM employees AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT id FROM branches AS brc
WHERE value > (
    SELECT SUM(amount) FROM shipments AS ord
    WHERE ord.id = brc.id
);


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

SELECT salary FROM managers AS mgr
WHERE code IN (
    SELECT code FROM transactions AS mgr
    WHERE mgr.code = mgr.code
);


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

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


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS brc
    WHERE brc.type = lne.type
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM requests AS acct
    WHERE acct.type = emp.type
);


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

SELECT value FROM categories AS catg
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS sale
    WHERE sale.type = catg.type
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.id = mgr.id
);


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

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


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

SELECT code FROM accounts AS acct
WHERE value > (
    SELECT AVG(salary) FROM sales AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT salary FROM products AS prod
WHERE code IN (
    SELECT code FROM items AS dept
    WHERE dept.type = prod.type
);


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.code = prj.code
);


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM items AS prod
    WHERE prod.type = sale.type
);


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

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


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

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


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

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


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

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


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT COUNT(salary) FROM sales AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT salary FROM departments AS dept
WHERE salary > (
    SELECT SUM(amount) FROM managers AS empl
    WHERE empl.status = dept.status
);


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

SELECT value FROM accounts AS acct
WHERE salary > (
    SELECT MAX(salary) FROM regions AS cust
    WHERE cust.id = acct.id
);


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

SELECT value FROM shipments AS shp
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS tsk
    WHERE tsk.level = shp.level
);


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

SELECT id FROM invoices AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS sale
    WHERE sale.code = inv.code
);


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

SELECT salary FROM staff AS empl
WHERE id IN (
    SELECT id FROM categories AS prj
    WHERE prj.id = empl.id
);


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

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


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

SELECT value FROM schedules AS schd
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS shp
    WHERE shp.level = schd.level
);


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

SELECT amount FROM managers AS mgr
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS acct
    WHERE acct.status = mgr.status
);


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

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


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

SELECT value FROM accounts AS acct
WHERE salary > (
    SELECT MAX(value) FROM transactions AS tsk
    WHERE tsk.type = acct.type
);


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

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


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

SELECT id FROM managers AS mgr
WHERE value > (
    SELECT SUM(salary) FROM orders AS emp
    WHERE emp.level = mgr.level
);


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

SELECT code FROM schedules AS schd
WHERE status IN (
    SELECT status FROM products AS emp
    WHERE emp.type = schd.type
);


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

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


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

SELECT amount FROM employees AS emp
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.code = emp.code
);


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

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


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.type = lne.type
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.type = tsk.type
);


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT MIN(salary) FROM orders AS lne
    WHERE lne.code = prj.code
);


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

SELECT id FROM products AS prod
WHERE type IN (
    SELECT type FROM customers AS ord
    WHERE ord.id = prod.id
);


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

SELECT salary FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM schedules AS emp
    WHERE emp.level = tsk.level
);


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

SELECT id FROM invoices AS inv
WHERE value > (
    SELECT SUM(salary) FROM branches AS inv
    WHERE inv.level = inv.level
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM staff AS shp
    WHERE shp.type = prod.type
);


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

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


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

SELECT salary FROM staff AS empl
WHERE level IN (
    SELECT level FROM regions AS mgr
    WHERE mgr.type = empl.type
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM categories AS dept
    WHERE dept.type = tsk.type
);


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

SELECT name FROM staff AS empl
WHERE status IN (
    SELECT status FROM categories AS dept
    WHERE dept.code = empl.code
);


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.id = emp.id
);


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

SELECT name FROM requests AS ordr
WHERE amount > (
    SELECT MAX(amount) FROM orders AS schd
    WHERE schd.type = ordr.type
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = acct.code
);


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS prj
    WHERE prj.status = empl.status
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE salary > (
    SELECT MAX(salary) FROM customers AS acct
    WHERE acct.code = schd.code
);


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

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


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

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


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

SELECT id FROM sales AS sale
WHERE salary > (
    SELECT MAX(amount) FROM regions AS acct
    WHERE acct.code = sale.code
);


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

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


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

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


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT AVG(amount) FROM employees AS schd
    WHERE schd.type = dept.type
);


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

SELECT name FROM employees AS emp
WHERE id IN (
    SELECT id FROM sales AS mgr
    WHERE mgr.code = emp.code
);


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

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


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

SELECT salary FROM orders AS ord
WHERE level IN (
    SELECT level FROM employees AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT id FROM managers AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM items AS ord
    WHERE ord.status = mgr.status
);


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

SELECT value FROM shipments AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS txn
    WHERE txn.type = shp.type
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = inv.level
);


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

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


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

SELECT code FROM staff AS empl
WHERE type IN (
    SELECT type FROM customers AS catg
    WHERE catg.level = empl.level
);


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

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


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

SELECT amount FROM departments AS dept
WHERE type IN (
    SELECT type FROM requests AS mgr
    WHERE mgr.code = dept.code
);


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

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


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT MAX(amount) FROM shipments AS brc
    WHERE brc.code = rgn.code
);


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

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


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.level = tsk.level
);


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

SELECT code FROM shipments AS shp
WHERE value > (
    SELECT MIN(value) FROM items AS acct
    WHERE acct.level = shp.level
);


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

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


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

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


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.level = acct.level
);


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

SELECT amount FROM regions AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM requests AS prod
    WHERE prod.id = rgn.id
);


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

SELECT value FROM departments AS dept
WHERE type IN (
    SELECT type FROM projects AS empl
    WHERE empl.code = dept.code
);


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

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


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

SELECT salary FROM regions AS rgn
WHERE code IN (
    SELECT code FROM requests AS sale
    WHERE sale.id = rgn.id
);


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

SELECT value FROM managers AS mgr
WHERE value > (
    SELECT MAX(salary) FROM transactions AS ord
    WHERE ord.type = mgr.type
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.id = tsk.id
);


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

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


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

SELECT code FROM departments AS dept
WHERE status IN (
    SELECT status FROM orders AS prod
    WHERE prod.level = dept.level
);


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

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


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

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


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

SELECT salary FROM branches AS brc
WHERE status IN (
    SELECT status FROM products AS cust
    WHERE cust.level = brc.level
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM schedules AS sale
    WHERE sale.status = mgr.status
);


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

SELECT id FROM sales AS sale
WHERE type IN (
    SELECT type FROM departments AS txn
    WHERE txn.status = sale.status
);


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

SELECT salary FROM branches AS brc
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS txn
    WHERE txn.id = brc.id
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM requests AS prod
    WHERE prod.id = txn.id
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM items AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT code FROM projects AS prj
WHERE code IN (
    SELECT code FROM products AS schd
    WHERE schd.id = prj.id
);


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

SELECT id FROM invoices AS inv
WHERE type IN (
    SELECT type FROM managers AS prj
    WHERE prj.level = inv.level
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM items AS inv
    WHERE inv.id = emp.id
);


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

SELECT value FROM managers AS mgr
WHERE value > (
    SELECT MIN(salary) FROM categories AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT id FROM staff AS empl
WHERE status IN (
    SELECT status FROM items AS inv
    WHERE inv.code = empl.code
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.id = sale.id
);


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

SELECT code FROM branches AS brc
WHERE value > (
    SELECT AVG(salary) FROM accounts AS acct
    WHERE acct.level = brc.level
);


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

SELECT salary FROM departments AS dept
WHERE salary > (
    SELECT COUNT(amount) FROM shipments AS txn
    WHERE txn.type = dept.type
);


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

SELECT name FROM departments AS dept
WHERE status IN (
    SELECT status FROM employees AS prj
    WHERE prj.status = dept.status
);


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

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


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

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


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

SELECT id FROM sales AS sale
WHERE id IN (
    SELECT id FROM departments AS tsk
    WHERE tsk.id = sale.id
);


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

SELECT value FROM products AS prod
WHERE value > (
    SELECT MIN(amount) FROM staff AS txn
    WHERE txn.level = prod.level
);


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

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


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

SELECT id FROM shipments AS shp
WHERE value > (
    SELECT MAX(value) FROM tasks AS sale
    WHERE sale.type = shp.type
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT salary FROM products AS prod
WHERE level IN (
    SELECT level FROM employees AS sale
    WHERE sale.code = prod.code
);


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

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


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

SELECT value FROM items AS lne
WHERE amount > (
    SELECT MAX(salary) FROM branches AS catg
    WHERE catg.status = lne.status
);


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

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


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

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


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.id = prod.id
);


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

SELECT value FROM products AS prod
WHERE code IN (
    SELECT code FROM departments AS prj
    WHERE prj.code = prod.code
);


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

SELECT code FROM staff AS empl
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.level = empl.level
);


Prompt:
Schema:
  managers (alias: mgr)(level, amount, salary, value)
  requests(salary, amount, id, date)
Task: Find name from managers where a matching record exists in requests with 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:
  products (alias: prod)(type, value, salary, code)
  branches(date, type, amount, level)
Task: Find id from products where amount exceeds the total value from branches for the same code.
SQL:

SELECT id FROM products AS prod
WHERE amount > (
    SELECT SUM(value) FROM branches AS prj
    WHERE prj.code = prod.code
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.level = ordr.level
);


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

SELECT name FROM projects AS prj
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.code = prj.code
);


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

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


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

SELECT id FROM items AS lne
WHERE value > (
    SELECT SUM(value) FROM departments AS shp
    WHERE shp.id = lne.id
);


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.level = prj.level
);


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

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


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

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


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

SELECT value FROM transactions AS txn
WHERE level IN (
    SELECT level FROM sales AS prod
    WHERE prod.code = txn.code
);


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

SELECT value FROM managers AS mgr
WHERE id IN (
    SELECT id FROM requests AS catg
    WHERE catg.level = mgr.level
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.id = txn.id
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.code = cust.code
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM items AS shp
    WHERE shp.level = catg.level
);


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

SELECT value FROM shipments AS shp
WHERE status IN (
    SELECT status FROM managers AS catg
    WHERE catg.type = shp.type
);


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

SELECT salary FROM items AS lne
WHERE status IN (
    SELECT status FROM invoices AS catg
    WHERE catg.status = lne.status
);


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

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


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

SELECT id FROM shipments AS shp
WHERE type IN (
    SELECT type FROM employees AS dept
    WHERE dept.id = shp.id
);


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

SELECT value FROM categories AS catg
WHERE level IN (
    SELECT level FROM sales AS acct
    WHERE acct.type = catg.type
);


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

SELECT salary FROM staff AS empl
WHERE amount > (
    SELECT MAX(value) FROM accounts AS lne
    WHERE lne.level = empl.level
);


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

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


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM items AS empl
    WHERE empl.code = ord.code
);


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

SELECT salary FROM employees AS emp
WHERE status IN (
    SELECT status FROM staff AS lne
    WHERE lne.type = emp.type
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.level = acct.level
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.id = acct.id
);


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

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


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

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


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

SELECT salary FROM invoices AS inv
WHERE amount > (
    SELECT MAX(salary) FROM branches AS ordr
    WHERE ordr.level = inv.level
);


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

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


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

SELECT id FROM managers AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM products AS brc
    WHERE brc.status = mgr.status
);


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

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


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

SELECT amount FROM orders AS ord
WHERE type IN (
    SELECT type FROM regions AS txn
    WHERE txn.status = ord.status
);


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

SELECT code FROM orders AS ord
WHERE code IN (
    SELECT code FROM products AS acct
    WHERE acct.status = ord.status
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM requests AS sale
    WHERE sale.status = catg.status
);


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

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


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.type = emp.type
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.level = dept.level
);


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

SELECT name FROM invoices AS inv
WHERE amount > (
    SELECT MIN(value) FROM items AS prod
    WHERE prod.type = inv.type
);


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

SELECT id FROM departments AS dept
WHERE status IN (
    SELECT status FROM categories AS lne
    WHERE lne.status = dept.status
);


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

SELECT code FROM sales AS sale
WHERE value > (
    SELECT MIN(salary) FROM accounts AS empl
    WHERE empl.id = sale.id
);


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

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


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.status = prod.status
);


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

SELECT id FROM projects AS prj
WHERE value > (
    SELECT SUM(value) FROM schedules AS emp
    WHERE emp.id = prj.id
);


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

SELECT amount FROM requests AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS mgr
    WHERE mgr.id = ordr.id
);


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

SELECT code FROM schedules AS schd
WHERE level IN (
    SELECT level FROM requests AS txn
    WHERE txn.code = schd.code
);


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

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


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

SELECT salary FROM staff AS empl
WHERE salary > (
    SELECT COUNT(value) FROM categories AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT salary FROM products AS prod
WHERE type IN (
    SELECT type FROM regions AS empl
    WHERE empl.status = prod.status
);


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

SELECT amount FROM transactions AS txn
WHERE amount > (
    SELECT MIN(value) FROM managers AS lne
    WHERE lne.level = txn.level
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.level = tsk.level
);


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

SELECT value FROM staff AS empl
WHERE value > (
    SELECT SUM(value) FROM products AS ord
    WHERE ord.code = empl.code
);


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

SELECT value FROM regions AS rgn
WHERE amount > (
    SELECT AVG(value) FROM schedules AS sale
    WHERE sale.type = rgn.type
);


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

SELECT id FROM requests AS ordr
WHERE level IN (
    SELECT level FROM schedules AS tsk
    WHERE tsk.type = ordr.type
);


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = schd.level
);


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS prj
    WHERE prj.code = ord.code
);


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

SELECT value FROM customers AS cust
WHERE level IN (
    SELECT level FROM requests AS emp
    WHERE emp.status = cust.status
);


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

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


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

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM requests AS inv
    WHERE inv.level = shp.level
);


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

SELECT value FROM customers AS cust
WHERE amount > (
    SELECT MAX(salary) FROM schedules AS empl
    WHERE empl.status = cust.status
);


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

SELECT name FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.status = tsk.status
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = dept.type
);


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

SELECT code FROM managers AS mgr
WHERE type IN (
    SELECT type FROM categories AS txn
    WHERE txn.type = mgr.type
);


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

SELECT amount FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.id = tsk.id
);


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

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


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

SELECT value FROM managers AS mgr
WHERE level IN (
    SELECT level FROM employees AS prod
    WHERE prod.id = mgr.id
);


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

SELECT value FROM schedules AS schd
WHERE salary > (
    SELECT MAX(value) FROM projects AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = tsk.id
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.type = cust.type
);


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

SELECT value FROM orders AS ord
WHERE value > (
    SELECT AVG(value) FROM branches AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.type = shp.type
);


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

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


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

SELECT salary FROM customers AS cust
WHERE level IN (
    SELECT level FROM staff AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT value FROM employees AS emp
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS empl
    WHERE empl.level = emp.level
);


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

SELECT name FROM regions AS rgn
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS inv
    WHERE inv.level = rgn.level
);


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

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


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

SELECT id FROM staff AS empl
WHERE id IN (
    SELECT id FROM employees AS lne
    WHERE lne.type = empl.type
);


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

SELECT id FROM accounts AS acct
WHERE amount > (
    SELECT MIN(value) FROM sales AS brc
    WHERE brc.status = acct.status
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = prod.type
);


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

SELECT id FROM requests AS ordr
WHERE code IN (
    SELECT code FROM products AS ord
    WHERE ord.level = ordr.level
);


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

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM orders AS tsk
    WHERE tsk.code = cust.code
);


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

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


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

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