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

SELECT id FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.level = prod.level
);


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

SELECT value FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM suppliers AS budg
    WHERE budg.status = mgr.status
);


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

SELECT amount FROM shipments AS txn
WHERE code IN (
    SELECT code FROM warehouses AS ord
    WHERE ord.type = txn.type
);


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

SELECT amount FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.code = rgn.code
);


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

SELECT name FROM departments AS ord
WHERE salary > (
    SELECT MAX(value) FROM projects AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT code FROM customers AS emp
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS schd
    WHERE schd.code = emp.code
);


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

SELECT salary FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT name FROM shipments AS budg
WHERE id IN (
    SELECT id FROM departments AS sale
    WHERE sale.type = budg.type
);


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

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


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

SELECT salary FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.type = budg.type
);


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

SELECT salary FROM categories AS dept
WHERE level IN (
    SELECT level FROM projects AS emp
    WHERE emp.code = dept.code
);


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

SELECT value FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT salary FROM orders AS inv
WHERE status IN (
    SELECT status FROM tasks AS whs
    WHERE whs.status = inv.status
);


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

SELECT value FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.level = txn.level
);


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

SELECT salary FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.status = dept.status
);


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.code = emp.code
);


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

SELECT name FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.level = acct.level
);


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

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


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

SELECT amount FROM accounts AS inv
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS sale
    WHERE sale.type = inv.type
);


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

SELECT value FROM branches AS prod
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT value FROM categories AS cust
WHERE salary > (
    SELECT MAX(amount) FROM suppliers AS whs
    WHERE whs.code = cust.code
);


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

SELECT name FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.level = rgn.level
);


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

SELECT amount FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.type = schd.type
);


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

SELECT value FROM shipments AS sale
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.status = sale.status
);


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

SELECT salary FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.level = ordr.level
);


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

SELECT name FROM projects AS budg
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.id = budg.id
);


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

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


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

SELECT value FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.id = empl.id
);


Prompt:
Schema:
  regions (alias: srvc)(code, status, type, salary)
  branches(code, status, amount, level)
Task: Retrieve salary from regions with amount above the COUNT(salary) of branches rows sharing the same code.
SQL:

SELECT salary FROM regions AS srvc
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS ord
    WHERE ord.code = srvc.code
);


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

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


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

SELECT name FROM accounts AS mgr
WHERE salary > (
    SELECT MIN(amount) FROM employees AS lne
    WHERE lne.code = mgr.code
);


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

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


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

SELECT id FROM orders AS sale
WHERE level IN (
    SELECT level FROM warehouses AS dept
    WHERE dept.status = sale.status
);


Prompt:
Schema:
  employees (alias: srvc)(value, code, date, id)
  regions(code, name, amount, id)
Task: Retrieve name from employees with amount above the AVG(amount) of regions rows sharing the same code.
SQL:

SELECT name FROM employees AS srvc
WHERE amount > (
    SELECT AVG(amount) FROM regions AS dept
    WHERE dept.code = srvc.code
);


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

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


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

SELECT value FROM products AS emp
WHERE value > (
    SELECT MIN(amount) FROM projects AS whs
    WHERE whs.id = emp.id
);


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

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


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

SELECT salary FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT value FROM categories AS srvc
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS inv
    WHERE inv.status = srvc.status
);


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

SELECT code FROM warehouses AS dept
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS cust
    WHERE cust.level = dept.level
);


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

SELECT name FROM branches AS budg
WHERE value > (
    SELECT COUNT(value) FROM employees AS catg
    WHERE catg.status = budg.status
);


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

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


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

SELECT salary FROM regions AS cust
WHERE id IN (
    SELECT id FROM invoices AS schd
    WHERE schd.status = cust.status
);


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

SELECT value FROM regions AS sale
WHERE status IN (
    SELECT status FROM employees AS cust
    WHERE cust.level = sale.level
);


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

SELECT code FROM regions AS acct
WHERE level IN (
    SELECT level FROM shipments AS inv
    WHERE inv.code = acct.code
);


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

SELECT name FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.code = dept.code
);


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

SELECT code FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.status = sale.status
);


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

SELECT salary FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.level = whs.level
);


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

SELECT amount FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.status = lne.status
);


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

SELECT amount FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = whs.type
);


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

SELECT id FROM transactions AS dept
WHERE status IN (
    SELECT status FROM departments AS ord
    WHERE ord.level = dept.level
);


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

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


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

SELECT salary FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.code = lne.code
);


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

SELECT id FROM customers AS mgr
WHERE level IN (
    SELECT level FROM branches AS prod
    WHERE prod.status = mgr.status
);


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

SELECT code FROM suppliers AS shp
WHERE salary > (
    SELECT MAX(salary) FROM categories AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT name FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.type = mgr.type
);


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

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


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

SELECT name FROM suppliers AS schd
WHERE status IN (
    SELECT status FROM employees AS rgn
    WHERE rgn.id = schd.id
);


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

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


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

SELECT name FROM orders AS acct
WHERE level IN (
    SELECT level FROM accounts AS prod
    WHERE prod.level = acct.level
);


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

SELECT code FROM shipments AS empl
WHERE level IN (
    SELECT level FROM warehouses AS emp
    WHERE emp.id = empl.id
);


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

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


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

SELECT id FROM warehouses AS acct
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS prod
    WHERE prod.code = acct.code
);


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

SELECT amount FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.level = acct.level
);


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

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


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

SELECT salary FROM projects AS inv
WHERE code IN (
    SELECT code FROM regions AS emp
    WHERE emp.status = inv.status
);


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

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


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

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


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

SELECT value FROM suppliers AS empl
WHERE id IN (
    SELECT id FROM customers AS catg
    WHERE catg.id = empl.id
);


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

SELECT code FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT AVG(value) FROM branches AS txn
    WHERE txn.status = cust.status
);


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

SELECT code FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.id = lne.id
);


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

SELECT name FROM branches AS empl
WHERE salary > (
    SELECT MIN(salary) FROM employees AS acct
    WHERE acct.status = empl.status
);


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

SELECT code FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.level = cust.level
);


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

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


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

SELECT amount FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.type = budg.type
);


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

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


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

SELECT name FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.type = dept.type
);


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

SELECT code FROM employees AS cust
WHERE value > (
    SELECT AVG(amount) FROM branches AS dept
    WHERE dept.id = cust.id
);


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

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


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

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


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

SELECT salary FROM customers AS acct
WHERE id IN (
    SELECT id FROM tasks AS inv
    WHERE inv.id = acct.id
);


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

SELECT code FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.id = sale.id
);


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

SELECT salary FROM products AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM orders AS acct
    WHERE acct.level = catg.level
);


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

SELECT value FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.code = sale.code
);


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

SELECT code FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.code = whs.code
);


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

SELECT salary FROM orders AS whs
WHERE level IN (
    SELECT level FROM branches AS budg
    WHERE budg.id = whs.id
);


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

SELECT id FROM accounts AS sale
WHERE amount > (
    SELECT MAX(value) FROM projects AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT id FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = empl.code
);


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

SELECT value FROM suppliers AS schd
WHERE salary > (
    SELECT MIN(value) FROM shipments AS emp
    WHERE emp.type = schd.type
);


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

SELECT value FROM products AS cust
WHERE id IN (
    SELECT id FROM warehouses AS ord
    WHERE ord.type = cust.type
);


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

SELECT id FROM tasks AS empl
WHERE type IN (
    SELECT type FROM projects AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT name FROM categories AS ord
WHERE value > (
    SELECT SUM(value) FROM suppliers AS whs
    WHERE whs.code = ord.code
);


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

SELECT value FROM orders AS empl
WHERE id IN (
    SELECT id FROM transactions AS inv
    WHERE inv.status = empl.status
);


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

SELECT code FROM tasks AS schd
WHERE type IN (
    SELECT type FROM accounts AS inv
    WHERE inv.id = schd.id
);


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

SELECT amount FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT id FROM employees AS inv
WHERE id IN (
    SELECT id FROM products AS emp
    WHERE emp.level = inv.level
);


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

SELECT code FROM projects AS rgn
WHERE level IN (
    SELECT level FROM employees AS shp
    WHERE shp.status = rgn.status
);


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

SELECT id FROM suppliers AS cust
WHERE id IN (
    SELECT id FROM products AS catg
    WHERE catg.code = cust.code
);


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

SELECT salary FROM employees AS ord
WHERE status IN (
    SELECT status FROM accounts AS schd
    WHERE schd.id = ord.id
);


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

SELECT name FROM suppliers AS prod
WHERE type IN (
    SELECT type FROM projects AS acct
    WHERE acct.level = prod.level
);


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

SELECT amount FROM projects AS rgn
WHERE value > (
    SELECT AVG(amount) FROM categories AS sale
    WHERE sale.level = rgn.level
);


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

SELECT value FROM branches AS lne
WHERE level IN (
    SELECT level FROM regions AS budg
    WHERE budg.level = lne.level
);


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

SELECT salary FROM orders AS ord
WHERE status IN (
    SELECT status FROM accounts AS schd
    WHERE schd.type = ord.type
);


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

SELECT name FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = shp.type
);


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

SELECT code FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT salary FROM products AS shp
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS emp
    WHERE emp.type = shp.type
);


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

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


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

SELECT name FROM warehouses AS shp
WHERE type IN (
    SELECT type FROM departments AS whs
    WHERE whs.type = shp.type
);


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

SELECT amount FROM regions AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM products AS txn
    WHERE txn.level = sale.level
);


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

SELECT value FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.id = cust.id
);


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

SELECT name FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = mgr.level
);


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

SELECT code FROM customers AS rgn
WHERE level IN (
    SELECT level FROM projects AS emp
    WHERE emp.type = rgn.type
);


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

SELECT id FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.id = cust.id
);


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

SELECT salary FROM transactions AS lne
WHERE status IN (
    SELECT status FROM shipments AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT salary FROM customers AS whs
WHERE amount > (
    SELECT COUNT(salary) FROM warehouses AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT salary FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.code = lne.code
);


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

SELECT code FROM categories AS prod
WHERE salary > (
    SELECT AVG(value) FROM employees AS dept
    WHERE dept.status = prod.status
);


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

SELECT name FROM suppliers AS lne
WHERE level IN (
    SELECT level FROM customers AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT id FROM suppliers AS srvc
WHERE salary > (
    SELECT MAX(amount) FROM departments AS schd
    WHERE schd.code = srvc.code
);


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

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


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

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


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

SELECT name FROM departments AS empl
WHERE code IN (
    SELECT code FROM tasks AS ord
    WHERE ord.level = empl.level
);


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

SELECT value FROM accounts AS lne
WHERE level IN (
    SELECT level FROM regions AS mgr
    WHERE mgr.status = lne.status
);


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

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


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

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


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

SELECT id FROM customers AS catg
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS acct
    WHERE acct.status = catg.status
);


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

SELECT amount FROM invoices AS empl
WHERE value > (
    SELECT COUNT(value) FROM products AS emp
    WHERE emp.type = empl.type
);


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

SELECT value FROM invoices AS sale
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS budg
    WHERE budg.level = sale.level
);


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

SELECT value FROM shipments AS prod
WHERE value > (
    SELECT COUNT(amount) FROM projects AS budg
    WHERE budg.level = prod.level
);


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

SELECT code FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.type = empl.type
);


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

SELECT salary FROM employees AS catg
WHERE code IN (
    SELECT code FROM branches AS ord
    WHERE ord.level = catg.level
);


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

SELECT code FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.status = acct.status
);


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

SELECT amount FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT id FROM branches AS whs
WHERE type IN (
    SELECT type FROM categories AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT name FROM accounts AS emp
WHERE level IN (
    SELECT level FROM orders AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT id FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.id = cust.id
);


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

SELECT value FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.status = schd.status
);


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

SELECT amount FROM projects AS lne
WHERE amount > (
    SELECT AVG(amount) FROM branches AS sale
    WHERE sale.type = lne.type
);


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

SELECT salary FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.code = catg.code
);


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

SELECT code FROM shipments AS emp
WHERE status IN (
    SELECT status FROM employees AS ordr
    WHERE ordr.level = emp.level
);


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

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


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

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


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

SELECT value FROM departments AS whs
WHERE salary > (
    SELECT MAX(amount) FROM employees AS acct
    WHERE acct.level = whs.level
);


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

SELECT salary FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.level = acct.level
);


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

SELECT amount FROM regions AS budg
WHERE id IN (
    SELECT id FROM departments AS shp
    WHERE shp.type = budg.type
);


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

SELECT salary FROM accounts AS shp
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS budg
    WHERE budg.type = shp.type
);


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

SELECT name FROM branches AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM regions AS ord
    WHERE ord.level = ordr.level
);


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

SELECT code FROM departments AS cust
WHERE type IN (
    SELECT type FROM products AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT id FROM customers AS mgr
WHERE amount > (
    SELECT COUNT(salary) FROM departments AS lne
    WHERE lne.type = mgr.type
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.code = txn.code
);


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

SELECT name FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.level = txn.level
);


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

SELECT salary FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT amount FROM shipments AS cust
WHERE value > (
    SELECT SUM(amount) FROM products AS whs
    WHERE whs.type = cust.type
);


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

SELECT id FROM shipments AS catg
WHERE id IN (
    SELECT id FROM branches AS inv
    WHERE inv.level = catg.level
);


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

SELECT value FROM employees AS budg
WHERE status IN (
    SELECT status FROM customers AS inv
    WHERE inv.level = budg.level
);


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

SELECT salary FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.code = inv.code
);


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

SELECT value FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM invoices AS catg
    WHERE catg.status = ordr.status
);


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

SELECT salary FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.id = schd.id
);


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

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


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

SELECT value FROM products AS cust
WHERE level IN (
    SELECT level FROM regions AS emp
    WHERE emp.status = cust.status
);


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

SELECT code FROM orders AS budg
WHERE code IN (
    SELECT code FROM tasks AS whs
    WHERE whs.level = budg.level
);


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

SELECT amount FROM employees AS cust
WHERE amount > (
    SELECT MIN(value) FROM suppliers AS dept
    WHERE dept.type = cust.type
);


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

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


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

SELECT name FROM categories AS inv
WHERE amount > (
    SELECT AVG(value) FROM regions AS schd
    WHERE schd.status = inv.status
);


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

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


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

SELECT name FROM customers AS whs
WHERE amount > (
    SELECT AVG(salary) FROM employees AS schd
    WHERE schd.id = whs.id
);


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

SELECT code FROM customers AS empl
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS budg
    WHERE budg.code = empl.code
);


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

SELECT id FROM customers AS rgn
WHERE amount > (
    SELECT MAX(salary) FROM departments AS budg
    WHERE budg.type = rgn.type
);


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

SELECT name FROM employees AS acct
WHERE value > (
    SELECT COUNT(value) FROM tasks AS ord
    WHERE ord.code = acct.code
);


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

SELECT value FROM employees AS sale
WHERE status IN (
    SELECT status FROM regions AS catg
    WHERE catg.code = sale.code
);


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

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


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

SELECT id FROM orders AS budg
WHERE id IN (
    SELECT id FROM projects AS lne
    WHERE lne.level = budg.level
);


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.status = ord.status
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.status = rgn.status
);


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

SELECT salary FROM invoices AS txn
WHERE id IN (
    SELECT id FROM products AS mgr
    WHERE mgr.status = txn.status
);


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

SELECT value FROM accounts AS inv
WHERE code IN (
    SELECT code FROM products AS shp
    WHERE shp.code = inv.code
);


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

SELECT salary FROM categories AS dept
WHERE code IN (
    SELECT code FROM accounts AS prod
    WHERE prod.id = dept.id
);


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

SELECT amount FROM tasks AS ordr
WHERE value > (
    SELECT SUM(value) FROM accounts AS emp
    WHERE emp.status = ordr.status
);


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

SELECT name FROM shipments AS budg
WHERE amount > (
    SELECT MIN(value) FROM customers AS catg
    WHERE catg.level = budg.level
);


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT COUNT(salary) FROM products AS ord
    WHERE ord.status = dept.status
);


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

SELECT value FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.level = lne.level
);


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

SELECT value FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.id = shp.id
);


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

SELECT amount FROM regions AS empl
WHERE code IN (
    SELECT code FROM transactions AS cust
    WHERE cust.id = empl.id
);


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

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


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

SELECT name FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.level = srvc.level
);


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

SELECT code FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.status = inv.status
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.status = ord.status
);


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

SELECT id FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT id FROM projects AS lne
WHERE value > (
    SELECT COUNT(value) FROM accounts AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT amount FROM employees AS emp
WHERE level IN (
    SELECT level FROM tasks AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT salary FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.type = mgr.type
);


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

SELECT value FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.type = lne.type
);


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

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


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

SELECT name FROM orders AS catg
WHERE amount > (
    SELECT MAX(value) FROM accounts AS sale
    WHERE sale.status = catg.status
);


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

SELECT id FROM projects AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM categories AS budg
    WHERE budg.type = rgn.type
);


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

SELECT id FROM branches AS prod
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS mgr
    WHERE mgr.code = prod.code
);


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

SELECT code FROM transactions AS inv
WHERE type IN (
    SELECT type FROM orders AS acct
    WHERE acct.code = inv.code
);


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

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


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

SELECT salary FROM employees AS ordr
WHERE level IN (
    SELECT level FROM warehouses AS whs
    WHERE whs.id = ordr.id
);


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

SELECT id FROM invoices AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS dept
    WHERE dept.level = ordr.level
);


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

SELECT name FROM products AS ord
WHERE amount > (
    SELECT SUM(amount) FROM branches AS emp
    WHERE emp.status = ord.status
);


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

SELECT code FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.status = empl.status
);


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

SELECT code FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT value FROM transactions AS prod
WHERE status IN (
    SELECT status FROM tasks AS ord
    WHERE ord.id = prod.id
);


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

SELECT value FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = budg.code
);


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

SELECT name FROM products AS catg
WHERE salary > (
    SELECT MAX(value) FROM orders AS rgn
    WHERE rgn.level = catg.level
);


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

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


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

SELECT id FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.code = ord.code
);


Prompt:
Schema:
  tasks (alias: ordr)(status, level, id, value)
  orders(level, code, date, value)
Task: Retrieve code from tasks with value above the COUNT(amount) of orders rows sharing the same status.
SQL:

SELECT code FROM tasks AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM orders AS txn
    WHERE txn.status = ordr.status
);


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

SELECT id FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.code = acct.code
);


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

SELECT name FROM products AS lne
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.id = lne.id
);


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

SELECT value FROM shipments AS ord
WHERE amount > (
    SELECT AVG(amount) FROM categories AS txn
    WHERE txn.code = ord.code
);


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

SELECT id FROM products AS inv
WHERE id IN (
    SELECT id FROM departments AS dept
    WHERE dept.id = inv.id
);


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

SELECT value FROM employees AS acct
WHERE amount > (
    SELECT AVG(value) FROM customers AS prod
    WHERE prod.type = acct.type
);


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

SELECT code FROM branches AS sale
WHERE level IN (
    SELECT level FROM transactions AS acct
    WHERE acct.status = sale.status
);


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

SELECT amount FROM suppliers AS ord
WHERE level IN (
    SELECT level FROM accounts AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT amount FROM accounts AS shp
WHERE status IN (
    SELECT status FROM suppliers AS acct
    WHERE acct.code = shp.code
);


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

SELECT value FROM invoices AS srvc
WHERE status IN (
    SELECT status FROM regions AS lne
    WHERE lne.type = srvc.type
);


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

SELECT amount FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT id FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.level = mgr.level
);


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

SELECT id FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.level = srvc.level
);


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

SELECT value FROM accounts AS acct
WHERE amount > (
    SELECT SUM(salary) FROM projects AS catg
    WHERE catg.level = acct.level
);


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

SELECT value FROM projects AS shp
WHERE status IN (
    SELECT status FROM departments AS budg
    WHERE budg.id = shp.id
);


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

SELECT amount FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.status = empl.status
);


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

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


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

SELECT code FROM customers AS empl
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS budg
    WHERE budg.level = empl.level
);


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

SELECT code FROM products AS empl
WHERE salary > (
    SELECT MAX(salary) FROM categories AS schd
    WHERE schd.level = empl.level
);


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

SELECT name FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT value FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.level = mgr.level
);


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

SELECT salary FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT id FROM accounts AS srvc
WHERE status IN (
    SELECT status FROM customers AS budg
    WHERE budg.level = srvc.level
);


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

SELECT salary FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.level = whs.level
);


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

SELECT amount FROM customers AS acct
WHERE type IN (
    SELECT type FROM warehouses AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT name FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.code = emp.code
);


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

SELECT id FROM tasks AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM accounts AS prod
    WHERE prod.id = sale.id
);


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

SELECT code FROM regions AS schd
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS cust
    WHERE cust.code = schd.code
);


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

SELECT code FROM accounts AS txn
WHERE salary > (
    SELECT SUM(amount) FROM categories AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT name FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.level = emp.level
);


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

SELECT value FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.code = sale.code
);


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

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


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

SELECT id FROM employees AS ordr
WHERE level IN (
    SELECT level FROM tasks AS dept
    WHERE dept.code = ordr.code
);


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

SELECT id FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT value FROM accounts AS schd
WHERE level IN (
    SELECT level FROM transactions AS txn
    WHERE txn.id = schd.id
);


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

SELECT name FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.status = inv.status
);


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

SELECT id FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM warehouses AS empl
    WHERE empl.code = ordr.code
);


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

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


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

SELECT id FROM invoices AS shp
WHERE amount > (
    SELECT AVG(salary) FROM employees AS catg
    WHERE catg.type = shp.type
);


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

SELECT amount FROM products AS dept
WHERE amount > (
    SELECT MAX(amount) FROM categories AS txn
    WHERE txn.status = dept.status
);


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

SELECT salary FROM projects AS budg
WHERE id IN (
    SELECT id FROM invoices AS ord
    WHERE ord.type = budg.type
);


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

SELECT code FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.type = srvc.type
);


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

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


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

SELECT name FROM projects AS lne
WHERE level IN (
    SELECT level FROM employees AS inv
    WHERE inv.code = lne.code
);


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

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


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

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


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

SELECT salary FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.code = schd.code
);


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

SELECT code FROM accounts AS acct
WHERE salary > (
    SELECT SUM(amount) FROM orders AS emp
    WHERE emp.level = acct.level
);


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

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


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

SELECT salary FROM branches AS ord
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS schd
    WHERE schd.id = ord.id
);


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

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


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

SELECT name FROM tasks AS catg
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS schd
    WHERE schd.type = catg.type
);


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

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


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

SELECT code FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.code = emp.code
);


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

SELECT id FROM departments AS cust
WHERE type IN (
    SELECT type FROM shipments AS acct
    WHERE acct.code = cust.code
);


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

SELECT code FROM employees AS whs
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.type = whs.type
);


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

SELECT amount FROM categories AS shp
WHERE level IN (
    SELECT level FROM products AS cust
    WHERE cust.id = shp.id
);


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

SELECT value FROM transactions AS cust
WHERE id IN (
    SELECT id FROM projects AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT code FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.id = inv.id
);


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

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


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

SELECT name FROM employees AS rgn
WHERE id IN (
    SELECT id FROM shipments AS prod
    WHERE prod.level = rgn.level
);


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

SELECT amount FROM products AS shp
WHERE value > (
    SELECT SUM(value) FROM warehouses AS prod
    WHERE prod.code = shp.code
);


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

SELECT code FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.id = ordr.id
);


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

SELECT id FROM warehouses AS txn
WHERE type IN (
    SELECT type FROM transactions AS ord
    WHERE ord.level = txn.level
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.level = prod.level
);


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

SELECT code FROM shipments AS sale
WHERE value > (
    SELECT MAX(amount) FROM products AS catg
    WHERE catg.status = sale.status
);


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

SELECT name FROM branches AS mgr
WHERE salary > (
    SELECT AVG(salary) FROM shipments AS rgn
    WHERE rgn.id = mgr.id
);


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

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


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

SELECT salary FROM invoices AS acct
WHERE amount > (
    SELECT AVG(salary) FROM transactions AS empl
    WHERE empl.id = acct.id
);


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

SELECT code FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.status = prod.status
);


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

SELECT id FROM employees AS ordr
WHERE value > (
    SELECT MIN(amount) FROM projects AS emp
    WHERE emp.level = ordr.level
);


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

SELECT salary FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT amount FROM suppliers AS catg
WHERE status IN (
    SELECT status FROM products AS shp
    WHERE shp.type = catg.type
);


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

SELECT salary FROM suppliers AS schd
WHERE amount > (
    SELECT SUM(value) FROM products AS txn
    WHERE txn.level = schd.level
);


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

SELECT id FROM shipments AS shp
WHERE value > (
    SELECT MIN(value) FROM tasks AS budg
    WHERE budg.id = shp.id
);


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

SELECT name FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = inv.id
);


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

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


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

SELECT name FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.type = dept.type
);


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

SELECT salary FROM categories AS lne
WHERE amount > (
    SELECT MIN(value) FROM employees AS inv
    WHERE inv.code = lne.code
);


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

SELECT id FROM orders AS ord
WHERE value > (
    SELECT MAX(salary) FROM accounts AS txn
    WHERE txn.status = ord.status
);


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

SELECT name FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.code = cust.code
);


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

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


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

SELECT id FROM employees AS prod
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS acct
    WHERE acct.type = prod.type
);


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

SELECT value FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.id = ordr.id
);


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

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