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

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


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

SELECT name FROM transactions AS txn
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS brc
    WHERE brc.type = txn.type
);


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

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


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

SELECT amount FROM categories AS catg
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.level = catg.level
);


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

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


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

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


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

SELECT value FROM managers AS mgr
WHERE status IN (
    SELECT status FROM projects AS tsk
    WHERE tsk.status = mgr.status
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.status = brc.status
);


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

SELECT value FROM employees AS emp
WHERE status IN (
    SELECT status FROM tasks AS sale
    WHERE sale.id = emp.id
);


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

SELECT code FROM products AS prod
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT name FROM orders AS ord
WHERE type IN (
    SELECT type FROM categories AS mgr
    WHERE mgr.code = ord.code
);


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

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


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.type = cust.type
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM sales AS emp
    WHERE emp.type = mgr.type
);


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

SELECT name FROM items AS lne
WHERE status IN (
    SELECT status FROM employees AS ord
    WHERE ord.id = lne.id
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS brc
    WHERE brc.code = schd.code
);


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.id = emp.id
);


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

SELECT code FROM staff AS empl
WHERE code IN (
    SELECT code FROM invoices AS brc
    WHERE brc.level = empl.level
);


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

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


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

SELECT salary FROM departments AS dept
WHERE level IN (
    SELECT level FROM branches AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.code = acct.code
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.code = catg.code
);


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

SELECT code FROM orders AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS emp
    WHERE emp.type = ord.type
);


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

SELECT id FROM regions AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM customers AS txn
    WHERE txn.code = rgn.code
);


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

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


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT amount FROM items AS lne
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.type = lne.type
);


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

SELECT id FROM branches AS brc
WHERE type IN (
    SELECT type FROM managers AS empl
    WHERE empl.status = brc.status
);


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

SELECT code FROM invoices AS inv
WHERE amount > (
    SELECT MAX(value) FROM managers AS prod
    WHERE prod.status = inv.status
);


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

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


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.code = brc.code
);


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

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


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.id = rgn.id
);


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

SELECT name FROM shipments AS shp
WHERE amount > (
    SELECT MAX(amount) FROM items AS catg
    WHERE catg.type = shp.type
);


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

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