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

SELECT name FROM accounts AS dept
WHERE value > (
    SELECT MIN(value) FROM categories AS mgr
    WHERE mgr.type = dept.type
);


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

SELECT value FROM departments AS ord
WHERE salary > (
    SELECT MAX(salary) FROM regions AS empl
    WHERE empl.status = ord.status
);


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

SELECT amount FROM warehouses AS dept
WHERE value > (
    SELECT MAX(salary) FROM invoices AS txn
    WHERE txn.status = dept.status
);


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

SELECT code FROM transactions AS mgr
WHERE status IN (
    SELECT status FROM suppliers AS whs
    WHERE whs.code = mgr.code
);


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

SELECT value FROM transactions AS shp
WHERE code IN (
    SELECT code FROM employees AS acct
    WHERE acct.level = shp.level
);


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

SELECT amount FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.type = txn.type
);


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

SELECT value FROM categories AS dept
WHERE salary > (
    SELECT AVG(value) FROM regions AS shp
    WHERE shp.code = dept.code
);


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

SELECT amount FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.level = emp.level
);


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

SELECT id FROM regions AS empl
WHERE value > (
    SELECT MAX(amount) FROM warehouses AS dept
    WHERE dept.id = empl.id
);


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

SELECT salary FROM invoices AS whs
WHERE id IN (
    SELECT id FROM accounts AS prod
    WHERE prod.type = whs.type
);


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

SELECT value FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.id = srvc.id
);


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

SELECT code FROM projects AS dept
WHERE amount > (
    SELECT AVG(value) FROM transactions AS shp
    WHERE shp.level = dept.level
);


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

SELECT amount FROM regions AS shp
WHERE type IN (
    SELECT type FROM departments AS sale
    WHERE sale.status = shp.status
);


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

SELECT id FROM projects AS txn
WHERE salary > (
    SELECT AVG(amount) FROM categories AS catg
    WHERE catg.status = txn.status
);


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

SELECT id FROM invoices AS dept
WHERE status IN (
    SELECT status FROM warehouses AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT code FROM projects AS emp
WHERE value > (
    SELECT MAX(amount) FROM regions AS txn
    WHERE txn.type = emp.type
);


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

SELECT salary FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.type = cust.type
);


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

SELECT name FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT name FROM employees AS prod
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS budg
    WHERE budg.type = prod.type
);


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

SELECT name FROM regions AS srvc
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.type = srvc.type
);


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

SELECT code FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT id FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.level = emp.level
);


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

SELECT code FROM orders AS whs
WHERE type IN (
    SELECT type FROM branches AS emp
    WHERE emp.level = whs.level
);


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

SELECT salary FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.id = ord.id
);


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

SELECT value FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT salary FROM regions AS ord
WHERE value > (
    SELECT MIN(value) FROM products AS acct
    WHERE acct.id = ord.id
);


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

SELECT salary FROM customers AS emp
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS empl
    WHERE empl.status = emp.status
);


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

SELECT value FROM categories AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS ord
    WHERE ord.status = acct.status
);


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

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


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

SELECT salary FROM categories AS shp
WHERE id IN (
    SELECT id FROM warehouses AS prod
    WHERE prod.id = shp.id
);


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

SELECT name FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.type = budg.type
);


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

SELECT code FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT salary FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.code = prod.code
);


Prompt:
Schema:
  regions (alias: sale)(level, code, id, salary)
  employees(status, code, amount, type)
Task: Retrieve code from regions with salary above the MAX(salary) of employees rows sharing the same type.
SQL:

SELECT code FROM regions AS sale
WHERE salary > (
    SELECT MAX(salary) FROM employees AS dept
    WHERE dept.type = sale.type
);


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

SELECT name FROM suppliers AS inv
WHERE level IN (
    SELECT level FROM regions AS whs
    WHERE whs.type = inv.type
);


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

SELECT name FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.id = sale.id
);


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

SELECT value FROM products AS dept
WHERE salary > (
    SELECT AVG(value) FROM shipments AS empl
    WHERE empl.status = dept.status
);


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

SELECT id FROM accounts AS ordr
WHERE code IN (
    SELECT code FROM branches AS txn
    WHERE txn.status = ordr.status
);


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

SELECT amount FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.id = ordr.id
);


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

SELECT name FROM transactions AS empl
WHERE status IN (
    SELECT status FROM customers AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT amount FROM warehouses AS prod
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT salary FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM projects AS txn
    WHERE txn.id = rgn.id
);


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

SELECT salary FROM regions AS ordr
WHERE id IN (
    SELECT id FROM products AS ord
    WHERE ord.code = ordr.code
);


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

SELECT id FROM departments AS cust
WHERE value > (
    SELECT MIN(amount) FROM branches AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT name FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.level = mgr.level
);


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

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


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

SELECT name FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT name FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = cust.level
);


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

SELECT value FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT id FROM transactions AS rgn
WHERE id IN (
    SELECT id FROM departments AS empl
    WHERE empl.type = rgn.type
);


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

SELECT id FROM products AS catg
WHERE code IN (
    SELECT code FROM regions AS inv
    WHERE inv.level = catg.level
);


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

SELECT value FROM invoices AS catg
WHERE code IN (
    SELECT code FROM transactions AS dept
    WHERE dept.level = catg.level
);


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

SELECT id FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM tasks AS prod
    WHERE prod.id = rgn.id
);


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

SELECT value FROM tasks AS inv
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS catg
    WHERE catg.type = inv.type
);


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

SELECT id FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.id = lne.id
);


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

SELECT id FROM tasks AS ordr
WHERE type IN (
    SELECT type FROM transactions AS shp
    WHERE shp.status = ordr.status
);


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

SELECT value FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.id = inv.id
);


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

SELECT value FROM regions AS catg
WHERE value > (
    SELECT COUNT(value) FROM transactions AS acct
    WHERE acct.id = catg.id
);


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

SELECT name FROM accounts AS catg
WHERE status IN (
    SELECT status FROM orders AS lne
    WHERE lne.code = catg.code
);


Prompt:
Schema:
  accounts (alias: cust)(name, salary, code, type)
  regions(amount, name, date, level)
Task: Find code from accounts where amount exceeds the average salary from regions for the same code.
SQL:

SELECT code FROM accounts AS cust
WHERE amount > (
    SELECT MAX(salary) FROM regions AS ord
    WHERE ord.code = cust.code
);


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

SELECT value FROM shipments AS txn
WHERE amount > (
    SELECT MIN(value) FROM warehouses AS prod
    WHERE prod.type = txn.type
);


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

SELECT code FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.type = ordr.type
);


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

SELECT salary FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.status = cust.status
);


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

SELECT amount FROM categories AS schd
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS ord
    WHERE ord.type = schd.type
);


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

SELECT name FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.status = inv.status
);


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

SELECT name FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.id = acct.id
);


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

SELECT code FROM invoices AS mgr
WHERE amount > (
    SELECT MIN(value) FROM shipments AS budg
    WHERE budg.code = mgr.code
);


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

SELECT name FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.status = ordr.status
);


Prompt:
Schema:
  suppliers (alias: txn)(amount, salary, id, date)
  categories(salary, id, value, status)
Task: Retrieve salary from suppliers with value above the MIN(salary) of categories rows sharing the same code.
SQL:

SELECT salary FROM suppliers AS txn
WHERE value > (
    SELECT MIN(salary) FROM categories AS sale
    WHERE sale.code = txn.code
);


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

SELECT value FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.level = shp.level
);


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

SELECT name FROM orders AS rgn
WHERE amount > (
    SELECT MAX(amount) FROM employees AS inv
    WHERE inv.level = rgn.level
);


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

SELECT value FROM transactions AS ord
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.type = ord.type
);


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

SELECT value FROM tasks AS prod
WHERE value > (
    SELECT MAX(amount) FROM branches AS srvc
    WHERE srvc.level = prod.level
);


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

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


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

SELECT code FROM tasks AS inv
WHERE salary > (
    SELECT COUNT(value) FROM categories AS empl
    WHERE empl.level = inv.level
);


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

SELECT code FROM orders AS acct
WHERE id IN (
    SELECT id FROM shipments AS budg
    WHERE budg.level = acct.level
);


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

SELECT code FROM products AS srvc
WHERE code IN (
    SELECT code FROM categories AS catg
    WHERE catg.level = srvc.level
);


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

SELECT amount FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT code FROM accounts AS budg
WHERE level IN (
    SELECT level FROM categories AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT code FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT salary FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM products AS dept
    WHERE dept.level = mgr.level
);


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

SELECT value FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.type = acct.type
);


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

SELECT id FROM transactions AS lne
WHERE code IN (
    SELECT code FROM accounts AS cust
    WHERE cust.id = lne.id
);


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

SELECT value FROM transactions AS acct
WHERE id IN (
    SELECT id FROM projects AS ord
    WHERE ord.status = acct.status
);


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

SELECT id FROM employees AS inv
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS shp
    WHERE shp.status = inv.status
);


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

SELECT code FROM branches AS lne
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS whs
    WHERE whs.code = lne.code
);


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

SELECT name FROM orders AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM warehouses AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT id FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT name FROM projects AS dept
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS schd
    WHERE schd.code = dept.code
);


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

SELECT value FROM projects AS sale
WHERE value > (
    SELECT MAX(salary) FROM regions AS catg
    WHERE catg.id = sale.id
);


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

SELECT amount FROM transactions AS schd
WHERE value > (
    SELECT MAX(salary) FROM projects AS cust
    WHERE cust.type = schd.type
);


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

SELECT id FROM accounts AS empl
WHERE id IN (
    SELECT id FROM regions AS lne
    WHERE lne.status = empl.status
);


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

SELECT value FROM tasks AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS emp
    WHERE emp.status = ord.status
);


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

SELECT salary FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.type = dept.type
);


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

SELECT code FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.status = emp.status
);


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

SELECT amount FROM suppliers AS empl
WHERE value > (
    SELECT MAX(salary) FROM customers AS prod
    WHERE prod.status = empl.status
);


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

SELECT salary FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.status = shp.status
);


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

SELECT id FROM suppliers AS empl
WHERE level IN (
    SELECT level FROM products AS cust
    WHERE cust.status = empl.status
);


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

SELECT amount FROM products AS prod
WHERE id IN (
    SELECT id FROM employees AS cust
    WHERE cust.type = prod.type
);


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

SELECT code FROM customers AS rgn
WHERE value > (
    SELECT AVG(amount) FROM employees AS whs
    WHERE whs.type = rgn.type
);


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

SELECT value FROM projects AS srvc
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.id = srvc.id
);


Prompt:
Schema:
  branches (alias: empl)(status, salary, value, code)
  warehouses(type, value, salary, date)
Task: Retrieve code from branches with value above the SUM(value) of warehouses rows sharing the same code.
SQL:

SELECT code FROM branches AS empl
WHERE value > (
    SELECT SUM(value) FROM warehouses AS inv
    WHERE inv.code = empl.code
);


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

SELECT amount FROM regions AS cust
WHERE type IN (
    SELECT type FROM shipments AS sale
    WHERE sale.code = cust.code
);


Prompt:
Schema:
  suppliers (alias: lne)(name, amount, level, salary)
  branches(value, name, type, code)
Task: Find salary from suppliers where amount exceeds the average salary from branches for the same level.
SQL:

SELECT salary FROM suppliers AS lne
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS catg
    WHERE catg.level = lne.level
);


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

SELECT id FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT salary FROM employees AS txn
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT value FROM suppliers AS prod
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS dept
    WHERE dept.level = prod.level
);


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

SELECT salary FROM tasks AS ord
WHERE salary > (
    SELECT MAX(value) FROM projects AS empl
    WHERE empl.code = ord.code
);


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

SELECT amount FROM branches AS sale
WHERE id IN (
    SELECT id FROM shipments AS inv
    WHERE inv.id = sale.id
);


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

SELECT amount FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT amount FROM projects AS schd
WHERE amount > (
    SELECT SUM(amount) FROM categories AS shp
    WHERE shp.id = schd.id
);


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

SELECT name FROM orders AS catg
WHERE value > (
    SELECT COUNT(value) FROM projects AS schd
    WHERE schd.level = catg.level
);


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

SELECT salary FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.type = ord.type
);


Prompt:
Schema:
  branches (alias: budg)(salary, name, date, id)
  shipments(code, amount, id, type)
Task: Find salary from branches where value exceeds the average value from shipments for the same id.
SQL:

SELECT salary FROM branches AS budg
WHERE value > (
    SELECT SUM(value) FROM shipments AS schd
    WHERE schd.id = budg.id
);


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

SELECT amount FROM accounts AS prod
WHERE value > (
    SELECT COUNT(amount) FROM customers AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT amount FROM transactions AS ord
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.code = ord.code
);


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

SELECT value FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.type = mgr.type
);


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

SELECT id FROM warehouses AS srvc
WHERE id IN (
    SELECT id FROM employees AS budg
    WHERE budg.status = srvc.status
);


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

SELECT salary FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.status = budg.status
);


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

SELECT code FROM suppliers AS txn
WHERE level IN (
    SELECT level FROM employees AS srvc
    WHERE srvc.code = txn.code
);


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

SELECT name FROM shipments AS inv
WHERE status IN (
    SELECT status FROM suppliers AS whs
    WHERE whs.level = inv.level
);


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

SELECT name FROM warehouses AS prod
WHERE amount > (
    SELECT MAX(value) FROM regions AS emp
    WHERE emp.id = prod.id
);


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

SELECT value FROM regions AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM transactions AS ord
    WHERE ord.id = sale.id
);


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

SELECT salary FROM employees AS empl
WHERE id IN (
    SELECT id FROM branches AS budg
    WHERE budg.type = empl.type
);


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

SELECT name FROM accounts AS shp
WHERE value > (
    SELECT SUM(value) FROM products AS whs
    WHERE whs.status = shp.status
);


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

SELECT code FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.type = dept.type
);


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

SELECT amount FROM shipments AS prod
WHERE status IN (
    SELECT status FROM accounts AS whs
    WHERE whs.level = prod.level
);


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

SELECT id FROM tasks AS whs
WHERE amount > (
    SELECT MAX(amount) FROM departments AS txn
    WHERE txn.status = whs.status
);


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

SELECT value FROM suppliers AS dept
WHERE value > (
    SELECT MAX(salary) FROM products AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT amount FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.status = inv.status
);


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

SELECT salary FROM departments AS txn
WHERE type IN (
    SELECT type FROM tasks AS catg
    WHERE catg.status = txn.status
);


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

SELECT amount FROM products AS prod
WHERE value > (
    SELECT AVG(value) FROM departments AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT amount FROM warehouses AS rgn
WHERE code IN (
    SELECT code FROM suppliers AS cust
    WHERE cust.level = rgn.level
);


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

SELECT id FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.id = whs.id
);


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

SELECT id FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = srvc.type
);


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

SELECT amount FROM customers AS schd
WHERE salary > (
    SELECT AVG(amount) FROM branches AS sale
    WHERE sale.status = schd.status
);


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

SELECT name FROM categories AS txn
WHERE code IN (
    SELECT code FROM warehouses AS schd
    WHERE schd.id = txn.id
);


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

SELECT value FROM branches AS txn
WHERE type IN (
    SELECT type FROM warehouses AS emp
    WHERE emp.id = txn.id
);


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

SELECT id FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.level = cust.level
);


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

SELECT code FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.id = mgr.id
);


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

SELECT salary FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.code = dept.code
);


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

SELECT salary FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.status = dept.status
);


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

SELECT value FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.id = dept.id
);


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

SELECT name FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT code FROM customers AS sale
WHERE value > (
    SELECT COUNT(amount) FROM regions AS shp
    WHERE shp.code = sale.code
);


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

SELECT salary FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT value FROM orders AS empl
WHERE amount > (
    SELECT AVG(value) FROM customers AS sale
    WHERE sale.type = empl.type
);


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

SELECT code FROM projects AS schd
WHERE type IN (
    SELECT type FROM employees AS inv
    WHERE inv.code = schd.code
);


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

SELECT amount FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.type = rgn.type
);


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

SELECT amount FROM departments AS catg
WHERE code IN (
    SELECT code FROM transactions AS empl
    WHERE empl.level = catg.level
);


Prompt:
Schema:
  accounts (alias: budg)(date, status, level, amount)
  invoices(amount, name, date, id)
Task: Retrieve amount from accounts with amount above the AVG(value) of invoices rows sharing the same status.
SQL:

SELECT amount FROM accounts AS budg
WHERE amount > (
    SELECT AVG(value) FROM invoices AS empl
    WHERE empl.status = budg.status
);


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

SELECT amount FROM suppliers AS cust
WHERE salary > (
    SELECT SUM(amount) FROM orders AS acct
    WHERE acct.type = cust.type
);


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

SELECT value FROM invoices AS empl
WHERE code IN (
    SELECT code FROM suppliers AS dept
    WHERE dept.type = empl.type
);


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

SELECT id FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.code = rgn.code
);


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

SELECT salary FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.id = mgr.id
);


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

SELECT amount FROM suppliers AS whs
WHERE salary > (
    SELECT COUNT(value) FROM categories AS empl
    WHERE empl.status = whs.status
);


Prompt:
Schema:
  customers (alias: budg)(name, amount, status, date)
  suppliers(status, salary, amount, date)
Task: Find salary from customers where type appears in suppliers entries with matching status.
SQL:

SELECT salary FROM customers AS budg
WHERE type IN (
    SELECT type FROM suppliers AS catg
    WHERE catg.status = budg.status
);


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

SELECT amount FROM categories AS catg
WHERE id IN (
    SELECT id FROM projects AS mgr
    WHERE mgr.code = catg.code
);


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

SELECT id FROM invoices AS dept
WHERE id IN (
    SELECT id FROM products AS budg
    WHERE budg.level = dept.level
);


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

SELECT code FROM projects AS budg
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS ord
    WHERE ord.type = budg.type
);


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

SELECT salary FROM invoices AS dept
WHERE id IN (
    SELECT id FROM transactions AS prod
    WHERE prod.status = dept.status
);


Prompt:
Schema:
  orders (alias: whs)(id, name, type, amount)
  shipments(level, amount, name, status)
Task: Find amount from orders where salary exceeds the average salary from shipments for the same id.
SQL:

SELECT amount FROM orders AS whs
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS emp
    WHERE emp.id = whs.id
);


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

SELECT salary FROM warehouses AS ordr
WHERE id IN (
    SELECT id FROM projects AS budg
    WHERE budg.status = ordr.status
);


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

SELECT name FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.status = sale.status
);


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

SELECT name FROM tasks AS empl
WHERE salary > (
    SELECT MAX(salary) FROM regions AS budg
    WHERE budg.id = empl.id
);


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

SELECT id FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.type = budg.type
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.type = dept.type
);


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

SELECT salary FROM branches AS inv
WHERE salary > (
    SELECT MAX(value) FROM regions AS txn
    WHERE txn.code = inv.code
);


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

SELECT salary FROM orders AS lne
WHERE amount > (
    SELECT MIN(value) FROM branches AS rgn
    WHERE rgn.code = lne.code
);


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

SELECT salary FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.status = empl.status
);


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

SELECT code FROM accounts AS rgn
WHERE id IN (
    SELECT id FROM suppliers AS cust
    WHERE cust.code = rgn.code
);


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

SELECT value FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.status = ordr.status
);


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

SELECT id FROM regions AS whs
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS txn
    WHERE txn.status = whs.status
);


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

SELECT code FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.id = empl.id
);


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

SELECT code FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM orders AS sale
    WHERE sale.id = ordr.id
);


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

SELECT amount FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = sale.status
);


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

SELECT amount FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.code = srvc.code
);


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

SELECT salary FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.code = sale.code
);


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

SELECT name FROM tasks AS budg
WHERE value > (
    SELECT AVG(value) FROM customers AS inv
    WHERE inv.code = budg.code
);


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

SELECT id FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.level = ord.level
);


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

SELECT code FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.status = emp.status
);


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

SELECT salary FROM accounts AS whs
WHERE value > (
    SELECT COUNT(value) FROM invoices AS inv
    WHERE inv.type = whs.type
);


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

SELECT salary FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT salary FROM transactions AS sale
WHERE status IN (
    SELECT status FROM shipments AS emp
    WHERE emp.status = sale.status
);


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

SELECT code FROM branches AS ordr
WHERE type IN (
    SELECT type FROM orders AS budg
    WHERE budg.code = ordr.code
);


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

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


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

SELECT id FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.status = emp.status
);


Prompt:
Schema:
  warehouses (alias: dept)(value, level, type, date)
  branches(level, amount, salary, date)
Task: Find id from warehouses where amount exceeds the average salary from branches for the same level.
SQL:

SELECT id FROM warehouses AS dept
WHERE amount > (
    SELECT SUM(salary) FROM branches AS catg
    WHERE catg.level = dept.level
);


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

SELECT name FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.type = acct.type
);


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

SELECT id FROM suppliers AS ord
WHERE level IN (
    SELECT level FROM tasks AS acct
    WHERE acct.code = ord.code
);


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

SELECT value FROM customers AS empl
WHERE code IN (
    SELECT code FROM warehouses AS schd
    WHERE schd.id = empl.id
);


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

SELECT name FROM customers AS catg
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.type = catg.type
);


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

SELECT amount FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.type = budg.type
);


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

SELECT id FROM shipments AS mgr
WHERE code IN (
    SELECT code FROM categories AS whs
    WHERE whs.level = mgr.level
);


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

SELECT id FROM projects AS whs
WHERE id IN (
    SELECT id FROM accounts AS catg
    WHERE catg.code = whs.code
);


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

SELECT name FROM invoices AS lne
WHERE level IN (
    SELECT level FROM shipments AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT code FROM invoices AS acct
WHERE id IN (
    SELECT id FROM warehouses AS empl
    WHERE empl.level = acct.level
);


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

SELECT amount FROM orders AS sale
WHERE value > (
    SELECT AVG(value) FROM suppliers AS emp
    WHERE emp.status = sale.status
);


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

SELECT amount FROM categories AS emp
WHERE level IN (
    SELECT level FROM branches AS inv
    WHERE inv.id = emp.id
);


Prompt:
Schema:
  categories (alias: acct)(value, status, salary, code)
  invoices(salary, date, amount, status)
Task: Retrieve salary from categories with salary above the MAX(amount) of invoices rows sharing the same status.
SQL:

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


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

SELECT amount FROM tasks AS rgn
WHERE level IN (
    SELECT level FROM orders AS prod
    WHERE prod.level = rgn.level
);


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

SELECT value FROM departments AS shp
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.level = shp.level
);


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

SELECT id FROM tasks AS sale
WHERE value > (
    SELECT AVG(amount) FROM accounts AS whs
    WHERE whs.code = sale.code
);


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

SELECT amount FROM transactions AS dept
WHERE value > (
    SELECT MIN(value) FROM regions AS acct
    WHERE acct.id = dept.id
);


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

SELECT amount FROM branches AS srvc
WHERE salary > (
    SELECT MIN(value) FROM departments AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT value FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.code = mgr.code
);


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

SELECT id FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.status = inv.status
);


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

SELECT name FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.level = schd.level
);


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

SELECT value FROM orders AS ord
WHERE value > (
    SELECT MAX(salary) FROM projects AS empl
    WHERE empl.type = ord.type
);


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

SELECT salary FROM departments AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM transactions AS whs
    WHERE whs.type = rgn.type
);


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

SELECT name FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT salary FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.level = ord.level
);


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

SELECT id FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = schd.type
);


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

SELECT value FROM warehouses AS inv
WHERE value > (
    SELECT MIN(salary) FROM regions AS whs
    WHERE whs.level = inv.level
);


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

SELECT id FROM regions AS budg
WHERE type IN (
    SELECT type FROM products AS acct
    WHERE acct.status = budg.status
);


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

SELECT name FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.code = cust.code
);


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

SELECT name FROM orders AS dept
WHERE amount > (
    SELECT SUM(value) FROM tasks AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT code FROM categories AS shp
WHERE level IN (
    SELECT level FROM customers AS budg
    WHERE budg.id = shp.id
);


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

SELECT value FROM orders AS whs
WHERE amount > (
    SELECT MIN(salary) FROM categories AS lne
    WHERE lne.type = whs.type
);


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.code = whs.code
);


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

SELECT code FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = txn.code
);


Prompt:
Schema:
  categories (alias: emp)(name, id, type, level)
  branches(amount, id, value, status)
Task: Find amount from categories where salary exceeds the average amount from branches for the same type.
SQL:

SELECT amount FROM categories AS emp
WHERE salary > (
    SELECT AVG(amount) FROM branches AS budg
    WHERE budg.type = emp.type
);


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

SELECT value FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT amount FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT salary FROM regions AS srvc
WHERE salary > (
    SELECT COUNT(amount) FROM shipments AS acct
    WHERE acct.level = srvc.level
);


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

SELECT value FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.level = srvc.level
);


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

SELECT name FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.id = txn.id
);


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

SELECT id FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.id = sale.id
);


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

SELECT name FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.type = empl.type
);


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

SELECT amount FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.id = catg.id
);


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

SELECT salary FROM branches AS budg
WHERE id IN (
    SELECT id FROM departments AS inv
    WHERE inv.id = budg.id
);


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

SELECT value FROM branches AS prod
WHERE amount > (
    SELECT MIN(value) FROM regions AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT value FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.code = catg.code
);


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

SELECT name FROM accounts AS cust
WHERE type IN (
    SELECT type FROM tasks AS catg
    WHERE catg.type = cust.type
);


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

SELECT salary FROM projects AS empl
WHERE code IN (
    SELECT code FROM orders AS inv
    WHERE inv.status = empl.status
);


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

SELECT name FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = ord.type
);


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

SELECT amount FROM products AS ord
WHERE id IN (
    SELECT id FROM categories AS shp
    WHERE shp.code = ord.code
);


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

SELECT code FROM branches AS budg
WHERE status IN (
    SELECT status FROM suppliers AS txn
    WHERE txn.level = budg.level
);


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

SELECT salary FROM products AS catg
WHERE status IN (
    SELECT status FROM branches AS lne
    WHERE lne.id = catg.id
);


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

SELECT name FROM departments AS whs
WHERE type IN (
    SELECT type FROM employees AS schd
    WHERE schd.level = whs.level
);


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

SELECT name FROM categories AS inv
WHERE salary > (
    SELECT SUM(salary) FROM transactions AS catg
    WHERE catg.id = inv.id
);


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

SELECT amount FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT id FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.level = acct.level
);


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

SELECT code FROM transactions AS catg
WHERE status IN (
    SELECT status FROM customers AS whs
    WHERE whs.level = catg.level
);


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

SELECT code FROM warehouses AS sale
WHERE id IN (
    SELECT id FROM suppliers AS inv
    WHERE inv.status = sale.status
);


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

SELECT amount FROM departments AS lne
WHERE id IN (
    SELECT id FROM regions AS empl
    WHERE empl.level = lne.level
);


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

SELECT code FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.id = cust.id
);


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

SELECT salary FROM departments AS schd
WHERE amount > (
    SELECT MIN(value) FROM invoices AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT amount FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = catg.code
);


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

SELECT code FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = prod.type
);


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

SELECT amount FROM warehouses AS mgr
WHERE type IN (
    SELECT type FROM suppliers AS txn
    WHERE txn.type = mgr.type
);


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

SELECT salary FROM projects AS ord
WHERE amount > (
    SELECT SUM(salary) FROM categories AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT value FROM tasks AS emp
WHERE code IN (
    SELECT code FROM categories AS shp
    WHERE shp.type = emp.type
);


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

SELECT id FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.level = prod.level
);


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

SELECT amount FROM products AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS inv
    WHERE inv.id = catg.id
);


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

SELECT value FROM transactions AS catg
WHERE amount > (
    SELECT MAX(value) FROM departments AS srvc
    WHERE srvc.code = catg.code
);


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

SELECT name FROM orders AS rgn
WHERE type IN (
    SELECT type FROM customers AS whs
    WHERE whs.code = rgn.code
);


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

SELECT code FROM tasks AS emp
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT value FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.status = txn.status
);


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

SELECT name FROM suppliers AS schd
WHERE type IN (
    SELECT type FROM transactions AS whs
    WHERE whs.status = schd.status
);


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

SELECT code FROM transactions AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS dept
    WHERE dept.status = srvc.status
);


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

SELECT name FROM orders AS ord
WHERE id IN (
    SELECT id FROM branches AS whs
    WHERE whs.level = ord.level
);


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

SELECT id FROM orders AS budg
WHERE status IN (
    SELECT status FROM customers AS sale
    WHERE sale.id = budg.id
);


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

SELECT name FROM employees AS whs
WHERE level IN (
    SELECT level FROM categories AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT amount FROM departments AS lne
WHERE status IN (
    SELECT status FROM customers AS schd
    WHERE schd.code = lne.code
);


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

SELECT amount FROM departments AS prod
WHERE value > (
    SELECT MIN(value) FROM shipments AS lne
    WHERE lne.id = prod.id
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.status = dept.status
);


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

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


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

SELECT code FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.code = ordr.code
);


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

SELECT name FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.code = budg.code
);


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

SELECT id FROM tasks AS ord
WHERE code IN (
    SELECT code FROM suppliers AS empl
    WHERE empl.id = ord.id
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.level = budg.level
);


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

SELECT value FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.level = lne.level
);


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

SELECT amount FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.type = budg.type
);


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

SELECT amount FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.id = lne.id
);


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

SELECT value FROM projects AS prod
WHERE amount > (
    SELECT SUM(value) FROM customers AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT id FROM shipments AS srvc
WHERE level IN (
    SELECT level FROM regions AS budg
    WHERE budg.id = srvc.id
);


Prompt:
Schema:
  categories (alias: lne)(status, date, amount, salary)
  projects(date, level, id, name)
Task: Find name from categories where amount exceeds the average salary from projects for the same status.
SQL:

SELECT name FROM categories AS lne
WHERE amount > (
    SELECT SUM(salary) FROM projects AS rgn
    WHERE rgn.status = lne.status
);


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

SELECT salary FROM branches AS cust
WHERE status IN (
    SELECT status FROM departments AS schd
    WHERE schd.type = cust.type
);


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

SELECT name FROM branches AS whs
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS ord
    WHERE ord.code = whs.code
);


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

SELECT salary FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.level = lne.level
);


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

SELECT code FROM invoices AS cust
WHERE status IN (
    SELECT status FROM orders AS txn
    WHERE txn.level = cust.level
);


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

SELECT id FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT name FROM projects AS acct
WHERE value > (
    SELECT MAX(amount) FROM invoices AS ordr
    WHERE ordr.id = acct.id
);


Prompt:
Schema:
  regions (alias: dept)(amount, value, date, code)
  products(date, value, id, name)
Task: Retrieve id from regions with salary above the MIN(value) of products rows sharing the same id.
SQL:

SELECT id FROM regions AS dept
WHERE salary > (
    SELECT MIN(value) FROM products AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT value FROM tasks AS srvc
WHERE id IN (
    SELECT id FROM warehouses AS prod
    WHERE prod.status = srvc.status
);


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

SELECT id FROM shipments AS whs
WHERE status IN (
    SELECT status FROM accounts AS cust
    WHERE cust.level = whs.level
);


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

SELECT amount FROM employees AS lne
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.level = lne.level
);


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

SELECT salary FROM customers AS inv
WHERE type IN (
    SELECT type FROM categories AS ord
    WHERE ord.code = inv.code
);


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

SELECT value FROM departments AS shp
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS emp
    WHERE emp.id = shp.id
);


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

SELECT code FROM regions AS catg
WHERE amount > (
    SELECT SUM(value) FROM employees AS acct
    WHERE acct.id = catg.id
);


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

SELECT id FROM accounts AS shp
WHERE value > (
    SELECT COUNT(salary) FROM categories AS acct
    WHERE acct.id = shp.id
);


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

SELECT value FROM accounts AS ordr
WHERE type IN (
    SELECT type FROM projects AS rgn
    WHERE rgn.code = ordr.code
);