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

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


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

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


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT MAX(amount) FROM employees AS emp
    WHERE emp.code = prj.code
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.level = dept.level
);


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

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


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

SELECT code FROM products AS prod
WHERE value > (
    SELECT SUM(value) FROM items AS lne
    WHERE lne.level = prod.level
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.id = shp.id
);


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

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


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

SELECT value FROM staff AS empl
WHERE level IN (
    SELECT level FROM managers AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.id = prj.id
);


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

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


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

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


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

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


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.id = txn.id
);


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

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


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.id = schd.id
);


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

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


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

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


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

SELECT id FROM managers AS mgr
WHERE code IN (
    SELECT code FROM categories AS catg
    WHERE catg.status = mgr.status
);


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

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


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

SELECT salary FROM branches AS brc
WHERE salary > (
    SELECT AVG(value) FROM departments AS dept
    WHERE dept.code = brc.code
);


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

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


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

SELECT amount FROM invoices AS inv
WHERE type IN (
    SELECT type FROM projects AS prj
    WHERE prj.type = inv.type
);


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

SELECT name FROM departments AS dept
WHERE value > (
    SELECT AVG(salary) FROM items AS lne
    WHERE lne.level = dept.level
);


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

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


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

SELECT name FROM products AS prod
WHERE id IN (
    SELECT id FROM staff AS empl
    WHERE empl.type = prod.type
);


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

SELECT amount FROM projects AS prj
WHERE salary > (
    SELECT MIN(salary) FROM sales AS sale
    WHERE sale.level = prj.level
);


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

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


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

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


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

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


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

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


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

SELECT amount FROM sales AS sale
WHERE type IN (
    SELECT type FROM projects AS prj
    WHERE prj.id = sale.id
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = emp.level
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = cust.level
);


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

SELECT amount FROM items AS lne
WHERE salary > (
    SELECT AVG(amount) FROM branches AS brc
    WHERE brc.status = lne.status
);


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

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


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

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


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

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


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = prj.code
);


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

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


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.type = prod.type
);


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

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


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

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


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

SELECT amount FROM regions AS rgn
WHERE id IN (
    SELECT id FROM categories AS catg
    WHERE catg.type = rgn.type
);


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

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


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

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


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

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


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

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


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

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


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

SELECT amount FROM regions AS rgn
WHERE value > (
    SELECT COUNT(value) FROM staff AS empl
    WHERE empl.level = rgn.level
);


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

SELECT value FROM projects AS prj
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS inv
    WHERE inv.status = prj.status
);


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

SELECT name FROM shipments AS shp
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT value FROM schedules AS schd
WHERE type IN (
    SELECT type FROM items AS lne
    WHERE lne.status = schd.status
);


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

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


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

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


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

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


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

SELECT name FROM categories AS catg
WHERE amount > (
    SELECT AVG(value) FROM invoices AS inv
    WHERE inv.type = catg.type
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.type = sale.type
);


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

SELECT salary FROM schedules AS schd
WHERE value > (
    SELECT MIN(amount) FROM managers AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT name FROM invoices AS inv
WHERE status IN (
    SELECT status FROM tasks AS tsk
    WHERE tsk.type = inv.type
);


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

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


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

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


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

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


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

SELECT salary FROM employees AS emp
WHERE code IN (
    SELECT code FROM sales AS sale
    WHERE sale.level = emp.level
);


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

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


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

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


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

SELECT id FROM requests AS ordr
WHERE value > (
    SELECT SUM(amount) FROM transactions AS txn
    WHERE txn.status = ordr.status
);


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

SELECT id FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM requests AS ordr
    WHERE ordr.code = tsk.code
);


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

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


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

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


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.code = sale.code
);


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

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


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

SELECT amount FROM products AS prod
WHERE id IN (
    SELECT id FROM tasks AS tsk
    WHERE tsk.code = prod.code
);


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

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


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.type = sale.type
);


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

SELECT id FROM branches AS brc
WHERE amount > (
    SELECT SUM(value) FROM transactions AS txn
    WHERE txn.type = brc.type
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.status = inv.status
);


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

SELECT value FROM products AS prod
WHERE value > (
    SELECT SUM(amount) FROM categories AS catg
    WHERE catg.id = prod.id
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = shp.type
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.type = rgn.type
);


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

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


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

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


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT MAX(value) FROM sales AS sale
    WHERE sale.type = rgn.type
);


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

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


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

SELECT id FROM schedules AS schd
WHERE level IN (
    SELECT level FROM tasks AS tsk
    WHERE tsk.code = schd.code
);


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

SELECT amount FROM regions AS rgn
WHERE code IN (
    SELECT code FROM staff AS empl
    WHERE empl.id = rgn.id
);


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

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


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

SELECT salary FROM categories AS catg
WHERE salary > (
    SELECT MIN(salary) FROM invoices AS inv
    WHERE inv.level = catg.level
);


Prompt:
Schema:
  tasks (alias: tsk)(salary, value, date, id)
  departments(value, id, level, type)
Task: Retrieve value from tasks with value above the MIN(value) of departments rows sharing the same type.
SQL:

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


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

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


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

SELECT name FROM categories AS catg
WHERE code IN (
    SELECT code FROM managers AS mgr
    WHERE mgr.level = catg.level
);


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

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


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

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


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

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


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

SELECT code FROM categories AS catg
WHERE value > (
    SELECT MIN(value) FROM sales AS sale
    WHERE sale.code = catg.code
);


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

SELECT amount FROM categories AS catg
WHERE value > (
    SELECT COUNT(value) FROM items AS lne
    WHERE lne.level = catg.level
);


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

SELECT value FROM orders AS ord
WHERE id IN (
    SELECT id FROM managers AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.level = tsk.level
);


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

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


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

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


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.type = dept.type
);


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

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


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

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


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

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


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

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


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

SELECT id FROM regions AS rgn
WHERE status IN (
    SELECT status FROM staff AS empl
    WHERE empl.level = rgn.level
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = dept.type
);


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

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


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.status = catg.status
);


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

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


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

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


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

SELECT name FROM projects AS prj
WHERE code IN (
    SELECT code FROM accounts AS acct
    WHERE acct.id = prj.id
);


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

SELECT salary FROM products AS prod
WHERE amount > (
    SELECT COUNT(value) FROM employees AS emp
    WHERE emp.level = prod.level
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.id = dept.id
);


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

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


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

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


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

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


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

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


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

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


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

SELECT amount FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.status = tsk.status
);


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

SELECT code FROM transactions AS txn
WHERE amount > (
    SELECT SUM(value) FROM shipments AS shp
    WHERE shp.code = txn.code
);


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

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


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

SELECT value FROM staff AS empl
WHERE salary > (
    SELECT MAX(value) FROM projects AS prj
    WHERE prj.id = empl.id
);


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

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


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

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


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

SELECT name FROM projects AS prj
WHERE amount > (
    SELECT MIN(value) FROM customers AS cust
    WHERE cust.type = prj.type
);


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

SELECT id FROM staff AS empl
WHERE value > (
    SELECT SUM(value) FROM transactions AS txn
    WHERE txn.code = empl.code
);


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

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


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

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


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

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


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

SELECT value FROM items AS lne
WHERE amount > (
    SELECT MIN(value) FROM sales AS sale
    WHERE sale.id = lne.id
);


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

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


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = inv.status
);


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

SELECT salary FROM managers AS mgr
WHERE level IN (
    SELECT level FROM categories AS catg
    WHERE catg.status = mgr.status
);


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

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


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

SELECT id FROM branches AS brc
WHERE value > (
    SELECT MAX(amount) FROM orders AS ord
    WHERE ord.type = brc.type
);


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

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


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

SELECT id FROM projects AS prj
WHERE amount > (
    SELECT MIN(amount) FROM customers AS cust
    WHERE cust.level = prj.level
);


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

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


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

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


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

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


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

SELECT salary FROM requests AS ordr
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS shp
    WHERE shp.code = ordr.code
);


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

SELECT id FROM branches AS brc
WHERE value > (
    SELECT MAX(value) FROM products AS prod
    WHERE prod.status = brc.status
);


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

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


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

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


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT name FROM products AS prod
WHERE id IN (
    SELECT id FROM departments AS dept
    WHERE dept.level = prod.level
);


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

SELECT name FROM employees AS emp
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.id = emp.id
);


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

SELECT name FROM schedules AS schd
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.code = schd.code
);


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

SELECT code FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS acct
    WHERE acct.type = tsk.type
);


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

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


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

SELECT name FROM staff AS empl
WHERE value > (
    SELECT AVG(salary) FROM regions AS rgn
    WHERE rgn.code = empl.code
);


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

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


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

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


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

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


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

SELECT code FROM branches AS brc
WHERE code IN (
    SELECT code FROM invoices AS inv
    WHERE inv.type = brc.type
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.level = inv.level
);


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

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


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = sale.status
);


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

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


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

SELECT name FROM items AS lne
WHERE value > (
    SELECT MIN(amount) FROM transactions AS txn
    WHERE txn.status = lne.status
);


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

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


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.code = shp.code
);


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

SELECT id FROM orders AS ord
WHERE code IN (
    SELECT code FROM employees AS emp
    WHERE emp.level = ord.level
);


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

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


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

SELECT value FROM orders AS ord
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.level = ord.level
);


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

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


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

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


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

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS acct
    WHERE acct.level = shp.level
);


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

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


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

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


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.id = prj.id
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.status = ordr.status
);


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

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


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

SELECT salary FROM branches AS brc
WHERE level IN (
    SELECT level FROM invoices AS inv
    WHERE inv.id = brc.id
);


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

SELECT value FROM sales AS sale
WHERE value > (
    SELECT MIN(salary) FROM departments AS dept
    WHERE dept.type = sale.type
);


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

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


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

SELECT name FROM employees AS emp
WHERE code IN (
    SELECT code FROM tasks AS tsk
    WHERE tsk.status = emp.status
);


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

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


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

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


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

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


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

SELECT salary FROM regions AS rgn
WHERE id IN (
    SELECT id FROM staff AS empl
    WHERE empl.code = rgn.code
);


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

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


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

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


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

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


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

SELECT value FROM requests AS ordr
WHERE code IN (
    SELECT code FROM staff AS empl
    WHERE empl.type = ordr.type
);


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

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


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

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


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

SELECT id FROM categories AS catg
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.code = catg.code
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.type = cust.type
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.level = ordr.level
);


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

SELECT value FROM categories AS catg
WHERE type IN (
    SELECT type FROM schedules AS schd
    WHERE schd.status = catg.status
);


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

SELECT value FROM staff AS empl
WHERE amount > (
    SELECT SUM(amount) FROM transactions AS txn
    WHERE txn.id = empl.id
);


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

SELECT code FROM requests AS ordr
WHERE type IN (
    SELECT type FROM tasks AS tsk
    WHERE tsk.status = ordr.status
);


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

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


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

SELECT id FROM managers AS mgr
WHERE id IN (
    SELECT id FROM sales AS sale
    WHERE sale.status = mgr.status
);


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

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


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

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


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

SELECT name FROM invoices AS inv
WHERE salary > (
    SELECT MAX(value) FROM requests AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.type = prod.type
);


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

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


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

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


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

SELECT code FROM departments AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS tsk
    WHERE tsk.status = dept.status
);


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

SELECT id FROM projects AS prj
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS acct
    WHERE acct.type = prj.type
);


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

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


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

SELECT id FROM tasks AS tsk
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS txn
    WHERE txn.level = tsk.level
);


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

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


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

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


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

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


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

SELECT value FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM staff AS empl
    WHERE empl.status = tsk.status
);


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

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


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

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


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

SELECT id FROM tasks AS tsk
WHERE salary > (
    SELECT COUNT(value) FROM employees AS emp
    WHERE emp.code = tsk.code
);


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

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


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

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


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

SELECT name FROM departments AS dept
WHERE status IN (
    SELECT status FROM branches AS brc
    WHERE brc.level = dept.level
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.level = mgr.level
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.code = tsk.code
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.id = tsk.id
);


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

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


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

SELECT value FROM departments AS dept
WHERE level IN (
    SELECT level FROM staff AS empl
    WHERE empl.id = dept.id
);


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

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS txn
    WHERE txn.code = cust.code
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE id IN (
    SELECT id FROM invoices AS inv
    WHERE inv.status = ordr.status
);


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

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


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

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


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

SELECT id FROM employees AS emp
WHERE salary > (
    SELECT SUM(amount) FROM departments AS dept
    WHERE dept.level = emp.level
);


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

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


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

SELECT amount FROM orders AS ord
WHERE level IN (
    SELECT level FROM schedules AS schd
    WHERE schd.id = ord.id
);


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

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


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

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


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

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


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

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


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

SELECT id FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = brc.status
);


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

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


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

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


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

SELECT amount FROM managers AS mgr
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.code = mgr.code
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.code = lne.code
);


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

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


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

SELECT amount FROM transactions AS txn
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.level = txn.level
);


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

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


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

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


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

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


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

SELECT amount FROM invoices AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.type = sale.type
);


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

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


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

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


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

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


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

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


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.code = ordr.code
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = catg.level
);


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

SELECT amount FROM employees AS emp
WHERE level IN (
    SELECT level FROM sales AS sale
    WHERE sale.level = emp.level
);


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

SELECT name FROM departments AS dept
WHERE value > (
    SELECT AVG(salary) FROM items AS lne
    WHERE lne.status = dept.status
);


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

SELECT id FROM shipments AS shp
WHERE id IN (
    SELECT id FROM regions AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT amount FROM categories AS catg
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.code = catg.code
);


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

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


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

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS tsk
    WHERE tsk.status = lne.status
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.level = cust.level
);


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

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


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

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


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

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


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

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


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

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


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

SELECT value FROM regions AS rgn
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.type = rgn.type
);


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

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


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

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


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.level = schd.level
);


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

SELECT name FROM items AS lne
WHERE id IN (
    SELECT id FROM invoices AS inv
    WHERE inv.type = lne.type
);


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

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


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

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


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

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


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

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


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = empl.code
);


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

SELECT name FROM customers AS cust
WHERE salary > (
    SELECT MIN(amount) FROM managers AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT value FROM regions AS rgn
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS ord
    WHERE ord.type = rgn.type
);


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

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


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

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


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

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


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

SELECT value FROM categories AS catg
WHERE id IN (
    SELECT id FROM projects AS prj
    WHERE prj.code = catg.code
);


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

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


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

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


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

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


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

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


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

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


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

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


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

SELECT code FROM managers AS mgr
WHERE amount > (
    SELECT MAX(salary) FROM regions AS rgn
    WHERE rgn.type = mgr.type
);


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

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


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT MAX(amount) FROM products AS prod
    WHERE prod.status = catg.status
);


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

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