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

SELECT id FROM tasks AS tsk
WHERE amount > (
    SELECT MIN(amount) FROM sales AS sale
    WHERE sale.id = tsk.id
);


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT COUNT(value) FROM items AS lne
    WHERE lne.type = cust.type
);


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

SELECT value FROM categories AS catg
WHERE level IN (
    SELECT level FROM items AS lne
    WHERE lne.status = catg.status
);


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

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


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

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


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

SELECT code FROM categories AS catg
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.level = catg.level
);


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

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


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

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


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

SELECT code FROM schedules AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS acct
    WHERE acct.type = schd.type
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = inv.type
);


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

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


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

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


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT AVG(salary) FROM customers AS cust
    WHERE cust.level = dept.level
);


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

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


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

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


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.type = emp.type
);


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

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


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

SELECT amount FROM invoices AS inv
WHERE value > (
    SELECT MIN(salary) FROM accounts AS acct
    WHERE acct.id = inv.id
);


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

SELECT salary FROM sales AS sale
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.id = sale.id
);


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

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


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

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


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

SELECT salary FROM customers AS cust
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS inv
    WHERE inv.id = cust.id
);


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM sales AS sale
    WHERE sale.status = ord.status
);


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

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


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

SELECT name FROM departments AS dept
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.level = dept.level
);


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

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


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

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


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

SELECT id FROM schedules AS schd
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.type = schd.type
);


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

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


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

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


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

SELECT amount FROM projects AS prj
WHERE level IN (
    SELECT level FROM regions AS rgn
    WHERE rgn.type = prj.type
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.type = schd.type
);


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

SELECT value FROM schedules AS schd
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.level = schd.level
);


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

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


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

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


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

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


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

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


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

SELECT value FROM regions AS rgn
WHERE code IN (
    SELECT code FROM categories AS catg
    WHERE catg.id = rgn.id
);


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.id = brc.id
);


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

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


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

SELECT name FROM sales AS sale
WHERE salary > (
    SELECT MIN(salary) FROM requests AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT code FROM invoices AS inv
WHERE amount > (
    SELECT SUM(value) FROM shipments AS shp
    WHERE shp.level = inv.level
);


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

SELECT amount FROM regions AS rgn
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.level = rgn.level
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.id = dept.id
);


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

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


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

SELECT id FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.level = tsk.level
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = ord.status
);


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

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


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

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


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

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


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

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


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

SELECT code FROM shipments AS shp
WHERE salary > (
    SELECT MIN(amount) FROM projects AS prj
    WHERE prj.status = shp.status
);


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

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


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

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


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

SELECT amount FROM products AS prod
WHERE amount > (
    SELECT SUM(salary) FROM employees AS emp
    WHERE emp.id = prod.id
);


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

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


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

SELECT code FROM orders AS ord
WHERE salary > (
    SELECT MIN(value) FROM categories AS catg
    WHERE catg.id = ord.id
);


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

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


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

SELECT id FROM accounts AS acct
WHERE value > (
    SELECT AVG(amount) FROM schedules AS schd
    WHERE schd.id = acct.id
);


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

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


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

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


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

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


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

SELECT salary FROM shipments AS shp
WHERE value > (
    SELECT MAX(salary) FROM categories AS catg
    WHERE catg.level = shp.level
);


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

SELECT name FROM products AS prod
WHERE id IN (
    SELECT id FROM items AS lne
    WHERE lne.id = prod.id
);


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

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


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

SELECT salary FROM staff AS empl
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.level = empl.level
);


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

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


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

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


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

SELECT amount FROM orders AS ord
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.id = ord.id
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = rgn.code
);


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

SELECT value FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.level = tsk.level
);


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

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


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

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


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT MIN(amount) FROM branches AS brc
    WHERE brc.status = shp.status
);


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

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


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

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


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

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


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.code = lne.code
);


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

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


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

SELECT name FROM departments AS dept
WHERE value > (
    SELECT AVG(amount) FROM managers AS mgr
    WHERE mgr.status = dept.status
);


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

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


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

SELECT amount FROM categories AS catg
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.type = catg.type
);


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

SELECT name FROM products AS prod
WHERE salary > (
    SELECT SUM(amount) FROM projects AS prj
    WHERE prj.type = prod.type
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = inv.level
);


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

SELECT amount FROM requests AS ordr
WHERE type IN (
    SELECT type FROM staff AS empl
    WHERE empl.level = ordr.level
);


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

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


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

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


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

SELECT name FROM transactions AS txn
WHERE value > (
    SELECT MIN(value) FROM regions AS rgn
    WHERE rgn.status = txn.status
);


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

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


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

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


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

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


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

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


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

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


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = cust.status
);


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

SELECT id FROM sales AS sale
WHERE level IN (
    SELECT level FROM projects AS prj
    WHERE prj.code = sale.code
);


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

SELECT amount FROM transactions AS txn
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.status = txn.status
);


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

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


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

SELECT value FROM customers AS cust
WHERE code IN (
    SELECT code FROM requests AS ordr
    WHERE ordr.status = cust.status
);


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

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


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

SELECT id FROM accounts AS acct
WHERE status IN (
    SELECT status FROM transactions AS txn
    WHERE txn.id = acct.id
);


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

SELECT id FROM categories AS catg
WHERE amount > (
    SELECT MIN(salary) FROM orders AS ord
    WHERE ord.type = catg.type
);


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.status = schd.status
);


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

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


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.type = acct.type
);


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

SELECT amount FROM sales AS sale
WHERE status IN (
    SELECT status FROM categories AS catg
    WHERE catg.code = sale.code
);


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

SELECT id FROM accounts AS acct
WHERE code IN (
    SELECT code FROM managers AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT code FROM departments AS dept
WHERE value > (
    SELECT MIN(value) FROM tasks AS tsk
    WHERE tsk.code = dept.code
);


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

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


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

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


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.status = ordr.status
);


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

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


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

SELECT value FROM invoices AS inv
WHERE id IN (
    SELECT id FROM schedules AS schd
    WHERE schd.status = inv.status
);


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

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


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

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


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = schd.type
);


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

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


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

SELECT value FROM regions AS rgn
WHERE id IN (
    SELECT id FROM transactions AS txn
    WHERE txn.type = rgn.type
);


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

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


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

SELECT amount FROM products AS prod
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS txn
    WHERE txn.id = prod.id
);


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

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT AVG(value) FROM transactions AS txn
    WHERE txn.status = rgn.status
);


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

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


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

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


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

SELECT id FROM branches AS brc
WHERE level IN (
    SELECT level FROM staff AS empl
    WHERE empl.id = brc.id
);


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

SELECT value FROM requests AS ordr
WHERE status IN (
    SELECT status FROM sales AS sale
    WHERE sale.level = ordr.level
);


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

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


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

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


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

SELECT name FROM tasks AS tsk
WHERE amount > (
    SELECT MAX(amount) FROM sales AS sale
    WHERE sale.code = tsk.code
);


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

SELECT salary FROM staff AS empl
WHERE status IN (
    SELECT status FROM products AS prod
    WHERE prod.level = empl.level
);


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

SELECT id FROM shipments AS shp
WHERE salary > (
    SELECT MIN(salary) FROM items AS lne
    WHERE lne.id = shp.id
);


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

SELECT id FROM schedules AS schd
WHERE amount > (
    SELECT MAX(salary) FROM managers AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT value FROM orders AS ord
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.id = ord.id
);


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

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


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

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


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

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


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

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


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

SELECT amount FROM orders AS ord
WHERE salary > (
    SELECT AVG(value) FROM items AS lne
    WHERE lne.type = ord.type
);


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

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


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

SELECT name FROM orders AS ord
WHERE status IN (
    SELECT status FROM products AS prod
    WHERE prod.level = ord.level
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.type = prod.type
);


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

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


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

SELECT amount FROM managers AS mgr
WHERE id IN (
    SELECT id FROM items AS lne
    WHERE lne.type = mgr.type
);


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

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


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

SELECT name FROM products AS prod
WHERE value > (
    SELECT MIN(salary) FROM categories AS catg
    WHERE catg.type = prod.type
);


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

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


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

SELECT amount FROM products AS prod
WHERE type IN (
    SELECT type FROM staff AS empl
    WHERE empl.status = prod.status
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.type = cust.type
);


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

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


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

SELECT name FROM employees AS emp
WHERE salary > (
    SELECT MAX(value) FROM shipments AS shp
    WHERE shp.status = emp.status
);


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

SELECT value FROM departments AS dept
WHERE value > (
    SELECT AVG(salary) FROM staff AS empl
    WHERE empl.level = dept.level
);


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

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


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

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


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

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


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

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


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

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


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

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


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

SELECT code FROM sales AS sale
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS rgn
    WHERE rgn.level = sale.level
);


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

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


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

SELECT code FROM projects AS prj
WHERE salary > (
    SELECT MAX(amount) FROM schedules AS schd
    WHERE schd.level = prj.level
);


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

SELECT value FROM items AS lne
WHERE type IN (
    SELECT type FROM transactions AS txn
    WHERE txn.code = lne.code
);


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

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


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.status = sale.status
);


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

SELECT name FROM projects AS prj
WHERE type IN (
    SELECT type FROM requests AS ordr
    WHERE ordr.id = prj.id
);


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT AVG(value) FROM requests AS ordr
    WHERE ordr.code = rgn.code
);


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

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


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

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


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

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


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

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


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

SELECT value FROM products AS prod
WHERE level IN (
    SELECT level FROM transactions AS txn
    WHERE txn.type = prod.type
);


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

SELECT name FROM departments AS dept
WHERE type IN (
    SELECT type FROM tasks AS tsk
    WHERE tsk.code = dept.code
);


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

SELECT code FROM branches AS brc
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.id = brc.id
);


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

SELECT name FROM employees AS emp
WHERE id IN (
    SELECT id FROM shipments AS shp
    WHERE shp.code = emp.code
);


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

SELECT code FROM products AS prod
WHERE type IN (
    SELECT type FROM requests AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT id FROM transactions AS txn
WHERE value > (
    SELECT MAX(value) FROM regions AS rgn
    WHERE rgn.id = txn.id
);


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

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


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.status = lne.status
);


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

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


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

SELECT salary FROM departments AS dept
WHERE value > (
    SELECT AVG(amount) FROM tasks AS tsk
    WHERE tsk.level = dept.level
);


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

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


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.status = catg.status
);


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

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


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

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


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

SELECT id FROM requests AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM items AS lne
    WHERE lne.level = ordr.level
);


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

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


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.code = shp.code
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.id = cust.id
);


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

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


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

SELECT id FROM transactions AS txn
WHERE id IN (
    SELECT id FROM projects AS prj
    WHERE prj.status = txn.status
);


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

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


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

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


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

SELECT name FROM projects AS prj
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.code = prj.code
);


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

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


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

SELECT code FROM accounts AS acct
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.level = acct.level
);


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

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


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

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


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

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


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

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


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

SELECT value FROM accounts AS acct
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.type = acct.type
);


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

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


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

SELECT name FROM transactions AS txn
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.id = txn.id
);


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

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


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = empl.type
);


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

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


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

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


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

SELECT name FROM managers AS mgr
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS acct
    WHERE acct.type = mgr.type
);


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

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


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

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


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

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


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

SELECT value FROM categories AS catg
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.status = catg.status
);


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

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


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

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


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

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


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT SUM(salary) FROM branches AS brc
    WHERE brc.type = acct.type
);


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.id = prj.id
);


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

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


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

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


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

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


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

SELECT name FROM schedules AS schd
WHERE salary > (
    SELECT MAX(value) FROM orders AS ord
    WHERE ord.type = schd.type
);


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

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


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

SELECT code FROM customers AS cust
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS shp
    WHERE shp.type = cust.type
);


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

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


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

SELECT value FROM products AS prod
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.id = prod.id
);


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

SELECT salary FROM staff AS empl
WHERE salary > (
    SELECT COUNT(salary) FROM transactions AS txn
    WHERE txn.status = empl.status
);


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

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


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.status = empl.status
);


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

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


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = prj.level
);


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

SELECT salary FROM schedules AS schd
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.status = schd.status
);


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

SELECT code FROM transactions AS txn
WHERE amount > (
    SELECT MIN(amount) FROM employees AS emp
    WHERE emp.level = txn.level
);


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

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


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

SELECT name FROM regions AS rgn
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.code = rgn.code
);


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

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


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

SELECT value FROM sales AS sale
WHERE amount > (
    SELECT AVG(value) FROM employees AS emp
    WHERE emp.type = sale.type
);


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

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


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

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


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

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT SUM(value) FROM products AS prod
    WHERE prod.status = shp.status
);


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

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


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.id = catg.id
);


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

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


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

SELECT code FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.status = tsk.status
);


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

SELECT salary FROM projects AS prj
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.code = prj.code
);


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

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


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

SELECT name FROM customers AS cust
WHERE salary > (
    SELECT COUNT(value) FROM regions AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = lne.status
);


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

SELECT amount FROM invoices AS inv
WHERE salary > (
    SELECT AVG(amount) FROM projects AS prj
    WHERE prj.level = inv.level
);


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

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


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = prod.id
);


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

SELECT value FROM regions AS rgn
WHERE code IN (
    SELECT code FROM requests AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT id FROM requests AS ordr
WHERE value > (
    SELECT AVG(amount) FROM invoices AS inv
    WHERE inv.id = ordr.id
);


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

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


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

SELECT name FROM invoices AS inv
WHERE amount > (
    SELECT MIN(value) FROM requests AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = sale.id
);


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

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


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

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


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

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT MIN(amount) FROM sales AS sale
    WHERE sale.level = shp.level
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.type = tsk.type
);


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

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


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

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


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT MAX(amount) FROM orders AS ord
    WHERE ord.type = prj.type
);


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

SELECT code FROM branches AS brc
WHERE value > (
    SELECT MIN(salary) FROM tasks AS tsk
    WHERE tsk.code = brc.code
);


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

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


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

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


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

SELECT id FROM invoices AS inv
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.status = inv.status
);


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

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.status = empl.status
);


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

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


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

SELECT value FROM regions AS rgn
WHERE code IN (
    SELECT code FROM branches AS brc
    WHERE brc.type = rgn.type
);


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

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


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

SELECT amount FROM staff AS empl
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.level = empl.level
);


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = ordr.level
);


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

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


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

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


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

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


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

SELECT amount FROM departments AS dept
WHERE salary > (
    SELECT COUNT(value) FROM products AS prod
    WHERE prod.type = dept.type
);


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

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


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

SELECT code FROM sales AS sale
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.code = sale.code
);


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

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


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

SELECT name FROM schedules AS schd
WHERE value > (
    SELECT MAX(salary) FROM orders AS ord
    WHERE ord.level = schd.level
);


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

SELECT id FROM customers AS cust
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.status = cust.status
);


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

SELECT amount FROM requests AS ordr
WHERE type IN (
    SELECT type FROM transactions AS txn
    WHERE txn.code = ordr.code
);


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

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


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

SELECT id FROM projects AS prj
WHERE salary > (
    SELECT MIN(amount) FROM employees AS emp
    WHERE emp.type = prj.type
);


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

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


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

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


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

SELECT amount FROM orders AS ord
WHERE level IN (
    SELECT level FROM requests AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.type = acct.type
);


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

SELECT salary FROM branches AS brc
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.type = brc.type
);


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

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


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

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


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

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


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

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


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

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


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

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


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

SELECT code FROM shipments AS shp
WHERE value > (
    SELECT COUNT(amount) FROM sales AS sale
    WHERE sale.status = shp.status
);


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

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


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

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


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

SELECT code FROM regions AS rgn
WHERE status IN (
    SELECT status FROM products AS prod
    WHERE prod.status = rgn.status
);


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

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


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

SELECT amount FROM departments AS dept
WHERE status IN (
    SELECT status FROM employees AS emp
    WHERE emp.type = dept.type
);


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

SELECT id FROM tasks AS tsk
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS inv
    WHERE inv.code = tsk.code
);