Prompt:
Schema:
  orders (alias: schd)(date, amount, id, level)
  transactions(id, type, amount, level)
Task: Find id from orders where code appears in transactions entries with matching level.
SQL:

SELECT id FROM orders AS schd
WHERE code IN (
    SELECT code FROM transactions AS txn
    WHERE txn.level = schd.level
);


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

SELECT amount FROM orders AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM departments AS budg
    WHERE budg.level = srvc.level
);


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

SELECT amount FROM tasks AS empl
WHERE id IN (
    SELECT id FROM orders AS emp
    WHERE emp.code = empl.code
);


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

SELECT value FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.type = catg.type
);


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

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


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

SELECT salary FROM branches AS prod
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS lne
    WHERE lne.id = prod.id
);


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

SELECT code FROM employees AS dept
WHERE value > (
    SELECT MAX(value) FROM orders AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT value FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.id = shp.id
);


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

SELECT code FROM shipments AS prod
WHERE status IN (
    SELECT status FROM employees AS txn
    WHERE txn.type = prod.type
);


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

SELECT code FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.code = lne.code
);


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

SELECT id FROM departments AS acct
WHERE salary > (
    SELECT MAX(amount) FROM employees AS inv
    WHERE inv.code = acct.code
);


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

SELECT name FROM tasks AS prod
WHERE amount > (
    SELECT MIN(amount) FROM employees AS catg
    WHERE catg.id = prod.id
);


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

SELECT amount FROM tasks AS txn
WHERE type IN (
    SELECT type FROM employees AS dept
    WHERE dept.level = txn.level
);


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

SELECT id FROM customers AS ord
WHERE level IN (
    SELECT level FROM products AS catg
    WHERE catg.id = ord.id
);


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

SELECT id FROM tasks AS schd
WHERE amount > (
    SELECT MAX(amount) FROM employees AS catg
    WHERE catg.level = schd.level
);


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

SELECT name FROM warehouses AS srvc
WHERE level IN (
    SELECT level FROM employees AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT value FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.type = sale.type
);


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

SELECT value FROM tasks AS emp
WHERE code IN (
    SELECT code FROM warehouses AS ordr
    WHERE ordr.level = emp.level
);


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

SELECT name FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.code = prod.code
);


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

SELECT name FROM accounts AS sale
WHERE id IN (
    SELECT id FROM orders AS cust
    WHERE cust.level = sale.level
);


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

SELECT value FROM shipments AS rgn
WHERE value > (
    SELECT MAX(amount) FROM employees AS sale
    WHERE sale.code = rgn.code
);


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

SELECT name FROM accounts AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM suppliers AS budg
    WHERE budg.status = mgr.status
);


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

SELECT id FROM employees AS mgr
WHERE level IN (
    SELECT level FROM regions AS budg
    WHERE budg.code = mgr.code
);


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

SELECT name FROM shipments AS schd
WHERE status IN (
    SELECT status FROM orders AS whs
    WHERE whs.id = schd.id
);


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

SELECT id FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.type = txn.type
);


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

SELECT id FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.code = empl.code
);


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

SELECT name FROM categories AS budg
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT name FROM suppliers AS emp
WHERE code IN (
    SELECT code FROM tasks AS prod
    WHERE prod.status = emp.status
);


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

SELECT id FROM departments AS cust
WHERE amount > (
    SELECT SUM(value) FROM categories AS whs
    WHERE whs.id = cust.id
);


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

SELECT value FROM employees AS catg
WHERE amount > (
    SELECT SUM(value) FROM transactions AS inv
    WHERE inv.id = catg.id
);


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

SELECT code FROM employees AS mgr
WHERE value > (
    SELECT AVG(value) FROM shipments AS whs
    WHERE whs.code = mgr.code
);


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

SELECT id FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.id = txn.id
);


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

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


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

SELECT code FROM regions AS catg
WHERE code IN (
    SELECT code FROM departments AS lne
    WHERE lne.type = catg.type
);


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

SELECT value FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.code = rgn.code
);


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

SELECT value FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.level = catg.level
);


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

SELECT amount FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.status = empl.status
);


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

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


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

SELECT name FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.level = rgn.level
);


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

SELECT amount FROM warehouses AS prod
WHERE level IN (
    SELECT level FROM shipments AS schd
    WHERE schd.level = prod.level
);


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

SELECT salary FROM orders AS txn
WHERE value > (
    SELECT MAX(amount) FROM tasks AS prod
    WHERE prod.status = txn.status
);


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

SELECT code FROM accounts AS ordr
WHERE type IN (
    SELECT type FROM warehouses AS emp
    WHERE emp.type = ordr.type
);


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

SELECT code FROM customers AS inv
WHERE amount > (
    SELECT COUNT(value) FROM departments AS shp
    WHERE shp.status = inv.status
);


Prompt:
Schema:
  employees (alias: lne)(status, amount, salary, value)
  invoices(value, salary, type, date)
Task: Retrieve name from employees with salary above the SUM(value) of invoices rows sharing the same status.
SQL:

SELECT name FROM employees AS lne
WHERE salary > (
    SELECT SUM(value) FROM invoices AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT code FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.type = shp.type
);


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

SELECT code FROM shipments AS cust
WHERE value > (
    SELECT COUNT(value) FROM departments AS empl
    WHERE empl.status = cust.status
);


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

SELECT code FROM warehouses AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS txn
    WHERE txn.id = empl.id
);


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

SELECT amount FROM accounts AS rgn
WHERE type IN (
    SELECT type FROM orders AS dept
    WHERE dept.type = rgn.type
);


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

SELECT value FROM invoices AS prod
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT amount FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.level = dept.level
);


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

SELECT code FROM invoices AS rgn
WHERE id IN (
    SELECT id FROM orders AS cust
    WHERE cust.level = rgn.level
);


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

SELECT salary FROM customers AS whs
WHERE amount > (
    SELECT AVG(salary) FROM projects AS cust
    WHERE cust.code = whs.code
);


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

SELECT name FROM categories AS txn
WHERE type IN (
    SELECT type FROM accounts AS sale
    WHERE sale.id = txn.id
);


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

SELECT code FROM suppliers AS schd
WHERE amount > (
    SELECT AVG(salary) FROM employees AS txn
    WHERE txn.type = schd.type
);


Prompt:
Schema:
  employees (alias: sale)(salary, code, level, status)
  warehouses(date, salary, status, code)
Task: Retrieve id from employees with salary above the AVG(salary) of warehouses rows sharing the same id.
SQL:

SELECT id FROM employees AS sale
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS dept
    WHERE dept.id = sale.id
);


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

SELECT value FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.level = mgr.level
);


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

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


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

SELECT amount FROM regions AS budg
WHERE code IN (
    SELECT code FROM branches AS acct
    WHERE acct.code = budg.code
);


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

SELECT amount FROM transactions AS ordr
WHERE id IN (
    SELECT id FROM shipments AS budg
    WHERE budg.id = ordr.id
);


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

SELECT name FROM suppliers AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS shp
    WHERE shp.id = schd.id
);


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

SELECT value FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.status = ordr.status
);


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

SELECT value FROM suppliers AS ordr
WHERE status IN (
    SELECT status FROM departments AS acct
    WHERE acct.level = ordr.level
);


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

SELECT id FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM orders AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT value FROM transactions AS prod
WHERE value > (
    SELECT SUM(salary) FROM orders AS whs
    WHERE whs.status = prod.status
);


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

SELECT name FROM warehouses AS ordr
WHERE value > (
    SELECT AVG(amount) FROM employees AS cust
    WHERE cust.level = ordr.level
);


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

SELECT id FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.type = cust.type
);


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

SELECT code FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.status = emp.status
);


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

SELECT id FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.level = acct.level
);


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

SELECT name FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.id = dept.id
);


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

SELECT value FROM projects AS lne
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.status = lne.status
);


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

SELECT salary FROM tasks AS inv
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.code = inv.code
);


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

SELECT name FROM accounts AS txn
WHERE salary > (
    SELECT MIN(amount) FROM branches AS inv
    WHERE inv.level = txn.level
);


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

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


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

SELECT id FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.status = cust.status
);


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

SELECT salary FROM employees AS catg
WHERE type IN (
    SELECT type FROM accounts AS rgn
    WHERE rgn.id = catg.id
);


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

SELECT value FROM suppliers AS ordr
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.type = ordr.type
);


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

SELECT name FROM suppliers AS txn
WHERE type IN (
    SELECT type FROM categories AS lne
    WHERE lne.id = txn.id
);


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

SELECT salary FROM warehouses AS sale
WHERE id IN (
    SELECT id FROM products AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT amount FROM products AS whs
WHERE id IN (
    SELECT id FROM transactions AS empl
    WHERE empl.status = whs.status
);


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

SELECT amount FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.id = schd.id
);


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

SELECT value FROM branches AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS prod
    WHERE prod.type = catg.type
);


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

SELECT id FROM shipments AS schd
WHERE amount > (
    SELECT COUNT(value) FROM transactions AS txn
    WHERE txn.status = schd.status
);


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

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


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

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


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

SELECT amount FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.type = emp.type
);


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

SELECT name FROM accounts AS schd
WHERE type IN (
    SELECT type FROM branches AS ordr
    WHERE ordr.code = schd.code
);


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

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


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

SELECT value FROM orders AS acct
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS budg
    WHERE budg.id = acct.id
);


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

SELECT amount FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.code = ordr.code
);


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

SELECT id FROM projects AS prod
WHERE type IN (
    SELECT type FROM customers AS lne
    WHERE lne.code = prod.code
);


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

SELECT id FROM customers AS empl
WHERE type IN (
    SELECT type FROM departments AS srvc
    WHERE srvc.level = empl.level
);


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

SELECT value FROM employees AS sale
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.level = sale.level
);


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

SELECT amount FROM warehouses AS catg
WHERE amount > (
    SELECT SUM(salary) FROM customers AS txn
    WHERE txn.status = catg.status
);


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

SELECT value FROM projects AS prod
WHERE salary > (
    SELECT MAX(value) FROM regions AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT amount FROM invoices AS ord
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT code FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.level = budg.level
);


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

SELECT id FROM transactions AS catg
WHERE salary > (
    SELECT SUM(value) FROM employees AS lne
    WHERE lne.status = catg.status
);


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

SELECT code FROM invoices AS srvc
WHERE amount > (
    SELECT SUM(salary) FROM customers AS inv
    WHERE inv.level = srvc.level
);


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

SELECT code FROM departments AS dept
WHERE type IN (
    SELECT type FROM shipments AS whs
    WHERE whs.id = dept.id
);


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

SELECT salary FROM projects AS prod
WHERE amount > (
    SELECT COUNT(value) FROM customers AS srvc
    WHERE srvc.level = prod.level
);


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

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


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

SELECT salary FROM tasks AS budg
WHERE code IN (
    SELECT code FROM products AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT id FROM invoices AS prod
WHERE value > (
    SELECT SUM(amount) FROM departments AS inv
    WHERE inv.id = prod.id
);


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT MAX(value) FROM categories AS inv
    WHERE inv.level = shp.level
);


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

SELECT id FROM departments AS mgr
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT value FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = sale.level
);


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

SELECT salary FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.id = lne.id
);


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

SELECT id FROM orders AS inv
WHERE value > (
    SELECT MAX(salary) FROM tasks AS acct
    WHERE acct.status = inv.status
);


Prompt:
Schema:
  invoices (alias: cust)(type, status, code, value)
  transactions(amount, level, value, code)
Task: Retrieve amount from invoices with amount above the MAX(amount) of transactions rows sharing the same status.
SQL:

SELECT amount FROM invoices AS cust
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT id FROM employees AS dept
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT amount FROM suppliers AS schd
WHERE salary > (
    SELECT COUNT(value) FROM employees AS empl
    WHERE empl.type = schd.type
);


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

SELECT amount FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT code FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.code = rgn.code
);


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

SELECT value FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.type = rgn.type
);


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

SELECT value FROM branches AS rgn
WHERE salary > (
    SELECT MAX(value) FROM regions AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT name FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.status = cust.status
);


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

SELECT code FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.id = inv.id
);


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

SELECT salary FROM customers AS srvc
WHERE value > (
    SELECT AVG(salary) FROM accounts AS sale
    WHERE sale.level = srvc.level
);


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

SELECT name FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.code = schd.code
);


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

SELECT salary FROM accounts AS rgn
WHERE value > (
    SELECT AVG(value) FROM invoices AS ord
    WHERE ord.type = rgn.type
);


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

SELECT code FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT code FROM warehouses AS empl
WHERE salary > (
    SELECT COUNT(value) FROM categories AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT id FROM employees AS txn
WHERE id IN (
    SELECT id FROM categories AS cust
    WHERE cust.code = txn.code
);


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

SELECT id FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.type = ordr.type
);


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

SELECT salary FROM regions AS shp
WHERE value > (
    SELECT MIN(salary) FROM shipments AS prod
    WHERE prod.type = shp.type
);


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

SELECT amount FROM categories AS ordr
WHERE amount > (
    SELECT COUNT(value) FROM products AS cust
    WHERE cust.type = ordr.type
);


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

SELECT amount FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.type = cust.type
);


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

SELECT amount FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.type = ordr.type
);


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

SELECT name FROM employees AS inv
WHERE amount > (
    SELECT MIN(salary) FROM suppliers AS whs
    WHERE whs.code = inv.code
);


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

SELECT salary FROM employees AS mgr
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS acct
    WHERE acct.level = mgr.level
);


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

SELECT id FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.status = lne.status
);


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

SELECT name FROM projects AS sale
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.code = sale.code
);


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

SELECT salary FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.level = cust.level
);


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

SELECT salary FROM projects AS rgn
WHERE amount > (
    SELECT SUM(value) FROM warehouses AS lne
    WHERE lne.level = rgn.level
);


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

SELECT value FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.level = inv.level
);


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

SELECT value FROM employees AS acct
WHERE value > (
    SELECT MAX(salary) FROM products AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT code FROM departments AS catg
WHERE level IN (
    SELECT level FROM shipments AS emp
    WHERE emp.id = catg.id
);


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

SELECT code FROM shipments AS txn
WHERE salary > (
    SELECT AVG(salary) FROM regions AS prod
    WHERE prod.id = txn.id
);


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

SELECT value FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.id = inv.id
);


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

SELECT code FROM tasks AS ord
WHERE id IN (
    SELECT id FROM warehouses AS acct
    WHERE acct.status = ord.status
);


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

SELECT name FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.code = ordr.code
);


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

SELECT value FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.code = prod.code
);


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

SELECT value FROM employees AS shp
WHERE code IN (
    SELECT code FROM accounts AS catg
    WHERE catg.id = shp.id
);


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

SELECT code FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.code = prod.code
);


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

SELECT name FROM invoices AS srvc
WHERE salary > (
    SELECT SUM(value) FROM customers AS txn
    WHERE txn.id = srvc.id
);


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

SELECT salary FROM employees AS budg
WHERE salary > (
    SELECT MIN(salary) FROM departments AS schd
    WHERE schd.type = budg.type
);


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

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


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

SELECT code FROM accounts AS mgr
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS sale
    WHERE sale.level = mgr.level
);


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

SELECT id FROM accounts AS sale
WHERE value > (
    SELECT SUM(salary) FROM orders AS lne
    WHERE lne.code = sale.code
);


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

SELECT value FROM regions AS txn
WHERE value > (
    SELECT MIN(salary) FROM invoices AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT value FROM transactions AS schd
WHERE level IN (
    SELECT level FROM orders AS shp
    WHERE shp.level = schd.level
);


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

SELECT code FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.id = inv.id
);


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

SELECT value FROM employees AS budg
WHERE type IN (
    SELECT type FROM orders AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT value FROM categories AS empl
WHERE value > (
    SELECT MIN(value) FROM projects AS rgn
    WHERE rgn.code = empl.code
);


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

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


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

SELECT salary FROM shipments AS catg
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS budg
    WHERE budg.type = catg.type
);


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

SELECT code FROM shipments AS rgn
WHERE type IN (
    SELECT type FROM departments AS ord
    WHERE ord.id = rgn.id
);


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

SELECT id FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.type = budg.type
);


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

SELECT salary FROM products AS ordr
WHERE id IN (
    SELECT id FROM warehouses AS emp
    WHERE emp.id = ordr.id
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.level = rgn.level
);


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

SELECT code FROM tasks AS budg
WHERE amount > (
    SELECT COUNT(value) FROM suppliers AS inv
    WHERE inv.level = budg.level
);


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

SELECT id FROM shipments AS dept
WHERE value > (
    SELECT COUNT(salary) FROM branches AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT id FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.code = cust.code
);


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

SELECT salary FROM suppliers AS ordr
WHERE id IN (
    SELECT id FROM orders AS dept
    WHERE dept.type = ordr.type
);


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

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


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

SELECT id FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.status = txn.status
);


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

SELECT code FROM tasks AS srvc
WHERE status IN (
    SELECT status FROM customers AS prod
    WHERE prod.code = srvc.code
);


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

SELECT amount FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.status = whs.status
);


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

SELECT code FROM shipments AS sale
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS dept
    WHERE dept.level = sale.level
);


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

SELECT name FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT value FROM products AS schd
WHERE level IN (
    SELECT level FROM shipments AS emp
    WHERE emp.level = schd.level
);


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

SELECT id FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.level = mgr.level
);


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

SELECT amount FROM tasks AS ord
WHERE code IN (
    SELECT code FROM projects AS catg
    WHERE catg.level = ord.level
);


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

SELECT code FROM suppliers AS budg
WHERE type IN (
    SELECT type FROM branches AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT value FROM warehouses AS budg
WHERE salary > (
    SELECT AVG(salary) FROM orders AS dept
    WHERE dept.status = budg.status
);


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

SELECT name FROM tasks AS schd
WHERE amount > (
    SELECT MIN(salary) FROM transactions AS sale
    WHERE sale.type = schd.type
);


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

SELECT amount FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.code = catg.code
);


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

SELECT salary FROM suppliers AS ordr
WHERE level IN (
    SELECT level FROM products AS inv
    WHERE inv.id = ordr.id
);


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

SELECT salary FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.type = txn.type
);


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

SELECT amount FROM employees AS emp
WHERE amount > (
    SELECT MAX(amount) FROM customers AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT id FROM shipments AS empl
WHERE status IN (
    SELECT status FROM branches AS emp
    WHERE emp.status = empl.status
);


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

SELECT code FROM accounts AS inv
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.code = shp.code
);


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

SELECT name FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.status = inv.status
);


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

SELECT id FROM branches AS dept
WHERE value > (
    SELECT MAX(amount) FROM tasks AS sale
    WHERE sale.type = dept.type
);


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

SELECT value FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.status = mgr.status
);


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

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


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

SELECT code FROM shipments AS cust
WHERE salary > (
    SELECT COUNT(value) FROM branches AS catg
    WHERE catg.code = cust.code
);


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

SELECT salary FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.type = schd.type
);


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

SELECT id FROM categories AS rgn
WHERE code IN (
    SELECT code FROM departments AS shp
    WHERE shp.code = rgn.code
);


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

SELECT value FROM projects AS budg
WHERE value > (
    SELECT COUNT(value) FROM invoices AS rgn
    WHERE rgn.type = budg.type
);


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

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


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

SELECT code FROM regions AS rgn
WHERE amount > (
    SELECT AVG(salary) FROM customers AS prod
    WHERE prod.code = rgn.code
);


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

SELECT name FROM tasks AS shp
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS acct
    WHERE acct.type = shp.type
);


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

SELECT id FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.level = txn.level
);


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

SELECT value FROM categories AS whs
WHERE status IN (
    SELECT status FROM departments AS shp
    WHERE shp.code = whs.code
);


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

SELECT salary FROM categories AS dept
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.status = dept.status
);


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

SELECT id FROM warehouses AS cust
WHERE salary > (
    SELECT SUM(salary) FROM employees AS emp
    WHERE emp.level = cust.level
);


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

SELECT amount FROM warehouses AS inv
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS txn
    WHERE txn.type = inv.type
);


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

SELECT id FROM products AS prod
WHERE level IN (
    SELECT level FROM suppliers AS whs
    WHERE whs.id = prod.id
);


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

SELECT id FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.level = schd.level
);


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

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


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

SELECT salary FROM regions AS budg
WHERE value > (
    SELECT COUNT(amount) FROM accounts AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT value FROM tasks AS budg
WHERE amount > (
    SELECT COUNT(value) FROM products AS dept
    WHERE dept.id = budg.id
);


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

SELECT value FROM transactions AS rgn
WHERE value > (
    SELECT SUM(value) FROM accounts AS dept
    WHERE dept.status = rgn.status
);


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

SELECT id FROM categories AS dept
WHERE salary > (
    SELECT AVG(salary) FROM customers AS srvc
    WHERE srvc.code = dept.code
);


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

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


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

SELECT name FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.status = srvc.status
);


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

SELECT value FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.id = emp.id
);


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

SELECT id FROM customers AS prod
WHERE code IN (
    SELECT code FROM tasks AS schd
    WHERE schd.id = prod.id
);


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

SELECT code FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT amount FROM categories AS sale
WHERE id IN (
    SELECT id FROM employees AS ord
    WHERE ord.code = sale.code
);


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

SELECT id FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT value FROM branches AS inv
WHERE type IN (
    SELECT type FROM customers AS dept
    WHERE dept.code = inv.code
);


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

SELECT amount FROM accounts AS sale
WHERE type IN (
    SELECT type FROM products AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT value FROM tasks AS cust
WHERE salary > (
    SELECT MIN(salary) FROM products AS shp
    WHERE shp.status = cust.status
);


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

SELECT amount FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.id = rgn.id
);


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

SELECT code FROM warehouses AS emp
WHERE level IN (
    SELECT level FROM products AS mgr
    WHERE mgr.level = emp.level
);


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

SELECT code FROM customers AS empl
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS catg
    WHERE catg.level = empl.level
);


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

SELECT code FROM invoices AS inv
WHERE code IN (
    SELECT code FROM shipments AS srvc
    WHERE srvc.status = inv.status
);


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

SELECT id FROM regions AS mgr
WHERE amount > (
    SELECT MIN(amount) FROM branches AS acct
    WHERE acct.code = mgr.code
);


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

SELECT id FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.level = catg.level
);


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

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


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

SELECT name FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.id = emp.id
);


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

SELECT amount FROM invoices AS cust
WHERE salary > (
    SELECT AVG(salary) FROM customers AS emp
    WHERE emp.status = cust.status
);


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

SELECT id FROM warehouses AS shp
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.id = shp.id
);


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

SELECT salary FROM transactions AS sale
WHERE level IN (
    SELECT level FROM orders AS catg
    WHERE catg.status = sale.status
);


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

SELECT code FROM regions AS lne
WHERE amount > (
    SELECT MIN(amount) FROM categories AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT value FROM transactions AS prod
WHERE value > (
    SELECT MAX(salary) FROM invoices AS catg
    WHERE catg.id = prod.id
);


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

SELECT id FROM departments AS emp
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS txn
    WHERE txn.id = emp.id
);


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

SELECT salary FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.code = dept.code
);


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

SELECT amount FROM categories AS ordr
WHERE type IN (
    SELECT type FROM regions AS mgr
    WHERE mgr.id = ordr.id
);


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

SELECT name FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.type = mgr.type
);


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

SELECT value FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = inv.status
);


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

SELECT amount FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.status = schd.status
);


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

SELECT amount FROM regions AS empl
WHERE level IN (
    SELECT level FROM shipments AS whs
    WHERE whs.type = empl.type
);


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

SELECT amount FROM shipments AS ord
WHERE id IN (
    SELECT id FROM categories AS dept
    WHERE dept.id = ord.id
);


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

SELECT amount FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.code = shp.code
);


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

SELECT name FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.id = rgn.id
);


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

SELECT name FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.id = ord.id
);


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

SELECT value FROM transactions AS inv
WHERE amount > (
    SELECT SUM(value) FROM suppliers AS ord
    WHERE ord.code = inv.code
);


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

SELECT value FROM categories AS catg
WHERE amount > (
    SELECT AVG(value) FROM invoices AS shp
    WHERE shp.code = catg.code
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.id = rgn.id
);


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

SELECT id FROM employees AS whs
WHERE status IN (
    SELECT status FROM departments AS budg
    WHERE budg.type = whs.type
);


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

SELECT name FROM accounts AS cust
WHERE value > (
    SELECT SUM(value) FROM products AS txn
    WHERE txn.level = cust.level
);


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

SELECT code FROM employees AS mgr
WHERE type IN (
    SELECT type FROM branches AS prod
    WHERE prod.code = mgr.code
);


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

SELECT code FROM categories AS whs
WHERE value > (
    SELECT MIN(amount) FROM branches AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT id FROM transactions AS prod
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS ord
    WHERE ord.id = prod.id
);


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

SELECT code FROM shipments AS rgn
WHERE level IN (
    SELECT level FROM invoices AS empl
    WHERE empl.status = rgn.status
);


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

SELECT value FROM products AS lne
WHERE status IN (
    SELECT status FROM employees AS prod
    WHERE prod.code = lne.code
);


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

SELECT code FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.status = ordr.status
);


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

SELECT name FROM tasks AS ordr
WHERE type IN (
    SELECT type FROM warehouses AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT id FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.type = empl.type
);


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

SELECT id FROM projects AS srvc
WHERE amount > (
    SELECT MIN(value) FROM shipments AS whs
    WHERE whs.code = srvc.code
);


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

SELECT salary FROM regions AS whs
WHERE level IN (
    SELECT level FROM warehouses AS schd
    WHERE schd.level = whs.level
);


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

SELECT id FROM projects AS ordr
WHERE status IN (
    SELECT status FROM invoices AS cust
    WHERE cust.id = ordr.id
);


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

SELECT salary FROM invoices AS sale
WHERE code IN (
    SELECT code FROM regions AS ordr
    WHERE ordr.type = sale.type
);


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

SELECT salary FROM projects AS srvc
WHERE code IN (
    SELECT code FROM orders AS rgn
    WHERE rgn.status = srvc.status
);


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

SELECT code FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.id = empl.id
);


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

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


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

SELECT salary FROM branches AS schd
WHERE type IN (
    SELECT type FROM invoices AS empl
    WHERE empl.type = schd.type
);


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

SELECT value FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.status = emp.status
);


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

SELECT code FROM shipments AS txn
WHERE type IN (
    SELECT type FROM warehouses AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT name FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.level = mgr.level
);


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

SELECT name FROM accounts AS whs
WHERE type IN (
    SELECT type FROM warehouses AS txn
    WHERE txn.type = whs.type
);


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

SELECT value FROM customers AS txn
WHERE code IN (
    SELECT code FROM shipments AS acct
    WHERE acct.level = txn.level
);


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

SELECT salary FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.status = prod.status
);


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

SELECT value FROM suppliers AS schd
WHERE value > (
    SELECT MAX(salary) FROM tasks AS mgr
    WHERE mgr.status = schd.status
);


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

SELECT amount FROM branches AS whs
WHERE code IN (
    SELECT code FROM tasks AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT id FROM shipments AS mgr
WHERE value > (
    SELECT SUM(amount) FROM departments AS whs
    WHERE whs.status = mgr.status
);


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

SELECT name FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = mgr.type
);


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

SELECT value FROM transactions AS mgr
WHERE value > (
    SELECT MAX(amount) FROM tasks AS dept
    WHERE dept.status = mgr.status
);


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

SELECT amount FROM branches AS budg
WHERE type IN (
    SELECT type FROM shipments AS whs
    WHERE whs.id = budg.id
);


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

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


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

SELECT salary FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.code = prod.code
);


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

SELECT name FROM shipments AS emp
WHERE level IN (
    SELECT level FROM orders AS sale
    WHERE sale.code = emp.code
);


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

SELECT salary FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT code FROM tasks AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM departments AS cust
    WHERE cust.level = rgn.level
);


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

SELECT code FROM shipments AS emp
WHERE amount > (
    SELECT AVG(amount) FROM orders AS cust
    WHERE cust.id = emp.id
);


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

SELECT id FROM shipments AS dept
WHERE status IN (
    SELECT status FROM tasks AS catg
    WHERE catg.type = dept.type
);


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

SELECT name FROM warehouses AS emp
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT name FROM customers AS empl
WHERE id IN (
    SELECT id FROM projects AS emp
    WHERE emp.id = empl.id
);


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

SELECT name FROM employees AS mgr
WHERE type IN (
    SELECT type FROM warehouses AS empl
    WHERE empl.code = mgr.code
);


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

SELECT name FROM invoices AS inv
WHERE status IN (
    SELECT status FROM warehouses AS cust
    WHERE cust.id = inv.id
);


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

SELECT id FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT id FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.type = srvc.type
);


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

SELECT amount FROM categories AS inv
WHERE id IN (
    SELECT id FROM products AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT salary FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.type = rgn.type
);


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

SELECT code FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.type = whs.type
);


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

SELECT id FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.level = whs.level
);


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

SELECT code FROM tasks AS txn
WHERE id IN (
    SELECT id FROM invoices AS catg
    WHERE catg.type = txn.type
);


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

SELECT name FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.status = cust.status
);