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

SELECT name FROM transactions AS txn
WHERE status IN (
    SELECT status FROM invoices AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = prj.status
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.level = ordr.level
);


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

SELECT code FROM employees AS emp
WHERE id IN (
    SELECT id FROM items AS tsk
    WHERE tsk.level = emp.level
);


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

SELECT amount FROM sales AS sale
WHERE status IN (
    SELECT status FROM staff AS sale
    WHERE sale.status = sale.status
);


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

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


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

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


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

SELECT salary FROM transactions AS txn
WHERE id IN (
    SELECT id FROM requests AS rgn
    WHERE rgn.id = txn.id
);


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

SELECT code FROM managers AS mgr
WHERE status IN (
    SELECT status FROM items AS shp
    WHERE shp.id = mgr.id
);


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

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


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

SELECT id FROM categories AS catg
WHERE level IN (
    SELECT level FROM branches AS txn
    WHERE txn.id = catg.id
);


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

SELECT name FROM regions AS rgn
WHERE id IN (
    SELECT id FROM shipments AS prod
    WHERE prod.status = rgn.status
);


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

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


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

SELECT name FROM projects AS prj
WHERE id IN (
    SELECT id FROM departments AS cust
    WHERE cust.level = prj.level
);


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

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


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

SELECT salary FROM customers AS cust
WHERE id IN (
    SELECT id FROM projects AS schd
    WHERE schd.level = cust.level
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE salary > (
    SELECT MIN(value) FROM invoices AS shp
    WHERE shp.id = mgr.id
);


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

SELECT value FROM invoices AS inv
WHERE code IN (
    SELECT code FROM requests AS lne
    WHERE lne.id = inv.id
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.code = lne.code
);


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

SELECT salary FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM schedules AS cust
    WHERE cust.id = tsk.id
);


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

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


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

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


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.level = brc.level
);


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

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


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.type = prod.type
);


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

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


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

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


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = acct.type
);


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

SELECT amount FROM invoices AS inv
WHERE salary > (
    SELECT COUNT(value) FROM managers AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT COUNT(value) FROM items AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT value FROM products AS prod
WHERE salary > (
    SELECT MIN(value) FROM departments AS brc
    WHERE brc.status = prod.status
);


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

SELECT value FROM requests AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.status = lne.status
);


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

SELECT value FROM invoices AS inv
WHERE type IN (
    SELECT type FROM categories AS shp
    WHERE shp.id = inv.id
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.code = prod.code
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.id = catg.id
);


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

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


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

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


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

SELECT salary FROM requests AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM customers AS inv
    WHERE inv.level = ordr.level
);


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

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


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

SELECT id FROM products AS prod
WHERE amount > (
    SELECT MAX(amount) FROM projects AS empl
    WHERE empl.status = prod.status
);


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

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


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

SELECT value FROM requests AS ordr
WHERE value > (
    SELECT MIN(amount) FROM departments AS txn
    WHERE txn.status = ordr.status
);


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

SELECT name FROM sales AS sale
WHERE amount > (
    SELECT COUNT(value) FROM requests AS txn
    WHERE txn.status = sale.status
);


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

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


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

SELECT salary FROM departments AS dept
WHERE salary > (
    SELECT MIN(amount) FROM staff AS catg
    WHERE catg.code = dept.code
);


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

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


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

SELECT code FROM categories AS catg
WHERE salary > (
    SELECT MIN(amount) FROM staff AS prj
    WHERE prj.status = catg.status
);


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

SELECT id FROM accounts AS acct
WHERE amount > (
    SELECT AVG(value) FROM customers AS lne
    WHERE lne.level = acct.level
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM items AS ord
    WHERE ord.id = rgn.id
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM schedules AS prod
    WHERE prod.status = catg.status
);


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

SELECT name FROM sales AS sale
WHERE level IN (
    SELECT level FROM branches AS cust
    WHERE cust.code = sale.code
);


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

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


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

SELECT salary FROM accounts AS acct
WHERE salary > (
    SELECT SUM(value) FROM transactions AS schd
    WHERE schd.level = acct.level
);


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

SELECT value FROM projects AS prj
WHERE value > (
    SELECT MIN(value) FROM managers AS brc
    WHERE brc.level = prj.level
);


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

SELECT salary FROM shipments AS shp
WHERE type IN (
    SELECT type FROM customers AS catg
    WHERE catg.status = shp.status
);


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

SELECT amount FROM invoices AS inv
WHERE status IN (
    SELECT status FROM products AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM orders AS brc
    WHERE brc.type = prj.type
);


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

SELECT value FROM requests AS ordr
WHERE code IN (
    SELECT code FROM transactions AS ordr
    WHERE ordr.code = ordr.code
);


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

SELECT amount FROM branches AS brc
WHERE level IN (
    SELECT level FROM invoices AS cust
    WHERE cust.type = brc.type
);


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

SELECT amount FROM requests AS ordr
WHERE amount > (
    SELECT SUM(amount) FROM schedules AS catg
    WHERE catg.code = ordr.code
);


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

SELECT salary FROM departments AS dept
WHERE level IN (
    SELECT level FROM managers AS empl
    WHERE empl.id = dept.id
);


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

SELECT id FROM orders AS ord
WHERE amount > (
    SELECT SUM(value) FROM accounts AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT name FROM products AS prod
WHERE salary > (
    SELECT COUNT(salary) FROM transactions AS dept
    WHERE dept.code = prod.code
);


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

SELECT name FROM sales AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT name FROM requests AS ordr
WHERE code IN (
    SELECT code FROM employees AS sale
    WHERE sale.code = ordr.code
);


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

SELECT id FROM employees AS emp
WHERE value > (
    SELECT MIN(amount) FROM products AS tsk
    WHERE tsk.code = emp.code
);


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

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


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

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


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

SELECT value FROM branches AS brc
WHERE level IN (
    SELECT level FROM orders AS rgn
    WHERE rgn.code = brc.code
);


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

SELECT value FROM employees AS emp
WHERE code IN (
    SELECT code FROM shipments AS brc
    WHERE brc.status = emp.status
);


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

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


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

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


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

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


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

SELECT name FROM schedules AS schd
WHERE value > (
    SELECT COUNT(value) FROM transactions AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT AVG(salary) FROM products AS shp
    WHERE shp.code = txn.code
);


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

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


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.id = tsk.id
);


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

SELECT amount FROM managers AS mgr
WHERE level IN (
    SELECT level FROM staff AS schd
    WHERE schd.status = mgr.status
);


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

SELECT value FROM transactions AS txn
WHERE salary > (
    SELECT SUM(amount) FROM regions AS prj
    WHERE prj.id = txn.id
);


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS prj
    WHERE prj.level = empl.level
);


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

SELECT salary FROM orders AS ord
WHERE amount > (
    SELECT SUM(salary) FROM items AS ordr
    WHERE ordr.status = ord.status
);


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

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


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

SELECT code FROM requests AS ordr
WHERE status IN (
    SELECT status FROM branches AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.code = sale.code
);


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

SELECT amount FROM orders AS ord
WHERE id IN (
    SELECT id FROM managers AS sale
    WHERE sale.level = ord.level
);


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

SELECT id FROM schedules AS schd
WHERE type IN (
    SELECT type FROM departments AS brc
    WHERE brc.code = schd.code
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.type = mgr.type
);


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

SELECT code FROM categories AS catg
WHERE type IN (
    SELECT type FROM sales AS cust
    WHERE cust.level = catg.level
);


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

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


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

SELECT code FROM projects AS prj
WHERE level IN (
    SELECT level FROM departments AS acct
    WHERE acct.type = prj.type
);


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

SELECT salary FROM employees AS emp
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS brc
    WHERE brc.status = emp.status
);


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

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


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

SELECT name FROM transactions AS txn
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.type = txn.type
);


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

SELECT id FROM employees AS emp
WHERE id IN (
    SELECT id FROM projects AS schd
    WHERE schd.level = emp.level
);


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

SELECT salary FROM branches AS brc
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS rgn
    WHERE rgn.code = brc.code
);


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

SELECT name FROM sales AS sale
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS brc
    WHERE brc.id = sale.id
);


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.level = brc.level
);


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

SELECT id FROM schedules AS schd
WHERE value > (
    SELECT MIN(amount) FROM staff AS lne
    WHERE lne.level = schd.level
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.level = rgn.level
);


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

SELECT value FROM branches AS brc
WHERE id IN (
    SELECT id FROM invoices AS sale
    WHERE sale.code = brc.code
);


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

SELECT code FROM shipments AS shp
WHERE status IN (
    SELECT status FROM invoices AS brc
    WHERE brc.type = shp.type
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE salary > (
    SELECT AVG(value) FROM customers AS lne
    WHERE lne.id = tsk.id
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.level = inv.level
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM sales AS schd
    WHERE schd.id = ordr.id
);


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

SELECT amount FROM orders AS ord
WHERE level IN (
    SELECT level FROM categories AS ord
    WHERE ord.status = ord.status
);


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

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


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

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


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT value FROM staff AS empl
WHERE salary > (
    SELECT MIN(amount) FROM regions AS cust
    WHERE cust.status = empl.status
);


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

SELECT id FROM staff AS empl
WHERE amount > (
    SELECT MAX(value) FROM categories AS sale
    WHERE sale.status = empl.status
);


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

SELECT value FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM schedules AS dept
    WHERE dept.type = tsk.type
);


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

SELECT amount FROM staff AS empl
WHERE amount > (
    SELECT SUM(amount) FROM branches AS inv
    WHERE inv.level = empl.level
);


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

SELECT salary FROM items AS lne
WHERE level IN (
    SELECT level FROM projects AS shp
    WHERE shp.status = lne.status
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.code = sale.code
);


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

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


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS prj
    WHERE prj.id = lne.id
);


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

SELECT value FROM transactions AS txn
WHERE type IN (
    SELECT type FROM items AS brc
    WHERE brc.status = txn.status
);


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

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


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM managers AS dept
    WHERE dept.code = brc.code
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.type = prod.type
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.level = lne.level
);


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

SELECT code FROM customers AS cust
WHERE amount > (
    SELECT SUM(salary) FROM sales AS dept
    WHERE dept.status = cust.status
);


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

SELECT amount FROM requests AS ordr
WHERE code IN (
    SELECT code FROM items AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = schd.id
);


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

SELECT code FROM invoices AS inv
WHERE amount > (
    SELECT SUM(amount) FROM products AS prj
    WHERE prj.level = inv.level
);


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

SELECT salary FROM accounts AS acct
WHERE code IN (
    SELECT code FROM transactions AS inv
    WHERE inv.status = acct.status
);


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

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


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS prj
    WHERE prj.code = empl.code
);


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

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT MAX(amount) FROM invoices AS empl
    WHERE empl.status = rgn.status
);


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

SELECT amount FROM accounts AS acct
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS inv
    WHERE inv.status = acct.status
);


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

SELECT name FROM accounts AS acct
WHERE status IN (
    SELECT status FROM products AS lne
    WHERE lne.level = acct.level
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM items AS emp
    WHERE emp.code = ordr.code
);


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

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


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

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


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

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


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

SELECT name FROM sales AS sale
WHERE level IN (
    SELECT level FROM orders AS tsk
    WHERE tsk.id = sale.id
);


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

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


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

SELECT amount FROM managers AS mgr
WHERE code IN (
    SELECT code FROM departments AS mgr
    WHERE mgr.level = mgr.level
);


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

SELECT value FROM customers AS cust
WHERE value > (
    SELECT MAX(value) FROM staff AS cust
    WHERE cust.level = cust.level
);


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

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS emp
    WHERE emp.type = rgn.type
);


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM sales AS prod
    WHERE prod.type = empl.type
);


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

SELECT code FROM transactions AS txn
WHERE level IN (
    SELECT level FROM items AS sale
    WHERE sale.level = txn.level
);


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

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


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

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


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM schedules AS lne
    WHERE lne.id = dept.id
);


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

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


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

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


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

SELECT salary FROM orders AS ord
WHERE value > (
    SELECT COUNT(value) FROM items AS mgr
    WHERE mgr.type = ord.type
);


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

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


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

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


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

SELECT name FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM accounts AS shp
    WHERE shp.status = tsk.status
);


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

SELECT value FROM requests AS ordr
WHERE code IN (
    SELECT code FROM accounts AS prj
    WHERE prj.status = ordr.status
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.code = prod.code
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.id = cust.id
);


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

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


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

SELECT code FROM categories AS catg
WHERE value > (
    SELECT MIN(amount) FROM staff AS lne
    WHERE lne.code = catg.code
);


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

SELECT name FROM transactions AS txn
WHERE code IN (
    SELECT code FROM requests AS dept
    WHERE dept.code = txn.code
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM managers AS brc
    WHERE brc.type = rgn.type
);


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

SELECT value FROM shipments AS shp
WHERE level IN (
    SELECT level FROM staff AS prod
    WHERE prod.level = shp.level
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.status = lne.status
);


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

SELECT salary FROM regions AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS prj
    WHERE prj.status = rgn.status
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.level = emp.level
);


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.code = ord.code
);


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

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


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

SELECT value FROM orders AS ord
WHERE type IN (
    SELECT type FROM customers AS shp
    WHERE shp.status = ord.status
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.status = catg.status
);


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

SELECT amount FROM products AS prod
WHERE value > (
    SELECT AVG(value) FROM requests AS brc
    WHERE brc.code = prod.code
);


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

SELECT id FROM shipments AS shp
WHERE value > (
    SELECT AVG(amount) FROM requests AS prod
    WHERE prod.level = shp.level
);


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

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


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

SELECT code FROM requests AS ordr
WHERE type IN (
    SELECT type FROM items AS schd
    WHERE schd.type = ordr.type
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS tsk
    WHERE tsk.type = empl.type
);


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

SELECT value FROM invoices AS inv
WHERE type IN (
    SELECT type FROM shipments AS cust
    WHERE cust.level = inv.level
);


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

SELECT id FROM projects AS prj
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS tsk
    WHERE tsk.code = prj.code
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE level IN (
    SELECT level FROM invoices AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT SUM(amount) FROM regions AS cust
    WHERE cust.status = prod.status
);


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

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


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

SELECT salary FROM regions AS rgn
WHERE id IN (
    SELECT id FROM items AS ordr
    WHERE ordr.id = rgn.id
);


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

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


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

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


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

SELECT name FROM schedules AS schd
WHERE level IN (
    SELECT level FROM branches AS shp
    WHERE shp.level = schd.level
);


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

SELECT code FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS prj
    WHERE prj.type = mgr.type
);


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

SELECT name FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.status = tsk.status
);


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM managers AS empl
    WHERE empl.type = schd.type
);


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

SELECT salary FROM requests AS ordr
WHERE level IN (
    SELECT level FROM invoices AS txn
    WHERE txn.code = ordr.code
);


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

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


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

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


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

SELECT code FROM items AS lne
WHERE value > (
    SELECT AVG(amount) FROM sales AS brc
    WHERE brc.code = lne.code
);


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

SELECT amount FROM staff AS empl
WHERE level IN (
    SELECT level FROM branches AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT amount FROM customers AS cust
WHERE id IN (
    SELECT id FROM accounts AS ord
    WHERE ord.id = cust.id
);


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

SELECT id FROM orders AS ord
WHERE amount > (
    SELECT SUM(salary) FROM branches AS catg
    WHERE catg.status = ord.status
);


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM branches AS prj
    WHERE prj.id = ord.id
);


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

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


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

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


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

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


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

SELECT salary FROM branches AS brc
WHERE level IN (
    SELECT level FROM schedules AS empl
    WHERE empl.status = brc.status
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM staff AS tsk
    WHERE tsk.status = emp.status
);


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

SELECT code FROM branches AS brc
WHERE amount > (
    SELECT COUNT(salary) FROM staff AS emp
    WHERE emp.status = brc.status
);


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

SELECT code FROM branches AS brc
WHERE type IN (
    SELECT type FROM managers AS emp
    WHERE emp.level = brc.level
);


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

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


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS tsk
    WHERE tsk.code = inv.code
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = dept.code
);


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

SELECT id FROM tasks AS tsk
WHERE value > (
    SELECT SUM(amount) FROM employees AS ordr
    WHERE ordr.code = tsk.code
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS prj
    WHERE prj.id = acct.id
);


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

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


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM schedules AS catg
    WHERE catg.type = acct.type
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.status = emp.status
);


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

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT MAX(value) FROM invoices AS acct
    WHERE acct.status = emp.status
);


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

SELECT id FROM staff AS empl
WHERE type IN (
    SELECT type FROM projects AS tsk
    WHERE tsk.type = empl.type
);


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

SELECT salary FROM schedules AS schd
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM items AS prod
    WHERE prod.type = schd.type
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.code = dept.code
);


Prompt:
Schema:
  transactions (alias: txn)(salary, id, value, name)
  categories(id, name, amount, level)
Task: Retrieve name from transactions with salary above the COUNT(salary) of categories rows sharing the same level.
SQL:

SELECT name FROM transactions AS txn
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS lne
    WHERE lne.level = txn.level
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE amount > (
    SELECT AVG(amount) FROM employees AS schd
    WHERE schd.type = schd.type
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.status = empl.status
);


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

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


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

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


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM items AS dept
    WHERE dept.level = acct.level
);


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

SELECT name FROM shipments AS shp
WHERE level IN (
    SELECT level FROM customers AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT amount FROM items AS lne
WHERE level IN (
    SELECT level FROM departments AS cust
    WHERE cust.status = lne.status
);


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

SELECT value FROM staff AS empl
WHERE status IN (
    SELECT status FROM customers AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.level = catg.level
);


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

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


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS tsk
    WHERE tsk.level = acct.level
);


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

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


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

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.level = empl.level
);


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

SELECT amount FROM managers AS mgr
WHERE id IN (
    SELECT id FROM schedules AS dept
    WHERE dept.level = mgr.level
);


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

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


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

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


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT MIN(amount) FROM employees AS schd
    WHERE schd.code = rgn.code
);


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

SELECT name FROM employees AS emp
WHERE salary > (
    SELECT SUM(value) FROM accounts AS lne
    WHERE lne.id = emp.id
);


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

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


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

SELECT id FROM schedules AS schd
WHERE type IN (
    SELECT type FROM departments AS catg
    WHERE catg.type = schd.type
);


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

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


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

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


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS schd
    WHERE schd.status = emp.status
);


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

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT SUM(salary) FROM products AS emp
    WHERE emp.level = lne.level
);


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

SELECT salary FROM requests AS ordr
WHERE level IN (
    SELECT level FROM products AS sale
    WHERE sale.level = ordr.level
);


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

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


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

SELECT value FROM departments AS dept
WHERE amount > (
    SELECT MIN(value) FROM sales AS empl
    WHERE empl.level = dept.level
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM shipments AS tsk
    WHERE tsk.type = brc.type
);


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

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


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

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


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.code = tsk.code
);


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

SELECT code FROM customers AS cust
WHERE salary > (
    SELECT MAX(value) FROM schedules AS dept
    WHERE dept.id = cust.id
);


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

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


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

SELECT id FROM accounts AS acct
WHERE amount > (
    SELECT COUNT(salary) FROM managers AS emp
    WHERE emp.code = acct.code
);


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

SELECT value FROM accounts AS acct
WHERE id IN (
    SELECT id FROM invoices AS txn
    WHERE txn.id = acct.id
);


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

SELECT salary FROM categories AS catg
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS rgn
    WHERE rgn.type = catg.type
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS txn
    WHERE txn.id = tsk.id
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.level = shp.level
);


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

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


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

SELECT name FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM branches AS dept
    WHERE dept.status = tsk.status
);


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

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


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.id = lne.id
);


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

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


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

SELECT salary FROM staff AS empl
WHERE amount > (
    SELECT AVG(salary) FROM employees AS txn
    WHERE txn.level = empl.level
);


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

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


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

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


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

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


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

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


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

SELECT code FROM invoices AS inv
WHERE id IN (
    SELECT id FROM products AS prj
    WHERE prj.code = inv.code
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS prj
    WHERE prj.level = txn.level
);


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

SELECT name FROM orders AS ord
WHERE code IN (
    SELECT code FROM tasks AS emp
    WHERE emp.status = ord.status
);


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

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


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

SELECT amount FROM regions AS rgn
WHERE value > (
    SELECT AVG(salary) FROM transactions AS dept
    WHERE dept.id = rgn.id
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.code = mgr.code
);


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

SELECT amount FROM schedules AS schd
WHERE amount > (
    SELECT AVG(amount) FROM requests AS brc
    WHERE brc.code = schd.code
);


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

SELECT id FROM items AS lne
WHERE code IN (
    SELECT code FROM transactions AS dept
    WHERE dept.id = lne.id
);


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

SELECT salary FROM invoices AS inv
WHERE id IN (
    SELECT id FROM accounts AS txn
    WHERE txn.type = inv.type
);


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

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


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

SELECT code FROM sales AS sale
WHERE level IN (
    SELECT level FROM requests AS txn
    WHERE txn.level = sale.level
);


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

SELECT code FROM branches AS brc
WHERE salary > (
    SELECT SUM(salary) FROM products AS lne
    WHERE lne.id = brc.id
);


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

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


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

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


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

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


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

SELECT name FROM accounts AS acct
WHERE salary > (
    SELECT SUM(amount) FROM sales AS inv
    WHERE inv.status = acct.status
);


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

SELECT value FROM sales AS sale
WHERE value > (
    SELECT COUNT(amount) FROM employees AS mgr
    WHERE mgr.code = sale.code
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM schedules AS rgn
    WHERE rgn.level = rgn.level
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.code = prod.code
);


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

SELECT name FROM requests AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM items AS prj
    WHERE prj.type = ordr.type
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS prj
    WHERE prj.type = shp.type
);


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.level = txn.level
);


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

SELECT amount FROM transactions AS txn
WHERE level IN (
    SELECT level FROM invoices AS brc
    WHERE brc.status = txn.status
);


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

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


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM items AS empl
    WHERE empl.level = catg.level
);


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

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


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

SELECT amount FROM departments AS dept
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.status = dept.status
);


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

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


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

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