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

SELECT code FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.type = srvc.type
);


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

SELECT amount FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.level = dept.level
);


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

SELECT name FROM transactions AS txn
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.status = txn.status
);


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

SELECT code FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = schd.status
);


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

SELECT name FROM customers AS acct
WHERE type IN (
    SELECT type FROM transactions AS inv
    WHERE inv.id = acct.id
);


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

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


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

SELECT name FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.status = emp.status
);


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

SELECT code FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.level = mgr.level
);


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

SELECT id FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.level = inv.level
);


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

SELECT salary FROM invoices AS emp
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS budg
    WHERE budg.id = emp.id
);


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

SELECT salary FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.level = mgr.level
);


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

SELECT name FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.status = dept.status
);


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

SELECT salary FROM departments AS cust
WHERE value > (
    SELECT AVG(amount) FROM products AS lne
    WHERE lne.id = cust.id
);


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

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


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

SELECT code FROM suppliers AS srvc
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.type = srvc.type
);


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

SELECT value FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.id = rgn.id
);


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

SELECT name FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.level = shp.level
);


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

SELECT salary FROM invoices AS empl
WHERE code IN (
    SELECT code FROM orders AS ord
    WHERE ord.code = empl.code
);


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

SELECT value FROM customers AS mgr
WHERE status IN (
    SELECT status FROM branches AS whs
    WHERE whs.level = mgr.level
);


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

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


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

SELECT value FROM customers AS dept
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT value FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT code FROM transactions AS lne
WHERE id IN (
    SELECT id FROM branches AS catg
    WHERE catg.status = lne.status
);


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

SELECT salary FROM tasks AS catg
WHERE salary > (
    SELECT MAX(salary) FROM branches AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT salary FROM warehouses AS budg
WHERE value > (
    SELECT COUNT(amount) FROM projects AS catg
    WHERE catg.level = budg.level
);


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

SELECT value FROM customers AS catg
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.status = catg.status
);


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

SELECT amount FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.status = whs.status
);


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

SELECT name FROM tasks AS budg
WHERE id IN (
    SELECT id FROM transactions AS catg
    WHERE catg.level = budg.level
);


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

SELECT code FROM accounts AS acct
WHERE id IN (
    SELECT id FROM suppliers AS prod
    WHERE prod.type = acct.type
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.status = catg.status
);


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

SELECT code FROM accounts AS ordr
WHERE type IN (
    SELECT type FROM employees AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT amount FROM suppliers AS prod
WHERE id IN (
    SELECT id FROM employees AS shp
    WHERE shp.type = prod.type
);


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

SELECT id FROM customers AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM regions AS mgr
    WHERE mgr.level = srvc.level
);


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

SELECT id FROM shipments AS acct
WHERE code IN (
    SELECT code FROM branches AS ord
    WHERE ord.code = acct.code
);


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

SELECT amount FROM categories AS dept
WHERE amount > (
    SELECT MIN(salary) FROM customers AS txn
    WHERE txn.status = dept.status
);


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

SELECT code FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT code FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.level = txn.level
);


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

SELECT id FROM invoices AS mgr
WHERE amount > (
    SELECT MAX(value) FROM tasks AS srvc
    WHERE srvc.id = mgr.id
);


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

SELECT id FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.id = dept.id
);


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

SELECT id FROM suppliers AS emp
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT salary FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.type = inv.type
);


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

SELECT amount FROM categories AS srvc
WHERE status IN (
    SELECT status FROM shipments AS prod
    WHERE prod.id = srvc.id
);


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

SELECT salary FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.code = sale.code
);


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

SELECT code FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.status = shp.status
);


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

SELECT value FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.status = catg.status
);


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

SELECT id FROM accounts AS catg
WHERE amount > (
    SELECT SUM(amount) FROM products AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT name FROM shipments AS empl
WHERE level IN (
    SELECT level FROM departments AS shp
    WHERE shp.status = empl.status
);


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

SELECT code FROM projects AS sale
WHERE code IN (
    SELECT code FROM accounts AS inv
    WHERE inv.id = sale.id
);


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

SELECT value FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.code = srvc.code
);


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

SELECT amount FROM customers AS schd
WHERE value > (
    SELECT SUM(salary) FROM departments AS lne
    WHERE lne.status = schd.status
);


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

SELECT amount FROM regions AS empl
WHERE value > (
    SELECT AVG(value) FROM departments AS lne
    WHERE lne.type = empl.type
);


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

SELECT salary FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.id = catg.id
);


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

SELECT id FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.code = mgr.code
);


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

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


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

SELECT amount FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.id = whs.id
);


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

SELECT id FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.id = budg.id
);


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

SELECT id FROM branches AS prod
WHERE status IN (
    SELECT status FROM tasks AS schd
    WHERE schd.status = prod.status
);


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

SELECT code FROM customers AS prod
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS schd
    WHERE schd.code = prod.code
);


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

SELECT id FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.status = schd.status
);


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

SELECT salary FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.level = srvc.level
);


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

SELECT id FROM customers AS rgn
WHERE status IN (
    SELECT status FROM projects AS acct
    WHERE acct.status = rgn.status
);


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

SELECT amount FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.type = whs.type
);


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

SELECT code FROM projects AS rgn
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT value FROM tasks AS shp
WHERE salary > (
    SELECT SUM(value) FROM departments AS ord
    WHERE ord.status = shp.status
);


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

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


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

SELECT value FROM departments AS schd
WHERE status IN (
    SELECT status FROM invoices AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT name FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.level = prod.level
);


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

SELECT id FROM categories AS rgn
WHERE code IN (
    SELECT code FROM transactions AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT amount FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.status = cust.status
);


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

SELECT salary FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.level = shp.level
);


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

SELECT salary FROM suppliers AS sale
WHERE status IN (
    SELECT status FROM products AS dept
    WHERE dept.id = sale.id
);


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

SELECT value FROM invoices AS empl
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.code = empl.code
);


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

SELECT salary FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.status = shp.status
);


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

SELECT amount FROM shipments AS cust
WHERE type IN (
    SELECT type FROM customers AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT name FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT code FROM transactions AS txn
WHERE type IN (
    SELECT type FROM categories AS inv
    WHERE inv.status = txn.status
);


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

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


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

SELECT id FROM accounts AS cust
WHERE type IN (
    SELECT type FROM invoices AS schd
    WHERE schd.id = cust.id
);


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

SELECT id FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.id = ord.id
);


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

SELECT name FROM departments AS txn
WHERE code IN (
    SELECT code FROM warehouses AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT amount FROM projects AS srvc
WHERE value > (
    SELECT MAX(amount) FROM invoices AS budg
    WHERE budg.level = srvc.level
);


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

SELECT salary FROM categories AS acct
WHERE level IN (
    SELECT level FROM branches AS mgr
    WHERE mgr.code = acct.code
);


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

SELECT id FROM invoices AS txn
WHERE code IN (
    SELECT code FROM employees AS lne
    WHERE lne.code = txn.code
);


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

SELECT amount FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.type = whs.type
);


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

SELECT code FROM warehouses AS sale
WHERE value > (
    SELECT MAX(salary) FROM tasks AS shp
    WHERE shp.type = sale.type
);


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

SELECT name FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.status = prod.status
);


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

SELECT id FROM regions AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS shp
    WHERE shp.status = whs.status
);


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

SELECT salary FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.code = sale.code
);


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

SELECT code FROM warehouses AS cust
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.level = cust.level
);


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

SELECT salary FROM warehouses AS prod
WHERE type IN (
    SELECT type FROM invoices AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT value FROM customers AS whs
WHERE value > (
    SELECT SUM(salary) FROM categories AS txn
    WHERE txn.type = whs.type
);


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

SELECT amount FROM tasks AS dept
WHERE id IN (
    SELECT id FROM shipments AS acct
    WHERE acct.level = dept.level
);


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

SELECT name FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.status = mgr.status
);


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

SELECT name FROM regions AS mgr
WHERE code IN (
    SELECT code FROM transactions AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT salary FROM products AS schd
WHERE value > (
    SELECT MIN(value) FROM projects AS catg
    WHERE catg.id = schd.id
);


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

SELECT id FROM projects AS lne
WHERE id IN (
    SELECT id FROM products AS shp
    WHERE shp.type = lne.type
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.status = inv.status
);


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

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


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

SELECT salary FROM transactions AS cust
WHERE amount > (
    SELECT MAX(amount) FROM branches AS inv
    WHERE inv.id = cust.id
);


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

SELECT name FROM shipments AS whs
WHERE code IN (
    SELECT code FROM orders AS acct
    WHERE acct.type = whs.type
);


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

SELECT amount FROM transactions AS txn
WHERE amount > (
    SELECT SUM(salary) FROM regions AS lne
    WHERE lne.type = txn.type
);


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

SELECT name FROM categories AS prod
WHERE amount > (
    SELECT SUM(amount) FROM customers AS txn
    WHERE txn.id = prod.id
);


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

SELECT id FROM products AS emp
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS txn
    WHERE txn.code = emp.code
);


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

SELECT value FROM departments AS sale
WHERE salary > (
    SELECT SUM(salary) FROM customers AS ord
    WHERE ord.code = sale.code
);


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

SELECT value FROM warehouses AS schd
WHERE code IN (
    SELECT code FROM shipments AS dept
    WHERE dept.id = schd.id
);


Prompt:
Schema:
  suppliers (alias: acct)(amount, name, date, id)
  projects(status, salary, name, code)
Task: Retrieve amount from suppliers with salary above the SUM(salary) of projects rows sharing the same status.
SQL:

SELECT amount FROM suppliers AS acct
WHERE salary > (
    SELECT SUM(salary) FROM projects AS schd
    WHERE schd.status = acct.status
);


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

SELECT value FROM products AS prod
WHERE amount > (
    SELECT MAX(amount) FROM projects AS sale
    WHERE sale.level = prod.level
);


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

SELECT name FROM projects AS ordr
WHERE code IN (
    SELECT code FROM departments AS lne
    WHERE lne.level = ordr.level
);


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

SELECT name FROM regions AS acct
WHERE value > (
    SELECT COUNT(salary) FROM accounts AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT salary FROM tasks AS shp
WHERE id IN (
    SELECT id FROM invoices AS mgr
    WHERE mgr.type = shp.type
);


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

SELECT code FROM employees AS dept
WHERE value > (
    SELECT MIN(salary) FROM shipments AS whs
    WHERE whs.level = dept.level
);


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

SELECT name FROM categories AS sale
WHERE amount > (
    SELECT MAX(salary) FROM regions AS shp
    WHERE shp.code = sale.code
);


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

SELECT name FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.type = sale.type
);


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

SELECT code FROM regions AS empl
WHERE amount > (
    SELECT MIN(salary) FROM projects AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT code FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.status = rgn.status
);


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

SELECT salary FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.status = budg.status
);


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

SELECT id FROM products AS catg
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.type = catg.type
);


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

SELECT value FROM suppliers AS catg
WHERE salary > (
    SELECT MAX(value) FROM regions AS emp
    WHERE emp.level = catg.level
);


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

SELECT amount FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT value FROM warehouses AS lne
WHERE value > (
    SELECT MIN(salary) FROM categories AS empl
    WHERE empl.status = lne.status
);


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

SELECT value FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.id = inv.id
);


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

SELECT id FROM transactions AS inv
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS prod
    WHERE prod.code = inv.code
);


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

SELECT code FROM products AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM branches AS dept
    WHERE dept.id = mgr.id
);


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

SELECT code FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.level = dept.level
);


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

SELECT amount FROM projects AS mgr
WHERE value > (
    SELECT MAX(value) FROM customers AS inv
    WHERE inv.id = mgr.id
);


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

SELECT code FROM transactions AS dept
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS schd
    WHERE schd.level = dept.level
);


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

SELECT salary FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.type = schd.type
);


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

SELECT id FROM branches AS lne
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS schd
    WHERE schd.type = lne.type
);


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

SELECT value FROM projects AS rgn
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.code = rgn.code
);


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

SELECT value FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.status = empl.status
);


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

SELECT name FROM regions AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT amount FROM tasks AS whs
WHERE status IN (
    SELECT status FROM categories AS empl
    WHERE empl.status = whs.status
);


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

SELECT name FROM transactions AS empl
WHERE value > (
    SELECT MAX(value) FROM products AS budg
    WHERE budg.status = empl.status
);


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

SELECT salary FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.status = ordr.status
);


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

SELECT value FROM customers AS ordr
WHERE amount > (
    SELECT SUM(salary) FROM orders AS lne
    WHERE lne.id = ordr.id
);


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

SELECT amount FROM suppliers AS whs
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS schd
    WHERE schd.status = whs.status
);


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

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


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

SELECT amount FROM branches AS schd
WHERE salary > (
    SELECT SUM(value) FROM invoices AS lne
    WHERE lne.code = schd.code
);


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

SELECT salary FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.level = shp.level
);


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

SELECT id FROM orders AS empl
WHERE code IN (
    SELECT code FROM suppliers AS prod
    WHERE prod.code = empl.code
);


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

SELECT id FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT code FROM invoices AS acct
WHERE level IN (
    SELECT level FROM shipments AS txn
    WHERE txn.id = acct.id
);


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

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


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

SELECT salary FROM shipments AS whs
WHERE code IN (
    SELECT code FROM transactions AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT salary FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.id = schd.id
);


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

SELECT name FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.code = sale.code
);


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

SELECT code FROM projects AS catg
WHERE value > (
    SELECT COUNT(salary) FROM suppliers AS mgr
    WHERE mgr.status = catg.status
);


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

SELECT salary FROM projects AS cust
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT salary FROM branches AS ord
WHERE status IN (
    SELECT status FROM orders AS dept
    WHERE dept.type = ord.type
);


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

SELECT name FROM invoices AS budg
WHERE amount > (
    SELECT SUM(value) FROM transactions AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT name FROM tasks AS rgn
WHERE id IN (
    SELECT id FROM categories AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT name FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT code FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.id = acct.id
);


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

SELECT name FROM shipments AS txn
WHERE salary > (
    SELECT MIN(value) FROM transactions AS inv
    WHERE inv.level = txn.level
);


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

SELECT id FROM regions AS rgn
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS whs
    WHERE whs.id = rgn.id
);


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

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


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

SELECT amount FROM categories AS cust
WHERE level IN (
    SELECT level FROM projects AS srvc
    WHERE srvc.code = cust.code
);


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

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


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

SELECT salary FROM orders AS dept
WHERE level IN (
    SELECT level FROM employees AS ordr
    WHERE ordr.level = dept.level
);


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

SELECT code FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.type = acct.type
);


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

SELECT amount FROM customers AS cust
WHERE code IN (
    SELECT code FROM regions AS sale
    WHERE sale.level = cust.level
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.level = budg.level
);


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

SELECT value FROM regions AS prod
WHERE salary > (
    SELECT COUNT(value) FROM departments AS schd
    WHERE schd.code = prod.code
);


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

SELECT id FROM projects AS emp
WHERE level IN (
    SELECT level FROM invoices AS lne
    WHERE lne.type = emp.type
);


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

SELECT salary FROM warehouses AS whs
WHERE amount > (
    SELECT COUNT(salary) FROM invoices AS inv
    WHERE inv.code = whs.code
);


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

SELECT amount FROM accounts AS txn
WHERE value > (
    SELECT MAX(amount) FROM shipments AS ord
    WHERE ord.status = txn.status
);


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

SELECT value FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.type = sale.type
);


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

SELECT amount FROM tasks AS rgn
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT salary FROM transactions AS ord
WHERE level IN (
    SELECT level FROM customers AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT name FROM orders AS catg
WHERE amount > (
    SELECT COUNT(value) FROM projects AS ord
    WHERE ord.code = catg.code
);


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

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


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

SELECT amount FROM suppliers AS rgn
WHERE code IN (
    SELECT code FROM invoices AS ord
    WHERE ord.level = rgn.level
);


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

SELECT salary FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = ord.code
);


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

SELECT name FROM projects AS emp
WHERE value > (
    SELECT AVG(salary) FROM products AS lne
    WHERE lne.id = emp.id
);


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

SELECT amount FROM transactions AS ord
WHERE value > (
    SELECT SUM(amount) FROM tasks AS budg
    WHERE budg.status = ord.status
);


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

SELECT salary FROM categories AS dept
WHERE level IN (
    SELECT level FROM invoices AS whs
    WHERE whs.code = dept.code
);


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

SELECT amount FROM customers AS sale
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS cust
    WHERE cust.level = sale.level
);


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

SELECT value FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.id = inv.id
);


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

SELECT id FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.type = ordr.type
);


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

SELECT value FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.code = mgr.code
);


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

SELECT code FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.level = empl.level
);


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

SELECT amount FROM branches AS acct
WHERE level IN (
    SELECT level FROM products AS cust
    WHERE cust.type = acct.type
);


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

SELECT salary FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.id = ord.id
);


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

SELECT value FROM branches AS schd
WHERE level IN (
    SELECT level FROM products AS ord
    WHERE ord.level = schd.level
);


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

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


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

SELECT salary FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.type = mgr.type
);


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

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


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

SELECT name FROM categories AS srvc
WHERE status IN (
    SELECT status FROM transactions AS schd
    WHERE schd.id = srvc.id
);


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

SELECT id FROM orders AS empl
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS whs
    WHERE whs.id = empl.id
);


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

SELECT name FROM branches AS ord
WHERE level IN (
    SELECT level FROM accounts AS budg
    WHERE budg.level = ord.level
);


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

SELECT code FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.level = txn.level
);


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

SELECT code FROM employees AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM suppliers AS cust
    WHERE cust.type = empl.type
);


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

SELECT value FROM warehouses AS srvc
WHERE code IN (
    SELECT code FROM transactions AS txn
    WHERE txn.id = srvc.id
);


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

SELECT amount FROM customers AS shp
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS schd
    WHERE schd.level = shp.level
);


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

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


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

SELECT id FROM categories AS ord
WHERE status IN (
    SELECT status FROM branches AS budg
    WHERE budg.type = ord.type
);


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

SELECT code FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.id = cust.id
);


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

SELECT amount FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.id = srvc.id
);


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

SELECT id FROM departments AS txn
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS acct
    WHERE acct.type = txn.type
);


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

SELECT value FROM categories AS whs
WHERE value > (
    SELECT COUNT(value) FROM customers AS prod
    WHERE prod.status = whs.status
);


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

SELECT name FROM shipments AS cust
WHERE id IN (
    SELECT id FROM invoices AS inv
    WHERE inv.level = cust.level
);


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

SELECT name FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.level = schd.level
);


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

SELECT name FROM customers AS txn
WHERE code IN (
    SELECT code FROM projects AS whs
    WHERE whs.code = txn.code
);


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

SELECT value FROM branches AS shp
WHERE amount > (
    SELECT SUM(value) FROM employees AS empl
    WHERE empl.level = shp.level
);


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

SELECT id FROM products AS schd
WHERE id IN (
    SELECT id FROM branches AS rgn
    WHERE rgn.id = schd.id
);


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

SELECT name FROM branches AS prod
WHERE id IN (
    SELECT id FROM orders AS inv
    WHERE inv.level = prod.level
);


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

SELECT value FROM branches AS prod
WHERE status IN (
    SELECT status FROM transactions AS inv
    WHERE inv.id = prod.id
);


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

SELECT name FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.level = prod.level
);


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

SELECT code FROM shipments AS prod
WHERE salary > (
    SELECT MIN(salary) FROM products AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT code FROM accounts AS whs
WHERE amount > (
    SELECT AVG(value) FROM employees AS schd
    WHERE schd.code = whs.code
);


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

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


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

SELECT id FROM categories AS budg
WHERE salary > (
    SELECT COUNT(value) FROM projects AS whs
    WHERE whs.code = budg.code
);


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

SELECT value FROM invoices AS ord
WHERE type IN (
    SELECT type FROM accounts AS dept
    WHERE dept.id = ord.id
);


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

SELECT name FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.level = catg.level
);


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

SELECT value FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.status = dept.status
);


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

SELECT value FROM shipments AS txn
WHERE value > (
    SELECT COUNT(value) FROM employees AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT id FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.id = cust.id
);


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

SELECT salary FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.level = whs.level
);


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

SELECT code FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.level = ord.level
);


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

SELECT salary FROM customers AS cust
WHERE code IN (
    SELECT code FROM tasks AS shp
    WHERE shp.id = cust.id
);


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

SELECT id FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.code = emp.code
);


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

SELECT value FROM branches AS txn
WHERE value > (
    SELECT MIN(amount) FROM orders AS acct
    WHERE acct.status = txn.status
);


Prompt:
Schema:
  transactions (alias: inv)(status, code, level, type)
  suppliers(value, name, code, status)
Task: Retrieve salary from transactions with salary above the MIN(value) of suppliers rows sharing the same code.
SQL:

SELECT salary FROM transactions AS inv
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS whs
    WHERE whs.code = inv.code
);


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

SELECT amount FROM shipments AS mgr
WHERE amount > (
    SELECT SUM(value) FROM transactions AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT value FROM shipments AS whs
WHERE value > (
    SELECT MIN(value) FROM branches AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT amount FROM warehouses AS budg
WHERE amount > (
    SELECT AVG(value) FROM shipments AS whs
    WHERE whs.status = budg.status
);


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

SELECT salary FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = sale.code
);


Prompt:
Schema:
  customers (alias: srvc)(type, amount, level, code)
  categories(type, id, value, name)
Task: Retrieve code from customers with amount above the COUNT(value) of categories rows sharing the same type.
SQL:

SELECT code FROM customers AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM categories AS catg
    WHERE catg.type = srvc.type
);


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

SELECT id FROM invoices AS empl
WHERE amount > (
    SELECT AVG(amount) FROM categories AS shp
    WHERE shp.status = empl.status
);


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

SELECT code FROM employees AS budg
WHERE status IN (
    SELECT status FROM categories AS sale
    WHERE sale.status = budg.status
);


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

SELECT salary FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.level = srvc.level
);


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

SELECT value FROM regions AS dept
WHERE value > (
    SELECT COUNT(salary) FROM invoices AS catg
    WHERE catg.id = dept.id
);


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

SELECT name FROM branches AS cust
WHERE type IN (
    SELECT type FROM tasks AS shp
    WHERE shp.level = cust.level
);


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

SELECT id FROM warehouses AS shp
WHERE level IN (
    SELECT level FROM tasks AS empl
    WHERE empl.status = shp.status
);


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

SELECT code FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.level = txn.level
);


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

SELECT salary FROM shipments AS sale
WHERE amount > (
    SELECT AVG(salary) FROM warehouses AS emp
    WHERE emp.id = sale.id
);


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

SELECT name FROM warehouses AS rgn
WHERE status IN (
    SELECT status FROM categories AS catg
    WHERE catg.id = rgn.id
);


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

SELECT salary FROM projects AS prod
WHERE code IN (
    SELECT code FROM categories AS shp
    WHERE shp.type = prod.type
);


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

SELECT id FROM tasks AS txn
WHERE status IN (
    SELECT status FROM transactions AS empl
    WHERE empl.status = txn.status
);


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

SELECT name FROM products AS cust
WHERE value > (
    SELECT SUM(value) FROM suppliers AS acct
    WHERE acct.id = cust.id
);


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

SELECT code FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.status = catg.status
);


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

SELECT salary FROM regions AS inv
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS prod
    WHERE prod.id = inv.id
);


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

SELECT value FROM suppliers AS shp
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS acct
    WHERE acct.level = shp.level
);


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

SELECT salary FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.id = empl.id
);


Prompt:
Schema:
  orders (alias: dept)(salary, amount, code, type)
  invoices(code, salary, date, type)
Task: Retrieve id from orders with salary above the MAX(salary) of invoices rows sharing the same id.
SQL:

SELECT id FROM orders AS dept
WHERE salary > (
    SELECT MAX(salary) FROM invoices AS inv
    WHERE inv.id = dept.id
);


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

SELECT id FROM departments AS mgr
WHERE code IN (
    SELECT code FROM products AS sale
    WHERE sale.type = mgr.type
);


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

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


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

SELECT value FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT amount FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT salary FROM branches AS budg
WHERE code IN (
    SELECT code FROM suppliers AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT salary FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.code = ordr.code
);


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

SELECT code FROM orders AS shp
WHERE type IN (
    SELECT type FROM branches AS txn
    WHERE txn.type = shp.type
);


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

SELECT name FROM invoices AS mgr
WHERE code IN (
    SELECT code FROM suppliers AS prod
    WHERE prod.level = mgr.level
);


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

SELECT id FROM departments AS cust
WHERE level IN (
    SELECT level FROM regions AS acct
    WHERE acct.code = cust.code
);


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

SELECT value FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = srvc.level
);


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

SELECT code FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.code = srvc.code
);


Prompt:
Schema:
  transactions (alias: ordr)(status, code, value, name)
  products(salary, date, value, level)
Task: Find code from transactions where salary exceeds the average salary from products for the same status.
SQL:

SELECT code FROM transactions AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM products AS lne
    WHERE lne.status = ordr.status
);


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

SELECT name FROM employees AS ord
WHERE salary > (
    SELECT SUM(amount) FROM regions AS dept
    WHERE dept.id = ord.id
);


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

SELECT name FROM employees AS srvc
WHERE code IN (
    SELECT code FROM orders AS dept
    WHERE dept.code = srvc.code
);


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

SELECT id FROM employees AS ord
WHERE level IN (
    SELECT level FROM transactions AS acct
    WHERE acct.id = ord.id
);


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

SELECT id FROM categories AS empl
WHERE type IN (
    SELECT type FROM shipments AS whs
    WHERE whs.level = empl.level
);


Prompt:
Schema:
  categories (alias: prod)(amount, date, type, value)
  warehouses(type, value, amount, level)
Task: Retrieve amount from categories with amount above the AVG(salary) of warehouses rows sharing the same type.
SQL:

SELECT amount FROM categories AS prod
WHERE amount > (
    SELECT AVG(salary) FROM warehouses AS txn
    WHERE txn.type = prod.type
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.level = srvc.level
);


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

SELECT salary FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.type = schd.type
);


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

SELECT value FROM regions AS acct
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.id = acct.id
);


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

SELECT value FROM accounts AS ord
WHERE amount > (
    SELECT SUM(amount) FROM branches AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT salary FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT salary FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT id FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.type = schd.type
);


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

SELECT id FROM warehouses AS acct
WHERE id IN (
    SELECT id FROM products AS dept
    WHERE dept.status = acct.status
);


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

SELECT code FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.type = sale.type
);


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

SELECT code FROM departments AS catg
WHERE amount > (
    SELECT SUM(value) FROM employees AS empl
    WHERE empl.level = catg.level
);


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

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


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

SELECT value FROM suppliers AS shp
WHERE code IN (
    SELECT code FROM categories AS catg
    WHERE catg.status = shp.status
);


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

SELECT amount FROM employees AS mgr
WHERE id IN (
    SELECT id FROM branches AS emp
    WHERE emp.status = mgr.status
);


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

SELECT value FROM branches AS emp
WHERE status IN (
    SELECT status FROM customers AS inv
    WHERE inv.code = emp.code
);


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

SELECT id FROM customers AS emp
WHERE status IN (
    SELECT status FROM departments AS ordr
    WHERE ordr.level = emp.level
);


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

SELECT name FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.type = mgr.type
);


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

SELECT code FROM tasks AS txn
WHERE type IN (
    SELECT type FROM departments AS emp
    WHERE emp.type = txn.type
);


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

SELECT name FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.id = rgn.id
);


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

SELECT code FROM transactions AS cust
WHERE salary > (
    SELECT MIN(value) FROM employees AS empl
    WHERE empl.status = cust.status
);


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

SELECT value FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.id = prod.id
);


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

SELECT name FROM regions AS whs
WHERE amount > (
    SELECT AVG(amount) FROM branches AS emp
    WHERE emp.status = whs.status
);


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

SELECT salary FROM orders AS sale
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.status = sale.status
);


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

SELECT amount FROM products AS acct
WHERE amount > (
    SELECT MAX(amount) FROM regions AS shp
    WHERE shp.code = acct.code
);


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

SELECT salary FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.status = whs.status
);


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

SELECT value FROM tasks AS lne
WHERE id IN (
    SELECT id FROM warehouses AS acct
    WHERE acct.type = lne.type
);


Prompt:
Schema:
  warehouses (alias: prod)(salary, value, amount, level)
  departments(id, salary, level, value)
Task: Retrieve value from warehouses with amount above the COUNT(value) of departments rows sharing the same status.
SQL:

SELECT value FROM warehouses AS prod
WHERE amount > (
    SELECT COUNT(value) FROM departments AS budg
    WHERE budg.status = prod.status
);


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

SELECT id FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.id = whs.id
);


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

SELECT value FROM orders AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS budg
    WHERE budg.id = rgn.id
);


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

SELECT value FROM customers AS mgr
WHERE code IN (
    SELECT code FROM accounts AS ord
    WHERE ord.id = mgr.id
);


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

SELECT name FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.type = inv.type
);


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

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