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

SELECT amount FROM categories AS catg
WHERE code IN (
    SELECT code FROM branches AS brc
    WHERE brc.code = catg.code
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = txn.level
);


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

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


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

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


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.code = brc.code
);


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

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


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

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


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

SELECT amount FROM orders AS ord
WHERE id IN (
    SELECT id FROM tasks AS tsk
    WHERE tsk.level = ord.level
);


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

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


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

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


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

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


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.code = mgr.code
);


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

SELECT id FROM items AS lne
WHERE type IN (
    SELECT type FROM accounts AS acct
    WHERE acct.id = lne.id
);


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.type = schd.type
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.type = emp.type
);


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

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


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

SELECT value FROM products AS prod
WHERE salary > (
    SELECT MAX(salary) FROM projects AS prj
    WHERE prj.status = prod.status
);


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

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


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.status = acct.status
);


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

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


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

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


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

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


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

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


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.type = lne.type
);


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

SELECT value FROM items AS lne
WHERE code IN (
    SELECT code FROM products AS prod
    WHERE prod.type = lne.type
);


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

SELECT salary FROM branches AS brc
WHERE code IN (
    SELECT code FROM requests AS ordr
    WHERE ordr.code = brc.code
);


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

SELECT id FROM invoices AS inv
WHERE amount > (
    SELECT SUM(salary) FROM sales AS sale
    WHERE sale.status = inv.status
);


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

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


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

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


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

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


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

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


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

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


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.level = shp.level
);