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

SELECT id FROM customers AS cust
WHERE salary > (
    SELECT MIN(value) FROM branches AS brc
    WHERE brc.type = cust.type
);


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

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


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

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


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

SELECT name FROM staff AS empl
WHERE value > (
    SELECT SUM(amount) FROM requests AS ordr
    WHERE ordr.id = empl.id
);


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

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


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

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


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = ordr.status
);


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

SELECT name FROM invoices AS inv
WHERE value > (
    SELECT MIN(salary) FROM branches AS brc
    WHERE brc.level = inv.level
);


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

SELECT name FROM projects AS prj
WHERE value > (
    SELECT MAX(value) FROM shipments AS shp
    WHERE shp.level = prj.level
);


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

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


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

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


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

SELECT salary FROM products AS prod
WHERE value > (
    SELECT SUM(amount) FROM transactions AS txn
    WHERE txn.status = prod.status
);


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

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


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

SELECT salary FROM employees AS emp
WHERE salary > (
    SELECT COUNT(salary) FROM items AS lne
    WHERE lne.code = emp.code
);


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

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


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

SELECT name FROM requests AS ordr
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.id = ordr.id
);


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

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


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

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


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

SELECT value FROM customers AS cust
WHERE code IN (
    SELECT code FROM branches AS brc
    WHERE brc.status = cust.status
);


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

SELECT value FROM staff AS empl
WHERE amount > (
    SELECT MAX(amount) FROM managers AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = catg.code
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.type = inv.type
);


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

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


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

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


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT MAX(amount) FROM orders AS ord
    WHERE ord.id = prod.id
);


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

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


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.id = brc.id
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = acct.status
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.code = rgn.code
);


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

SELECT id FROM departments AS dept
WHERE salary > (
    SELECT AVG(amount) FROM sales AS sale
    WHERE sale.id = dept.id
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = ordr.code
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.status = ord.status
);


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

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


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

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


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

SELECT code FROM projects AS prj
WHERE salary > (
    SELECT SUM(salary) FROM customers AS cust
    WHERE cust.type = prj.type
);


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

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


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

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


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

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


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

SELECT value FROM employees AS emp
WHERE amount > (
    SELECT AVG(value) FROM invoices AS inv
    WHERE inv.code = emp.code
);


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

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


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

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


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

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


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

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


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

SELECT name FROM managers AS mgr
WHERE type IN (
    SELECT type FROM requests AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT salary FROM transactions AS txn
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.type = txn.type
);


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

SELECT code FROM accounts AS acct
WHERE id IN (
    SELECT id FROM categories AS catg
    WHERE catg.id = acct.id
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.code = rgn.code
);


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

SELECT name FROM shipments AS shp
WHERE level IN (
    SELECT level FROM branches AS brc
    WHERE brc.status = shp.status
);


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

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM schedules AS schd
    WHERE schd.code = cust.code
);


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

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


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

SELECT id FROM products AS prod
WHERE value > (
    SELECT SUM(value) FROM regions AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.code = prod.code
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = acct.code
);


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

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


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

SELECT salary FROM items AS lne
WHERE type IN (
    SELECT type FROM branches AS brc
    WHERE brc.level = lne.level
);


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

SELECT salary FROM shipments AS shp
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS inv
    WHERE inv.status = shp.status
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = lne.type
);


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

SELECT name FROM regions AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS shp
    WHERE shp.status = rgn.status
);


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

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


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

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


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

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


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

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


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = empl.id
);


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

SELECT code FROM branches AS brc
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.status = brc.status
);


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

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


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

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


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

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


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

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


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

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


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.type = mgr.type
);


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

SELECT value FROM departments AS dept
WHERE status IN (
    SELECT status FROM sales AS sale
    WHERE sale.type = dept.type
);


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

SELECT amount FROM sales AS sale
WHERE code IN (
    SELECT code FROM transactions AS txn
    WHERE txn.type = sale.type
);


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

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


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

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


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

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


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

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT code FROM customers AS cust
WHERE salary > (
    SELECT AVG(salary) FROM projects AS prj
    WHERE prj.status = cust.status
);


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

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


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.type = txn.type
);


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

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


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

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


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT SUM(value) FROM tasks AS tsk
    WHERE tsk.level = catg.level
);


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

SELECT value FROM shipments AS shp
WHERE code IN (
    SELECT code FROM branches AS brc
    WHERE brc.id = shp.id
);


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

SELECT code FROM employees AS emp
WHERE amount > (
    SELECT AVG(value) FROM tasks AS tsk
    WHERE tsk.status = emp.status
);


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

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


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

SELECT code FROM branches AS brc
WHERE type IN (
    SELECT type FROM staff AS empl
    WHERE empl.type = brc.type
);


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

SELECT name FROM managers AS mgr
WHERE salary > (
    SELECT MAX(salary) FROM staff AS empl
    WHERE empl.id = mgr.id
);


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

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


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

SELECT value FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.status = tsk.status
);


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

SELECT name FROM sales AS sale
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.code = sale.code
);


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

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


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

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


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

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


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

SELECT code FROM categories AS catg
WHERE salary > (
    SELECT MIN(amount) FROM regions AS rgn
    WHERE rgn.id = catg.id
);


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

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


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

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


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

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


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.status = catg.status
);


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

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


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

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


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

SELECT code FROM projects AS prj
WHERE type IN (
    SELECT type FROM tasks AS tsk
    WHERE tsk.type = prj.type
);


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

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


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

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


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

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


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

SELECT id FROM staff AS empl
WHERE salary > (
    SELECT MIN(amount) FROM branches AS brc
    WHERE brc.id = empl.id
);


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

SELECT id FROM categories AS catg
WHERE value > (
    SELECT MIN(salary) FROM projects AS prj
    WHERE prj.status = catg.status
);


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

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


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

SELECT amount FROM requests AS ordr
WHERE status IN (
    SELECT status FROM products AS prod
    WHERE prod.status = ordr.status
);


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

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


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.code = tsk.code
);


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

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


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = inv.id
);


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

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


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

SELECT name FROM items AS lne
WHERE value > (
    SELECT SUM(salary) FROM categories AS catg
    WHERE catg.id = lne.id
);


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

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


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

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


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

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


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

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


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

SELECT value FROM branches AS brc
WHERE code IN (
    SELECT code FROM items AS lne
    WHERE lne.level = brc.level
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.level = cust.level
);


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

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


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

SELECT name FROM invoices AS inv
WHERE level IN (
    SELECT level FROM categories AS catg
    WHERE catg.type = inv.type
);


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

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


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

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


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

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


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

SELECT name FROM branches AS brc
WHERE value > (
    SELECT SUM(amount) FROM categories AS catg
    WHERE catg.type = brc.type
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.id = empl.id
);


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

SELECT value FROM shipments AS shp
WHERE id IN (
    SELECT id FROM accounts AS acct
    WHERE acct.level = shp.level
);


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

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


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

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


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

SELECT salary FROM staff AS empl
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.level = empl.level
);


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

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


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

SELECT code FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.code = ordr.code
);


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = ord.code
);


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

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


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

SELECT id FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.level = lne.level
);


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

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


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

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


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

SELECT code FROM sales AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS catg
    WHERE catg.code = sale.code
);


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

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


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

SELECT amount FROM accounts AS acct
WHERE value > (
    SELECT MIN(salary) FROM sales AS sale
    WHERE sale.level = acct.level
);


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

SELECT amount FROM regions AS rgn
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.status = rgn.status
);


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

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


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

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


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

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


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

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


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

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


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = acct.code
);


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

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


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

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


Prompt:
Schema:
  orders (alias: ord)(amount, type, code, value)
  staff(status, amount, salary, id)
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:
  managers (alias: mgr)(id, level, code, date)
  requests(amount, level, salary, id)
Task: Retrieve code from managers whose code is found in requests rows where type matches the outer record.
SQL:

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


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

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


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

SELECT amount FROM schedules AS schd
WHERE value > (
    SELECT SUM(value) FROM regions AS rgn
    WHERE rgn.level = schd.level
);


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

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


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

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


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

SELECT salary FROM items AS lne
WHERE level IN (
    SELECT level FROM invoices AS inv
    WHERE inv.code = lne.code
);


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

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


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

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


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

SELECT name FROM staff AS empl
WHERE type IN (
    SELECT type FROM items AS lne
    WHERE lne.code = empl.code
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = txn.code
);


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

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


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

SELECT code FROM orders AS ord
WHERE salary > (
    SELECT MAX(salary) FROM regions AS rgn
    WHERE rgn.type = ord.type
);


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

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


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

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


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

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


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT SUM(amount) FROM projects AS prj
    WHERE prj.status = acct.status
);


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

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


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

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


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

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


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

SELECT id FROM requests AS ordr
WHERE code IN (
    SELECT code FROM invoices AS inv
    WHERE inv.level = ordr.level
);


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

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


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

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


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

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


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

SELECT code FROM employees AS emp
WHERE level IN (
    SELECT level FROM managers AS mgr
    WHERE mgr.status = emp.status
);


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

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


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

SELECT salary FROM staff AS empl
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.code = empl.code
);


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

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


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

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


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

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


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

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


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

SELECT name FROM staff AS empl
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.status = empl.status
);


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

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


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

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


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

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


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

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


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.level = inv.level
);


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

SELECT amount FROM invoices AS inv
WHERE salary > (
    SELECT COUNT(value) FROM orders AS ord
    WHERE ord.level = inv.level
);


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

SELECT code FROM employees AS emp
WHERE amount > (
    SELECT AVG(amount) FROM accounts AS acct
    WHERE acct.type = emp.type
);


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

SELECT amount FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM schedules AS schd
    WHERE schd.status = tsk.status
);


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

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


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

SELECT code FROM schedules AS schd
WHERE value > (
    SELECT MAX(value) FROM regions AS rgn
    WHERE rgn.code = schd.code
);


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

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


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

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


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.code = empl.code
);


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

SELECT salary FROM orders AS ord
WHERE id IN (
    SELECT id FROM projects AS prj
    WHERE prj.id = ord.id
);


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT SUM(amount) FROM branches AS brc
    WHERE brc.status = cust.status
);


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

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


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = sale.code
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.status = dept.status
);


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

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


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

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


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

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS acct
    WHERE acct.status = shp.status
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.status = lne.status
);


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = brc.status
);


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

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


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

SELECT code FROM accounts AS acct
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.id = acct.id
);


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

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


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

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


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

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


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

SELECT amount FROM items AS lne
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.id = lne.id
);


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

SELECT value FROM tasks AS tsk
WHERE amount > (
    SELECT MAX(value) FROM managers AS mgr
    WHERE mgr.level = tsk.level
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = cust.status
);


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

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


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

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


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

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


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

SELECT salary FROM products AS prod
WHERE status IN (
    SELECT status FROM employees AS emp
    WHERE emp.code = prod.code
);


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

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


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

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


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.status = rgn.status
);


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

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


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT MAX(value) FROM items AS lne
    WHERE lne.id = prod.id
);


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

SELECT id FROM managers AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS catg
    WHERE catg.type = mgr.type
);


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

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


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

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


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

SELECT id FROM customers AS cust
WHERE level IN (
    SELECT level FROM items AS lne
    WHERE lne.status = cust.status
);


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

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


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

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


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

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


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

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.code = mgr.code
);


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

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


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

SELECT name FROM projects AS prj
WHERE value > (
    SELECT SUM(salary) FROM departments AS dept
    WHERE dept.code = prj.code
);


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

SELECT id FROM staff AS empl
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.type = empl.type
);


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

SELECT name FROM products AS prod
WHERE salary > (
    SELECT SUM(amount) FROM sales AS sale
    WHERE sale.level = prod.level
);


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

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


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

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


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

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


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

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


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

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


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

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


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

SELECT salary FROM transactions AS txn
WHERE status IN (
    SELECT status FROM sales AS sale
    WHERE sale.level = txn.level
);


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

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


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

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


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

SELECT id FROM schedules AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS catg
    WHERE catg.status = schd.status
);


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

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


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

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


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

SELECT name FROM items AS lne
WHERE level IN (
    SELECT level FROM projects AS prj
    WHERE prj.code = lne.code
);


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

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


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

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


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

SELECT amount FROM employees AS emp
WHERE value > (
    SELECT COUNT(amount) FROM categories AS catg
    WHERE catg.type = emp.type
);


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

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


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = cust.status
);


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

SELECT name FROM managers AS mgr
WHERE amount > (
    SELECT MIN(salary) FROM products AS prod
    WHERE prod.type = mgr.type
);


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

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


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

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


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

SELECT name FROM orders AS ord
WHERE amount > (
    SELECT MAX(amount) FROM branches AS brc
    WHERE brc.code = ord.code
);


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

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


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

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


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

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


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

SELECT value FROM staff AS empl
WHERE id IN (
    SELECT id FROM categories AS catg
    WHERE catg.id = empl.id
);


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

SELECT amount FROM staff AS empl
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.level = empl.level
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = schd.type
);


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

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


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = txn.code
);


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

SELECT name FROM regions AS rgn
WHERE value > (
    SELECT MAX(salary) FROM departments AS dept
    WHERE dept.type = rgn.type
);


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

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


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

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


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

SELECT code FROM projects AS prj
WHERE level IN (
    SELECT level FROM branches AS brc
    WHERE brc.id = prj.id
);


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

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


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

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


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.code = mgr.code
);


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

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


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

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


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = shp.code
);


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

SELECT amount FROM transactions AS txn
WHERE id IN (
    SELECT id FROM schedules AS schd
    WHERE schd.level = txn.level
);


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

SELECT salary FROM requests AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM products AS prod
    WHERE prod.status = ordr.status
);


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

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


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

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


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

SELECT salary FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.code = tsk.code
);


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

SELECT amount FROM departments AS dept
WHERE level IN (
    SELECT level FROM tasks AS tsk
    WHERE tsk.level = dept.level
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = inv.status
);


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

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


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT MIN(salary) FROM products AS prod
    WHERE prod.code = rgn.code
);


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

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


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

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


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

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


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

SELECT code FROM projects AS prj
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.status = prj.status
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = tsk.status
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.id = schd.id
);


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

SELECT name FROM products AS prod
WHERE amount > (
    SELECT MIN(value) FROM tasks AS tsk
    WHERE tsk.id = prod.id
);


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

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


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

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


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

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


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

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


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

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT SUM(amount) FROM departments AS dept
    WHERE dept.id = lne.id
);