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

SELECT amount FROM orders AS lne
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT salary FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.type = cust.type
);


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

SELECT amount FROM orders AS ordr
WHERE level IN (
    SELECT level FROM regions AS acct
    WHERE acct.level = ordr.level
);


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

SELECT salary FROM shipments AS srvc
WHERE id IN (
    SELECT id FROM departments AS schd
    WHERE schd.code = srvc.code
);


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

SELECT name FROM projects AS srvc
WHERE level IN (
    SELECT level FROM invoices AS budg
    WHERE budg.type = srvc.type
);


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

SELECT value FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.type = cust.type
);


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

SELECT code FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.id = txn.id
);


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

SELECT value FROM projects AS prod
WHERE type IN (
    SELECT type FROM orders AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT id FROM invoices AS empl
WHERE status IN (
    SELECT status FROM regions AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT value FROM regions AS emp
WHERE id IN (
    SELECT id FROM branches AS empl
    WHERE empl.code = emp.code
);


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

SELECT id FROM tasks AS ordr
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.level = ordr.level
);


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

SELECT name FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.status = dept.status
);


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

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


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

SELECT name FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.level = dept.level
);


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

SELECT value FROM accounts AS sale
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.level = sale.level
);


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

SELECT name FROM transactions AS dept
WHERE level IN (
    SELECT level FROM projects AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT salary FROM employees AS sale
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS txn
    WHERE txn.code = sale.code
);


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

SELECT amount FROM warehouses AS prod
WHERE salary > (
    SELECT MIN(amount) FROM departments AS ord
    WHERE ord.id = prod.id
);


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

SELECT code FROM branches AS lne
WHERE code IN (
    SELECT code FROM products AS shp
    WHERE shp.code = lne.code
);


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

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


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

SELECT salary FROM projects AS acct
WHERE salary > (
    SELECT SUM(value) FROM customers AS mgr
    WHERE mgr.code = acct.code
);


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

SELECT code FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.type = lne.type
);


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

SELECT code FROM projects AS emp
WHERE value > (
    SELECT COUNT(amount) FROM warehouses AS ord
    WHERE ord.type = emp.type
);


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

SELECT amount FROM employees AS sale
WHERE code IN (
    SELECT code FROM orders AS whs
    WHERE whs.code = sale.code
);


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

SELECT name FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = srvc.code
);


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

SELECT name FROM projects AS schd
WHERE status IN (
    SELECT status FROM warehouses AS shp
    WHERE shp.code = schd.code
);


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

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


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

SELECT amount FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.status = ordr.status
);


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

SELECT name FROM warehouses AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM projects AS acct
    WHERE acct.id = rgn.id
);


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

SELECT code FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.level = cust.level
);


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

SELECT name FROM warehouses AS rgn
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT id FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT name FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.id = txn.id
);


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

SELECT name FROM accounts AS cust
WHERE value > (
    SELECT SUM(salary) FROM regions AS schd
    WHERE schd.id = cust.id
);


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

SELECT code FROM invoices AS acct
WHERE amount > (
    SELECT MIN(salary) FROM transactions AS ord
    WHERE ord.type = acct.type
);


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

SELECT name FROM shipments AS dept
WHERE type IN (
    SELECT type FROM categories AS empl
    WHERE empl.code = dept.code
);


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

SELECT id FROM regions AS catg
WHERE code IN (
    SELECT code FROM warehouses AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT value FROM products AS whs
WHERE amount > (
    SELECT AVG(amount) FROM orders AS inv
    WHERE inv.id = whs.id
);


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

SELECT name FROM suppliers AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM invoices AS cust
    WHERE cust.status = rgn.status
);


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

SELECT name FROM tasks AS lne
WHERE id IN (
    SELECT id FROM employees AS cust
    WHERE cust.status = lne.status
);


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

SELECT name FROM tasks AS empl
WHERE salary > (
    SELECT MIN(value) FROM accounts AS txn
    WHERE txn.code = empl.code
);


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

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


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

SELECT amount FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.status = dept.status
);


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

SELECT name FROM invoices AS budg
WHERE amount > (
    SELECT MAX(amount) FROM branches AS catg
    WHERE catg.status = budg.status
);


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

SELECT id FROM orders AS empl
WHERE type IN (
    SELECT type FROM products AS lne
    WHERE lne.type = empl.type
);


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

SELECT id FROM shipments AS ord
WHERE amount > (
    SELECT AVG(amount) FROM customers AS srvc
    WHERE srvc.level = ord.level
);


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

SELECT name FROM invoices AS whs
WHERE amount > (
    SELECT MAX(salary) FROM orders AS cust
    WHERE cust.id = whs.id
);


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

SELECT value FROM transactions AS ord
WHERE level IN (
    SELECT level FROM employees AS catg
    WHERE catg.status = ord.status
);


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

SELECT salary FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.id = rgn.id
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = budg.level
);


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

SELECT code FROM categories AS sale
WHERE value > (
    SELECT SUM(salary) FROM transactions AS lne
    WHERE lne.status = sale.status
);


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

SELECT id FROM customers AS whs
WHERE value > (
    SELECT MAX(salary) FROM employees AS lne
    WHERE lne.type = whs.type
);


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

SELECT id FROM regions AS txn
WHERE value > (
    SELECT AVG(salary) FROM customers AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT value FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = lne.level
);


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

SELECT name FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.status = whs.status
);


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

SELECT amount FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT code FROM customers AS sale
WHERE id IN (
    SELECT id FROM invoices AS lne
    WHERE lne.code = sale.code
);


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

SELECT value FROM orders AS budg
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS schd
    WHERE schd.level = budg.level
);


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

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


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

SELECT value FROM departments AS inv
WHERE amount > (
    SELECT MIN(value) FROM products AS whs
    WHERE whs.code = inv.code
);


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

SELECT amount FROM employees AS shp
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.status = shp.status
);


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

SELECT code FROM tasks AS schd
WHERE level IN (
    SELECT level FROM employees AS mgr
    WHERE mgr.status = schd.status
);


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

SELECT salary FROM orders AS whs
WHERE salary > (
    SELECT AVG(value) FROM employees AS prod
    WHERE prod.type = whs.type
);


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

SELECT name FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.code = empl.code
);


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

SELECT salary FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.type = sale.type
);


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

SELECT salary FROM tasks AS inv
WHERE status IN (
    SELECT status FROM customers AS empl
    WHERE empl.level = inv.level
);


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

SELECT salary FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT id FROM products AS mgr
WHERE code IN (
    SELECT code FROM warehouses AS cust
    WHERE cust.id = mgr.id
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.code = catg.code
);


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

SELECT salary FROM transactions AS schd
WHERE value > (
    SELECT MIN(amount) FROM categories AS ord
    WHERE ord.type = schd.type
);


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

SELECT amount FROM tasks AS acct
WHERE code IN (
    SELECT code FROM invoices AS budg
    WHERE budg.type = acct.type
);


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

SELECT name FROM invoices AS txn
WHERE value > (
    SELECT SUM(amount) FROM regions AS empl
    WHERE empl.code = txn.code
);


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

SELECT amount FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.code = cust.code
);


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

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


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

SELECT salary FROM branches AS catg
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.id = catg.id
);


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

SELECT salary FROM projects AS txn
WHERE id IN (
    SELECT id FROM regions AS shp
    WHERE shp.status = txn.status
);


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

SELECT salary FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT value FROM suppliers AS shp
WHERE value > (
    SELECT MAX(salary) FROM accounts AS emp
    WHERE emp.status = shp.status
);


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

SELECT code FROM branches AS shp
WHERE level IN (
    SELECT level FROM customers AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT name FROM warehouses AS srvc
WHERE level IN (
    SELECT level FROM shipments AS empl
    WHERE empl.code = srvc.code
);


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

SELECT salary FROM employees AS ordr
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS acct
    WHERE acct.level = ordr.level
);


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

SELECT name FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.status = acct.status
);


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

SELECT code FROM transactions AS emp
WHERE value > (
    SELECT COUNT(salary) FROM categories AS inv
    WHERE inv.id = emp.id
);


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

SELECT value FROM suppliers AS ordr
WHERE value > (
    SELECT MAX(value) FROM warehouses AS catg
    WHERE catg.id = ordr.id
);


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

SELECT name FROM tasks AS srvc
WHERE id IN (
    SELECT id FROM orders AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT id FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.type = acct.type
);


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

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


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

SELECT code FROM orders AS srvc
WHERE amount > (
    SELECT MAX(salary) FROM projects AS empl
    WHERE empl.status = srvc.status
);


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

SELECT id FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.code = catg.code
);


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

SELECT salary FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.status = catg.status
);


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

SELECT id FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.code = ord.code
);


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

SELECT amount FROM suppliers AS shp
WHERE level IN (
    SELECT level FROM projects AS emp
    WHERE emp.status = shp.status
);


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

SELECT salary FROM accounts AS cust
WHERE amount > (
    SELECT AVG(salary) FROM categories AS sale
    WHERE sale.type = cust.type
);


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

SELECT salary FROM suppliers AS rgn
WHERE value > (
    SELECT MIN(amount) FROM products AS sale
    WHERE sale.id = rgn.id
);


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

SELECT id FROM transactions AS prod
WHERE amount > (
    SELECT MAX(value) FROM accounts AS sale
    WHERE sale.type = prod.type
);


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

SELECT salary FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.type = ordr.type
);


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

SELECT id FROM projects AS mgr
WHERE type IN (
    SELECT type FROM tasks AS catg
    WHERE catg.id = mgr.id
);


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

SELECT amount FROM orders AS schd
WHERE id IN (
    SELECT id FROM warehouses AS catg
    WHERE catg.type = schd.type
);


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

SELECT amount FROM transactions AS rgn
WHERE amount > (
    SELECT AVG(salary) FROM orders AS empl
    WHERE empl.status = rgn.status
);


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

SELECT code FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.level = mgr.level
);


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

SELECT value FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.type = cust.type
);


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

SELECT salary FROM branches AS ord
WHERE id IN (
    SELECT id FROM customers AS empl
    WHERE empl.type = ord.type
);


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

SELECT name FROM regions AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS txn
    WHERE txn.code = catg.code
);


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

SELECT id FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT value FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.id = prod.id
);


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

SELECT code FROM departments AS cust
WHERE amount > (
    SELECT MAX(value) FROM shipments AS whs
    WHERE whs.level = cust.level
);


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

SELECT code FROM warehouses AS emp
WHERE salary > (
    SELECT AVG(amount) FROM departments AS cust
    WHERE cust.id = emp.id
);


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

SELECT id FROM transactions AS inv
WHERE level IN (
    SELECT level FROM accounts AS empl
    WHERE empl.code = inv.code
);


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

SELECT code FROM accounts AS budg
WHERE amount > (
    SELECT SUM(amount) FROM customers AS rgn
    WHERE rgn.type = budg.type
);


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

SELECT name FROM accounts AS inv
WHERE value > (
    SELECT AVG(salary) FROM departments AS schd
    WHERE schd.type = inv.type
);


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

SELECT code FROM projects AS budg
WHERE value > (
    SELECT SUM(value) FROM accounts AS txn
    WHERE txn.type = budg.type
);


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

SELECT name FROM tasks AS cust
WHERE status IN (
    SELECT status FROM customers AS acct
    WHERE acct.type = cust.type
);


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

SELECT code FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.status = sale.status
);


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

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


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

SELECT value FROM shipments AS srvc
WHERE salary > (
    SELECT MAX(amount) FROM tasks AS cust
    WHERE cust.type = srvc.type
);


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

SELECT id FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.status = emp.status
);


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

SELECT value FROM products AS rgn
WHERE value > (
    SELECT AVG(value) FROM transactions AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT salary FROM shipments AS txn
WHERE type IN (
    SELECT type FROM categories AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT value FROM invoices AS cust
WHERE salary > (
    SELECT MAX(salary) FROM projects AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT value FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.id = whs.id
);


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

SELECT value FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.id = dept.id
);


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

SELECT id FROM products AS schd
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT salary FROM employees AS sale
WHERE code IN (
    SELECT code FROM departments AS catg
    WHERE catg.code = sale.code
);


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

SELECT id FROM warehouses AS acct
WHERE amount > (
    SELECT COUNT(value) FROM departments AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.status = rgn.status
);


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

SELECT salary FROM categories AS prod
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT name FROM transactions AS acct
WHERE amount > (
    SELECT MIN(value) FROM branches AS cust
    WHERE cust.code = acct.code
);


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

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


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

SELECT amount FROM tasks AS dept
WHERE id IN (
    SELECT id FROM regions AS rgn
    WHERE rgn.id = dept.id
);


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

SELECT id FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.level = inv.level
);


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

SELECT amount FROM orders AS ord
WHERE salary > (
    SELECT MIN(value) FROM tasks AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT amount FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.id = rgn.id
);


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

SELECT code FROM departments AS mgr
WHERE salary > (
    SELECT AVG(value) FROM categories AS shp
    WHERE shp.level = mgr.level
);


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

SELECT name FROM projects AS whs
WHERE amount > (
    SELECT MAX(value) FROM products AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT name FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.id = budg.id
);


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

SELECT value FROM categories AS txn
WHERE id IN (
    SELECT id FROM warehouses AS prod
    WHERE prod.status = txn.status
);


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

SELECT value FROM accounts AS emp
WHERE salary > (
    SELECT COUNT(value) FROM employees AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT value FROM categories AS schd
WHERE id IN (
    SELECT id FROM invoices AS budg
    WHERE budg.id = schd.id
);


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

SELECT name FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = ordr.type
);


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

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


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

SELECT value FROM customers AS shp
WHERE amount > (
    SELECT SUM(value) FROM orders AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT name FROM warehouses AS emp
WHERE amount > (
    SELECT SUM(salary) FROM products AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT name FROM customers AS srvc
WHERE amount > (
    SELECT MAX(value) FROM departments AS shp
    WHERE shp.level = srvc.level
);


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

SELECT amount FROM shipments AS catg
WHERE value > (
    SELECT SUM(value) FROM invoices AS budg
    WHERE budg.level = catg.level
);


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

SELECT value FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT value FROM transactions AS rgn
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS txn
    WHERE txn.code = rgn.code
);


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

SELECT name FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.type = ord.type
);


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

SELECT amount FROM transactions AS whs
WHERE type IN (
    SELECT type FROM invoices AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT value FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT id FROM products AS schd
WHERE status IN (
    SELECT status FROM projects AS cust
    WHERE cust.status = schd.status
);


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

SELECT value FROM employees AS sale
WHERE type IN (
    SELECT type FROM projects AS srvc
    WHERE srvc.code = sale.code
);


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

SELECT amount FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.type = shp.type
);


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

SELECT salary FROM tasks AS emp
WHERE value > (
    SELECT AVG(amount) FROM orders AS empl
    WHERE empl.code = emp.code
);


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

SELECT salary FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.id = srvc.id
);


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

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


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

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


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

SELECT amount FROM regions AS prod
WHERE amount > (
    SELECT SUM(value) FROM products AS cust
    WHERE cust.status = prod.status
);


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

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


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

SELECT id FROM branches AS cust
WHERE type IN (
    SELECT type FROM tasks AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT amount FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.id = catg.id
);


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

SELECT code FROM accounts AS empl
WHERE salary > (
    SELECT SUM(salary) FROM orders AS ord
    WHERE ord.id = empl.id
);


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

SELECT salary FROM products AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS budg
    WHERE budg.code = empl.code
);


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

SELECT name FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.status = whs.status
);


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

SELECT amount FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.level = shp.level
);


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

SELECT amount FROM products AS acct
WHERE type IN (
    SELECT type FROM categories AS dept
    WHERE dept.status = acct.status
);


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

SELECT amount FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT value FROM shipments AS emp
WHERE code IN (
    SELECT code FROM warehouses AS txn
    WHERE txn.code = emp.code
);


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

SELECT id FROM departments AS lne
WHERE code IN (
    SELECT code FROM invoices AS prod
    WHERE prod.status = lne.status
);


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

SELECT code FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.id = shp.id
);


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

SELECT amount FROM tasks AS ordr
WHERE amount > (
    SELECT MAX(salary) FROM customers AS dept
    WHERE dept.level = ordr.level
);


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

SELECT id FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.code = emp.code
);


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

SELECT id FROM orders AS ordr
WHERE value > (
    SELECT AVG(value) FROM tasks AS txn
    WHERE txn.code = ordr.code
);


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

SELECT value FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.status = shp.status
);


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

SELECT salary FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.level = whs.level
);


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

SELECT name FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.level = prod.level
);


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

SELECT name FROM orders AS inv
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT salary FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.id = whs.id
);


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

SELECT code FROM tasks AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS acct
    WHERE acct.status = rgn.status
);


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

SELECT code FROM customers AS empl
WHERE salary > (
    SELECT SUM(salary) FROM employees AS inv
    WHERE inv.code = empl.code
);


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

SELECT salary FROM accounts AS sale
WHERE type IN (
    SELECT type FROM departments AS prod
    WHERE prod.status = sale.status
);


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

SELECT amount FROM regions AS whs
WHERE level IN (
    SELECT level FROM warehouses AS sale
    WHERE sale.level = whs.level
);


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

SELECT code FROM tasks AS whs
WHERE type IN (
    SELECT type FROM warehouses AS cust
    WHERE cust.type = whs.type
);


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

SELECT code FROM transactions AS inv
WHERE value > (
    SELECT COUNT(salary) FROM regions AS shp
    WHERE shp.id = inv.id
);


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

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


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

SELECT value FROM orders AS ord
WHERE code IN (
    SELECT code FROM categories AS prod
    WHERE prod.type = ord.type
);


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

SELECT code FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.level = shp.level
);


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

SELECT code FROM branches AS cust
WHERE status IN (
    SELECT status FROM customers AS dept
    WHERE dept.id = cust.id
);


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

SELECT value FROM customers AS ord
WHERE level IN (
    SELECT level FROM warehouses AS emp
    WHERE emp.level = ord.level
);


Prompt:
Schema:
  customers (alias: mgr)(level, date, status, name)
  departments(date, name, status, salary)
Task: Retrieve name from customers with value above the MIN(amount) of departments rows sharing the same level.
SQL:

SELECT name FROM customers AS mgr
WHERE value > (
    SELECT MIN(amount) FROM departments AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT salary FROM departments AS txn
WHERE status IN (
    SELECT status FROM suppliers AS catg
    WHERE catg.id = txn.id
);


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

SELECT name FROM branches AS empl
WHERE value > (
    SELECT AVG(salary) FROM accounts AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT salary FROM invoices AS acct
WHERE salary > (
    SELECT SUM(value) FROM orders AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT value FROM departments AS sale
WHERE type IN (
    SELECT type FROM regions AS catg
    WHERE catg.type = sale.type
);


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

SELECT name FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.id = dept.id
);


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

SELECT name FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.code = cust.code
);


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

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


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

SELECT code FROM invoices AS txn
WHERE code IN (
    SELECT code FROM warehouses AS budg
    WHERE budg.status = txn.status
);


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

SELECT salary FROM regions AS rgn
WHERE status IN (
    SELECT status FROM categories AS inv
    WHERE inv.level = rgn.level
);


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

SELECT code FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.id = dept.id
);


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

SELECT salary FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.type = cust.type
);


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

SELECT amount FROM branches AS budg
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT value FROM categories AS lne
WHERE id IN (
    SELECT id FROM tasks AS cust
    WHERE cust.status = lne.status
);


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

SELECT value FROM regions AS empl
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.status = empl.status
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.level = dept.level
);


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

SELECT code FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT name FROM warehouses AS cust
WHERE amount > (
    SELECT MIN(value) FROM shipments AS inv
    WHERE inv.level = cust.level
);


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

SELECT code FROM departments AS dept
WHERE status IN (
    SELECT status FROM customers AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT salary FROM transactions AS rgn
WHERE code IN (
    SELECT code FROM products AS sale
    WHERE sale.level = rgn.level
);


Prompt:
Schema:
  products (alias: rgn)(date, status, level, id)
  projects(type, date, id, salary)
Task: Retrieve id from products with salary above the MIN(amount) of projects rows sharing the same level.
SQL:

SELECT id FROM products AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM projects AS ordr
    WHERE ordr.level = rgn.level
);


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

SELECT amount FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.code = ord.code
);


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

SELECT salary FROM shipments AS rgn
WHERE id IN (
    SELECT id FROM suppliers AS prod
    WHERE prod.status = rgn.status
);


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

SELECT amount FROM warehouses AS empl
WHERE amount > (
    SELECT MAX(amount) FROM departments AS ordr
    WHERE ordr.type = empl.type
);


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

SELECT code FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.level = whs.level
);


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

SELECT amount FROM suppliers AS lne
WHERE salary > (
    SELECT MAX(value) FROM projects AS schd
    WHERE schd.code = lne.code
);


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

SELECT id FROM projects AS catg
WHERE salary > (
    SELECT MIN(amount) FROM departments AS rgn
    WHERE rgn.level = catg.level
);


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

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


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

SELECT code FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = acct.status
);


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

SELECT amount FROM departments AS catg
WHERE status IN (
    SELECT status FROM transactions AS emp
    WHERE emp.status = catg.status
);


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

SELECT value FROM warehouses AS ordr
WHERE level IN (
    SELECT level FROM shipments AS empl
    WHERE empl.code = ordr.code
);


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

SELECT code FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.id = empl.id
);


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

SELECT name FROM invoices AS schd
WHERE code IN (
    SELECT code FROM orders AS lne
    WHERE lne.type = schd.type
);


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

SELECT id FROM tasks AS rgn
WHERE value > (
    SELECT SUM(salary) FROM employees AS whs
    WHERE whs.level = rgn.level
);


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

SELECT name FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.type = mgr.type
);


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

SELECT amount FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.status = rgn.status
);


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

SELECT value FROM departments AS mgr
WHERE status IN (
    SELECT status FROM invoices AS ord
    WHERE ord.code = mgr.code
);


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

SELECT value FROM regions AS cust
WHERE value > (
    SELECT SUM(value) FROM customers AS emp
    WHERE emp.id = cust.id
);


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

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


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

SELECT id FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.level = inv.level
);


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

SELECT name FROM orders AS rgn
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS whs
    WHERE whs.id = rgn.id
);


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

SELECT salary FROM transactions AS empl
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.type = empl.type
);


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

SELECT name FROM regions AS ord
WHERE salary > (
    SELECT SUM(amount) FROM categories AS budg
    WHERE budg.status = ord.status
);


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

SELECT salary FROM categories AS prod
WHERE amount > (
    SELECT COUNT(salary) FROM departments AS acct
    WHERE acct.id = prod.id
);


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

SELECT salary FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = whs.type
);


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

SELECT salary FROM shipments AS txn
WHERE salary > (
    SELECT SUM(amount) FROM branches AS emp
    WHERE emp.code = txn.code
);


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

SELECT salary FROM departments AS emp
WHERE type IN (
    SELECT type FROM accounts AS shp
    WHERE shp.type = emp.type
);


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

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


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

SELECT value FROM categories AS budg
WHERE salary > (
    SELECT AVG(salary) FROM products AS shp
    WHERE shp.status = budg.status
);


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

SELECT code FROM regions AS ord
WHERE id IN (
    SELECT id FROM products AS empl
    WHERE empl.status = ord.status
);


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

SELECT name FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.level = cust.level
);


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

SELECT value FROM projects AS shp
WHERE amount > (
    SELECT MIN(amount) FROM customers AS dept
    WHERE dept.status = shp.status
);


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

SELECT amount FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.status = lne.status
);


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

SELECT value FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.level = shp.level
);


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

SELECT value FROM orders AS prod
WHERE level IN (
    SELECT level FROM branches AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT value FROM projects AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM departments AS dept
    WHERE dept.status = ordr.status
);


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

SELECT id FROM suppliers AS budg
WHERE code IN (
    SELECT code FROM accounts AS inv
    WHERE inv.code = budg.code
);


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

SELECT id FROM products AS whs
WHERE level IN (
    SELECT level FROM projects AS txn
    WHERE txn.status = whs.status
);


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

SELECT value FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = rgn.code
);


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

SELECT code FROM projects AS inv
WHERE amount > (
    SELECT AVG(amount) FROM products AS catg
    WHERE catg.level = inv.level
);


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

SELECT id FROM warehouses AS catg
WHERE amount > (
    SELECT COUNT(value) FROM departments AS ord
    WHERE ord.code = catg.code
);


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

SELECT salary FROM categories AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS inv
    WHERE inv.code = rgn.code
);


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

SELECT code FROM shipments AS cust
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS lne
    WHERE lne.id = cust.id
);


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

SELECT value FROM suppliers AS inv
WHERE code IN (
    SELECT code FROM branches AS cust
    WHERE cust.level = inv.level
);


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

SELECT salary FROM projects AS emp
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS prod
    WHERE prod.id = emp.id
);


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

SELECT amount FROM orders AS ord
WHERE level IN (
    SELECT level FROM warehouses AS empl
    WHERE empl.id = ord.id
);


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

SELECT code FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.code = prod.code
);


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

SELECT value FROM tasks AS cust
WHERE id IN (
    SELECT id FROM branches AS acct
    WHERE acct.code = cust.code
);


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

SELECT salary FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.id = acct.id
);


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

SELECT value FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.id = schd.id
);


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

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


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

SELECT value FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT code FROM products AS sale
WHERE level IN (
    SELECT level FROM transactions AS emp
    WHERE emp.code = sale.code
);


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

SELECT id FROM accounts AS catg
WHERE value > (
    SELECT AVG(value) FROM suppliers AS emp
    WHERE emp.code = catg.code
);


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

SELECT amount FROM customers AS budg
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.code = budg.code
);


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

SELECT code FROM invoices AS schd
WHERE id IN (
    SELECT id FROM suppliers AS empl
    WHERE empl.status = schd.status
);


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

SELECT id FROM projects AS empl
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.id = empl.id
);


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

SELECT code FROM shipments AS dept
WHERE value > (
    SELECT AVG(salary) FROM tasks AS inv
    WHERE inv.id = dept.id
);


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

SELECT name FROM projects AS txn
WHERE level IN (
    SELECT level FROM categories AS schd
    WHERE schd.type = txn.type
);


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

SELECT name FROM transactions AS budg
WHERE salary > (
    SELECT SUM(value) FROM projects AS sale
    WHERE sale.status = budg.status
);


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

SELECT amount FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.id = ord.id
);


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

SELECT name FROM products AS rgn
WHERE value > (
    SELECT AVG(value) FROM transactions AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT name FROM transactions AS lne
WHERE value > (
    SELECT MAX(value) FROM customers AS emp
    WHERE emp.type = lne.type
);


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

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


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

SELECT name FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.code = schd.code
);


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

SELECT name FROM customers AS rgn
WHERE type IN (
    SELECT type FROM projects AS txn
    WHERE txn.id = rgn.id
);


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

SELECT amount FROM accounts AS rgn
WHERE status IN (
    SELECT status FROM shipments AS acct
    WHERE acct.status = rgn.status
);


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

SELECT name FROM suppliers AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM products AS ord
    WHERE ord.status = rgn.status
);


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

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


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

SELECT name FROM warehouses AS budg
WHERE value > (
    SELECT MAX(value) FROM tasks AS mgr
    WHERE mgr.id = budg.id
);


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

SELECT value FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.status = catg.status
);


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

SELECT value FROM branches AS ordr
WHERE value > (
    SELECT SUM(value) FROM categories AS schd
    WHERE schd.type = ordr.type
);


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

SELECT code FROM tasks AS whs
WHERE amount > (
    SELECT AVG(salary) FROM branches AS lne
    WHERE lne.level = whs.level
);


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

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


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

SELECT amount FROM suppliers AS dept
WHERE value > (
    SELECT MAX(salary) FROM categories AS sale
    WHERE sale.id = dept.id
);


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

SELECT code FROM orders AS acct
WHERE id IN (
    SELECT id FROM products AS lne
    WHERE lne.code = acct.code
);


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

SELECT code FROM customers AS emp
WHERE level IN (
    SELECT level FROM products AS cust
    WHERE cust.status = emp.status
);


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

SELECT id FROM customers AS empl
WHERE amount > (
    SELECT SUM(value) FROM accounts AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT id FROM tasks AS whs
WHERE level IN (
    SELECT level FROM warehouses AS dept
    WHERE dept.status = whs.status
);


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

SELECT name FROM orders AS acct
WHERE status IN (
    SELECT status FROM employees AS emp
    WHERE emp.level = acct.level
);


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

SELECT salary FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT name FROM products AS catg
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS dept
    WHERE dept.id = catg.id
);


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

SELECT code FROM invoices AS ord
WHERE value > (
    SELECT COUNT(value) FROM products AS cust
    WHERE cust.code = ord.code
);


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

SELECT value FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.type = schd.type
);


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

SELECT salary FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.level = shp.level
);