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

SELECT value FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.id = emp.id
);


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

SELECT name FROM invoices AS mgr
WHERE type IN (
    SELECT type FROM shipments AS lne
    WHERE lne.type = mgr.type
);


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

SELECT salary FROM products AS schd
WHERE level IN (
    SELECT level FROM tasks AS ord
    WHERE ord.level = schd.level
);


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

SELECT amount FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.level = shp.level
);


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

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


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

SELECT name FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.id = whs.id
);


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

SELECT amount FROM tasks AS ordr
WHERE code IN (
    SELECT code FROM projects AS schd
    WHERE schd.code = ordr.code
);


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

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


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

SELECT id FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = ordr.status
);


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

SELECT name FROM departments AS prod
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.status = prod.status
);


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

SELECT value FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.level = budg.level
);


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

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


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

SELECT id FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.type = prod.type
);


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

SELECT value FROM shipments AS inv
WHERE status IN (
    SELECT status FROM warehouses AS txn
    WHERE txn.level = inv.level
);


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

SELECT value FROM shipments AS emp
WHERE value > (
    SELECT AVG(salary) FROM orders AS budg
    WHERE budg.type = emp.type
);


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

SELECT value FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT code FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT code FROM regions AS sale
WHERE amount > (
    SELECT AVG(salary) FROM suppliers AS budg
    WHERE budg.status = sale.status
);


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

SELECT salary FROM regions AS shp
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS sale
    WHERE sale.status = shp.status
);


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

SELECT name FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.type = prod.type
);


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

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


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

SELECT value FROM warehouses AS ord
WHERE type IN (
    SELECT type FROM orders AS schd
    WHERE schd.level = ord.level
);


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

SELECT code FROM accounts AS txn
WHERE type IN (
    SELECT type FROM employees AS mgr
    WHERE mgr.status = txn.status
);


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

SELECT value FROM tasks AS catg
WHERE value > (
    SELECT COUNT(value) FROM categories AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT name FROM customers AS prod
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS dept
    WHERE dept.level = prod.level
);


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

SELECT code FROM warehouses AS sale
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS schd
    WHERE schd.status = sale.status
);


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

SELECT salary FROM regions AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM employees AS lne
    WHERE lne.level = srvc.level
);


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

SELECT id FROM invoices AS inv
WHERE amount > (
    SELECT MIN(amount) FROM branches AS whs
    WHERE whs.status = inv.status
);


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

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


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

SELECT salary FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.id = inv.id
);


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

SELECT code FROM branches AS catg
WHERE code IN (
    SELECT code FROM departments AS acct
    WHERE acct.code = catg.code
);


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

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


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

SELECT amount FROM departments AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS emp
    WHERE emp.status = ord.status
);


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

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


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

SELECT salary FROM orders AS mgr
WHERE salary > (
    SELECT MIN(value) FROM projects AS dept
    WHERE dept.type = mgr.type
);


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

SELECT name FROM suppliers AS emp
WHERE level IN (
    SELECT level FROM projects AS cust
    WHERE cust.id = emp.id
);


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

SELECT id FROM regions AS prod
WHERE value > (
    SELECT MAX(value) FROM orders AS empl
    WHERE empl.code = prod.code
);


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

SELECT code FROM projects AS cust
WHERE level IN (
    SELECT level FROM accounts AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT name FROM categories AS catg
WHERE id IN (
    SELECT id FROM invoices AS mgr
    WHERE mgr.id = catg.id
);


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

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


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

SELECT salary FROM accounts AS acct
WHERE amount > (
    SELECT SUM(value) FROM tasks AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT code FROM tasks AS sale
WHERE amount > (
    SELECT MAX(value) FROM orders AS ord
    WHERE ord.status = sale.status
);


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

SELECT name FROM projects AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS emp
    WHERE emp.status = empl.status
);


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

SELECT salary FROM departments AS empl
WHERE status IN (
    SELECT status FROM projects AS shp
    WHERE shp.type = empl.type
);


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

SELECT salary FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.code = emp.code
);


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

SELECT value FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.type = inv.type
);


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

SELECT amount FROM departments AS srvc
WHERE salary > (
    SELECT AVG(value) FROM customers AS whs
    WHERE whs.code = srvc.code
);


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

SELECT salary FROM tasks AS lne
WHERE value > (
    SELECT SUM(salary) FROM invoices AS acct
    WHERE acct.type = lne.type
);


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

SELECT name FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT value FROM transactions AS empl
WHERE status IN (
    SELECT status FROM categories AS lne
    WHERE lne.status = empl.status
);


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

SELECT id FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.code = inv.code
);


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

SELECT salary FROM transactions AS shp
WHERE level IN (
    SELECT level FROM employees AS whs
    WHERE whs.status = shp.status
);


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

SELECT id FROM invoices AS whs
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.code = whs.code
);


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

SELECT name FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = srvc.level
);


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

SELECT amount FROM transactions AS whs
WHERE code IN (
    SELECT code FROM invoices AS budg
    WHERE budg.type = whs.type
);


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

SELECT salary FROM accounts AS catg
WHERE salary > (
    SELECT MAX(salary) FROM products AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT name FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.id = prod.id
);


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

SELECT id FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.level = catg.level
);


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

SELECT name FROM customers AS txn
WHERE status IN (
    SELECT status FROM regions AS mgr
    WHERE mgr.id = txn.id
);


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

SELECT id FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.level = empl.level
);


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

SELECT salary FROM accounts AS ord
WHERE type IN (
    SELECT type FROM employees AS catg
    WHERE catg.level = ord.level
);


Prompt:
Schema:
  tasks (alias: lne)(name, salary, status, type)
  projects(salary, date, value, name)
Task: Retrieve value from tasks with salary above the MIN(value) of projects rows sharing the same status.
SQL:

SELECT value FROM tasks AS lne
WHERE salary > (
    SELECT MIN(value) FROM projects AS emp
    WHERE emp.status = lne.status
);


Prompt:
Schema:
  regions (alias: ord)(id, salary, date, name)
  orders(date, id, type, code)
Task: Retrieve amount from regions with salary above the AVG(salary) of orders rows sharing the same type.
SQL:

SELECT amount FROM regions AS ord
WHERE salary > (
    SELECT AVG(salary) FROM orders AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT salary FROM projects AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM categories AS shp
    WHERE shp.status = ordr.status
);


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

SELECT code FROM warehouses AS ord
WHERE value > (
    SELECT SUM(amount) FROM invoices AS cust
    WHERE cust.level = ord.level
);


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

SELECT salary FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.status = txn.status
);


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

SELECT salary FROM suppliers AS inv
WHERE value > (
    SELECT MIN(amount) FROM products AS prod
    WHERE prod.code = inv.code
);


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

SELECT id FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.id = shp.id
);


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

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


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

SELECT salary FROM orders AS txn
WHERE code IN (
    SELECT code FROM warehouses AS emp
    WHERE emp.code = txn.code
);


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

SELECT id FROM products AS lne
WHERE id IN (
    SELECT id FROM invoices AS acct
    WHERE acct.level = lne.level
);


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

SELECT name FROM shipments AS inv
WHERE level IN (
    SELECT level FROM projects AS emp
    WHERE emp.status = inv.status
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.code = empl.code
);


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

SELECT amount FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.type = ord.type
);


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

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


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

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


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

SELECT amount FROM categories AS dept
WHERE id IN (
    SELECT id FROM products AS catg
    WHERE catg.level = dept.level
);


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

SELECT name FROM categories AS prod
WHERE salary > (
    SELECT MIN(value) FROM shipments AS whs
    WHERE whs.status = prod.status
);


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

SELECT value FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.code = lne.code
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT id FROM warehouses AS cust
WHERE type IN (
    SELECT type FROM invoices AS catg
    WHERE catg.status = cust.status
);


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

SELECT id FROM branches AS cust
WHERE type IN (
    SELECT type FROM shipments AS budg
    WHERE budg.status = cust.status
);


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

SELECT value FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.code = srvc.code
);


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

SELECT code FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.level = schd.level
);


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

SELECT amount FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.status = whs.status
);


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

SELECT salary FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT name FROM suppliers AS budg
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS dept
    WHERE dept.code = budg.code
);


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

SELECT id FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.status = catg.status
);


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

SELECT amount FROM tasks AS sale
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS prod
    WHERE prod.code = sale.code
);


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

SELECT amount FROM regions AS acct
WHERE value > (
    SELECT MAX(amount) FROM departments AS prod
    WHERE prod.id = acct.id
);


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

SELECT amount FROM orders AS catg
WHERE value > (
    SELECT MAX(salary) FROM transactions AS rgn
    WHERE rgn.status = catg.status
);


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

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


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

SELECT id FROM shipments AS dept
WHERE value > (
    SELECT SUM(salary) FROM orders AS prod
    WHERE prod.level = dept.level
);


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

SELECT id FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.level = ordr.level
);


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

SELECT salary FROM suppliers AS txn
WHERE type IN (
    SELECT type FROM categories AS ord
    WHERE ord.code = txn.code
);


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

SELECT id FROM departments AS shp
WHERE id IN (
    SELECT id FROM invoices AS lne
    WHERE lne.id = shp.id
);


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

SELECT id FROM transactions AS prod
WHERE salary > (
    SELECT SUM(value) FROM employees AS sale
    WHERE sale.type = prod.type
);


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

SELECT amount FROM customers AS rgn
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS ord
    WHERE ord.id = rgn.id
);


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

SELECT salary FROM employees AS mgr
WHERE status IN (
    SELECT status FROM warehouses AS rgn
    WHERE rgn.level = mgr.level
);


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

SELECT code FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.level = whs.level
);


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

SELECT salary FROM customers AS txn
WHERE id IN (
    SELECT id FROM transactions AS cust
    WHERE cust.type = txn.type
);


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

SELECT amount FROM warehouses AS inv
WHERE id IN (
    SELECT id FROM suppliers AS empl
    WHERE empl.level = inv.level
);


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

SELECT name FROM transactions AS prod
WHERE code IN (
    SELECT code FROM accounts AS srvc
    WHERE srvc.status = prod.status
);


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

SELECT amount FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.level = cust.level
);


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

SELECT name FROM categories AS mgr
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.code = mgr.code
);


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

SELECT salary FROM employees AS acct
WHERE value > (
    SELECT MIN(value) FROM warehouses AS txn
    WHERE txn.id = acct.id
);


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

SELECT value FROM accounts AS shp
WHERE id IN (
    SELECT id FROM orders AS ordr
    WHERE ordr.status = shp.status
);


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

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


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

SELECT name FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.status = ord.status
);


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

SELECT salary FROM departments AS srvc
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS catg
    WHERE catg.level = srvc.level
);


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

SELECT name FROM categories AS emp
WHERE value > (
    SELECT MAX(amount) FROM warehouses AS whs
    WHERE whs.code = emp.code
);


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

SELECT amount FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT code FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = empl.type
);


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

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


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

SELECT id FROM invoices AS shp
WHERE type IN (
    SELECT type FROM accounts AS emp
    WHERE emp.code = shp.code
);


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

SELECT salary FROM categories AS lne
WHERE level IN (
    SELECT level FROM tasks AS emp
    WHERE emp.level = lne.level
);


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

SELECT code FROM projects AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS acct
    WHERE acct.type = schd.type
);


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

SELECT code FROM transactions AS sale
WHERE level IN (
    SELECT level FROM regions AS ord
    WHERE ord.code = sale.code
);


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

SELECT salary FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.code = prod.code
);


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

SELECT id FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.id = srvc.id
);


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

SELECT amount FROM transactions AS mgr
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS shp
    WHERE shp.code = mgr.code
);


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

SELECT salary FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.status = mgr.status
);


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

SELECT code FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT name FROM categories AS inv
WHERE value > (
    SELECT AVG(value) FROM transactions AS whs
    WHERE whs.id = inv.id
);


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

SELECT id FROM shipments AS budg
WHERE type IN (
    SELECT type FROM accounts AS shp
    WHERE shp.status = budg.status
);


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

SELECT value FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.level = sale.level
);


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

SELECT salary FROM employees AS shp
WHERE salary > (
    SELECT SUM(amount) FROM regions AS acct
    WHERE acct.type = shp.type
);


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

SELECT amount FROM suppliers AS shp
WHERE amount > (
    SELECT MAX(salary) FROM orders AS dept
    WHERE dept.code = shp.code
);


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

SELECT name FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.code = sale.code
);


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

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


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

SELECT amount FROM warehouses AS txn
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.status = txn.status
);


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

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


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

SELECT id FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.level = prod.level
);


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

SELECT id FROM shipments AS catg
WHERE code IN (
    SELECT code FROM accounts AS inv
    WHERE inv.type = catg.type
);


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

SELECT salary FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT id FROM shipments AS srvc
WHERE code IN (
    SELECT code FROM tasks AS dept
    WHERE dept.level = srvc.level
);


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

SELECT amount FROM employees AS inv
WHERE id IN (
    SELECT id FROM orders AS prod
    WHERE prod.code = inv.code
);


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

SELECT name FROM departments AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS cust
    WHERE cust.code = mgr.code
);


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

SELECT amount FROM departments AS prod
WHERE value > (
    SELECT MAX(value) FROM categories AS shp
    WHERE shp.level = prod.level
);


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

SELECT amount FROM invoices AS rgn
WHERE id IN (
    SELECT id FROM suppliers AS emp
    WHERE emp.id = rgn.id
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.id = txn.id
);


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

SELECT code FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.id = empl.id
);


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

SELECT salary FROM accounts AS rgn
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS shp
    WHERE shp.type = rgn.type
);


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

SELECT code FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.type = ord.type
);


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

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


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

SELECT amount FROM orders AS prod
WHERE value > (
    SELECT MIN(value) FROM invoices AS lne
    WHERE lne.code = prod.code
);


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

SELECT amount FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT salary FROM suppliers AS dept
WHERE level IN (
    SELECT level FROM regions AS rgn
    WHERE rgn.id = dept.id
);


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

SELECT value FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.code = schd.code
);


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

SELECT amount FROM warehouses AS emp
WHERE level IN (
    SELECT level FROM invoices AS sale
    WHERE sale.id = emp.id
);


Prompt:
Schema:
  projects (alias: lne)(amount, id, level, value)
  departments(id, level, amount, salary)
Task: Retrieve name from projects with value above the SUM(value) of departments rows sharing the same id.
SQL:

SELECT name FROM projects AS lne
WHERE value > (
    SELECT SUM(value) FROM departments AS acct
    WHERE acct.id = lne.id
);


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

SELECT id FROM branches AS acct
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.id = acct.id
);


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

SELECT name FROM projects AS mgr
WHERE level IN (
    SELECT level FROM transactions AS budg
    WHERE budg.id = mgr.id
);


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

SELECT code FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.id = lne.id
);


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

SELECT value FROM shipments AS whs
WHERE level IN (
    SELECT level FROM projects AS acct
    WHERE acct.id = whs.id
);


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

SELECT code FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.type = shp.type
);


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

SELECT salary FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.id = txn.id
);


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

SELECT code FROM employees AS catg
WHERE value > (
    SELECT SUM(amount) FROM orders AS txn
    WHERE txn.status = catg.status
);


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

SELECT code FROM customers AS whs
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS catg
    WHERE catg.status = whs.status
);


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

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


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

SELECT amount FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.status = ordr.status
);


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

SELECT amount FROM invoices AS schd
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT name FROM accounts AS budg
WHERE code IN (
    SELECT code FROM departments AS lne
    WHERE lne.status = budg.status
);


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

SELECT value FROM transactions AS shp
WHERE value > (
    SELECT COUNT(value) FROM accounts AS dept
    WHERE dept.type = shp.type
);


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

SELECT salary FROM accounts AS lne
WHERE status IN (
    SELECT status FROM warehouses AS srvc
    WHERE srvc.type = lne.type
);


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

SELECT salary FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT name FROM regions AS ordr
WHERE id IN (
    SELECT id FROM employees AS catg
    WHERE catg.status = ordr.status
);


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

SELECT name FROM regions AS empl
WHERE status IN (
    SELECT status FROM suppliers AS cust
    WHERE cust.level = empl.level
);


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

SELECT name FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.level = shp.level
);


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

SELECT name FROM departments AS acct
WHERE type IN (
    SELECT type FROM regions AS catg
    WHERE catg.level = acct.level
);


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

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


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

SELECT value FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.code = inv.code
);


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

SELECT value FROM projects AS inv
WHERE value > (
    SELECT AVG(value) FROM categories AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT salary FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.type = txn.type
);


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

SELECT id FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.status = catg.status
);


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

SELECT value FROM tasks AS srvc
WHERE status IN (
    SELECT status FROM projects AS lne
    WHERE lne.type = srvc.type
);


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

SELECT id FROM categories AS dept
WHERE code IN (
    SELECT code FROM orders AS emp
    WHERE emp.code = dept.code
);


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

SELECT name FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.code = whs.code
);


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

SELECT code FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.id = ordr.id
);


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

SELECT amount FROM customers AS sale
WHERE type IN (
    SELECT type FROM categories AS emp
    WHERE emp.id = sale.id
);


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

SELECT value FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT id FROM accounts AS schd
WHERE value > (
    SELECT MAX(value) FROM employees AS shp
    WHERE shp.status = schd.status
);


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

SELECT id FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.status = acct.status
);


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

SELECT code FROM transactions AS ordr
WHERE value > (
    SELECT AVG(salary) FROM tasks AS whs
    WHERE whs.level = ordr.level
);


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

SELECT code FROM shipments AS mgr
WHERE value > (
    SELECT MIN(salary) FROM accounts AS budg
    WHERE budg.status = mgr.status
);


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

SELECT amount FROM branches AS rgn
WHERE level IN (
    SELECT level FROM shipments AS catg
    WHERE catg.type = rgn.type
);


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

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


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

SELECT salary FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.status = empl.status
);


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

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


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

SELECT salary FROM orders AS srvc
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS sale
    WHERE sale.level = srvc.level
);


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

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


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

SELECT id FROM products AS lne
WHERE type IN (
    SELECT type FROM accounts AS txn
    WHERE txn.status = lne.status
);


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

SELECT id FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.level = rgn.level
);


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

SELECT salary FROM orders AS schd
WHERE code IN (
    SELECT code FROM categories AS shp
    WHERE shp.code = schd.code
);


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

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


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

SELECT code FROM tasks AS ord
WHERE type IN (
    SELECT type FROM products AS whs
    WHERE whs.level = ord.level
);


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

SELECT id FROM branches AS mgr
WHERE value > (
    SELECT AVG(value) FROM invoices AS budg
    WHERE budg.type = mgr.type
);


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

SELECT amount FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.level = cust.level
);


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

SELECT code FROM categories AS acct
WHERE value > (
    SELECT SUM(salary) FROM departments AS budg
    WHERE budg.type = acct.type
);


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

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


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

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


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

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


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

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


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

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


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

SELECT name FROM shipments AS shp
WHERE amount > (
    SELECT AVG(value) FROM products AS lne
    WHERE lne.id = shp.id
);


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

SELECT salary FROM shipments AS cust
WHERE amount > (
    SELECT SUM(value) FROM transactions AS shp
    WHERE shp.level = cust.level
);


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

SELECT id FROM products AS whs
WHERE id IN (
    SELECT id FROM customers AS lne
    WHERE lne.status = whs.status
);


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

SELECT amount FROM transactions AS catg
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS shp
    WHERE shp.type = catg.type
);


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

SELECT salary FROM regions AS ord
WHERE code IN (
    SELECT code FROM departments AS cust
    WHERE cust.level = ord.level
);


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

SELECT value FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.code = schd.code
);


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

SELECT salary FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT name FROM employees AS budg
WHERE type IN (
    SELECT type FROM shipments AS catg
    WHERE catg.type = budg.type
);


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

SELECT amount FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.type = catg.type
);


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

SELECT id FROM tasks AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS shp
    WHERE shp.level = mgr.level
);


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

SELECT value FROM transactions AS srvc
WHERE level IN (
    SELECT level FROM tasks AS txn
    WHERE txn.status = srvc.status
);


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

SELECT amount FROM suppliers AS txn
WHERE status IN (
    SELECT status FROM customers AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT amount FROM orders AS schd
WHERE value > (
    SELECT MAX(value) FROM regions AS sale
    WHERE sale.id = schd.id
);


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

SELECT id FROM orders AS budg
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS inv
    WHERE inv.code = budg.code
);


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

SELECT salary FROM regions AS cust
WHERE code IN (
    SELECT code FROM warehouses AS sale
    WHERE sale.type = cust.type
);


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

SELECT id FROM transactions AS mgr
WHERE code IN (
    SELECT code FROM warehouses AS acct
    WHERE acct.level = mgr.level
);


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

SELECT name FROM branches AS sale
WHERE value > (
    SELECT MAX(amount) FROM customers AS prod
    WHERE prod.code = sale.code
);


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

SELECT id FROM departments AS emp
WHERE code IN (
    SELECT code FROM orders AS shp
    WHERE shp.code = emp.code
);


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

SELECT id FROM categories AS empl
WHERE level IN (
    SELECT level FROM products AS ordr
    WHERE ordr.status = empl.status
);


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

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


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

SELECT code FROM tasks AS cust
WHERE status IN (
    SELECT status FROM customers AS empl
    WHERE empl.status = cust.status
);


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

SELECT id FROM departments AS schd
WHERE status IN (
    SELECT status FROM branches AS lne
    WHERE lne.status = schd.status
);


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

SELECT name FROM products AS ordr
WHERE status IN (
    SELECT status FROM accounts AS shp
    WHERE shp.level = ordr.level
);


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

SELECT value FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.type = mgr.type
);


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

SELECT value FROM accounts AS acct
WHERE status IN (
    SELECT status FROM tasks AS emp
    WHERE emp.type = acct.type
);


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

SELECT amount FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT value FROM regions AS schd
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS prod
    WHERE prod.level = schd.level
);


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

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


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

SELECT amount FROM invoices AS sale
WHERE value > (
    SELECT AVG(amount) FROM shipments AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT code FROM customers AS empl
WHERE value > (
    SELECT SUM(salary) FROM regions AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT code FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.status = txn.status
);


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

SELECT code FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.code = srvc.code
);


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

SELECT value FROM orders AS mgr
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS whs
    WHERE whs.status = mgr.status
);


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

SELECT id FROM categories AS ord
WHERE salary > (
    SELECT MAX(value) FROM customers AS txn
    WHERE txn.id = ord.id
);


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

SELECT code FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.level = emp.level
);


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

SELECT id FROM invoices AS ordr
WHERE value > (
    SELECT SUM(value) FROM employees AS ord
    WHERE ord.level = ordr.level
);


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

SELECT code FROM orders AS emp
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.type = emp.type
);


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

SELECT code FROM projects AS ord
WHERE code IN (
    SELECT code FROM transactions AS txn
    WHERE txn.type = ord.type
);


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

SELECT value FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.code = emp.code
);


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

SELECT value FROM departments AS dept
WHERE value > (
    SELECT COUNT(salary) FROM warehouses AS shp
    WHERE shp.type = dept.type
);


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

SELECT amount FROM employees AS ordr
WHERE id IN (
    SELECT id FROM suppliers AS acct
    WHERE acct.type = ordr.type
);


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

SELECT salary FROM suppliers AS rgn
WHERE type IN (
    SELECT type FROM accounts AS lne
    WHERE lne.type = rgn.type
);


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

SELECT name FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.level = inv.level
);


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

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


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

SELECT amount FROM suppliers AS srvc
WHERE type IN (
    SELECT type FROM accounts AS empl
    WHERE empl.id = srvc.id
);


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

SELECT name FROM suppliers AS empl
WHERE type IN (
    SELECT type FROM branches AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT salary FROM projects AS emp
WHERE code IN (
    SELECT code FROM accounts AS empl
    WHERE empl.id = emp.id
);


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

SELECT id FROM tasks AS emp
WHERE code IN (
    SELECT code FROM accounts AS cust
    WHERE cust.level = emp.level
);


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

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


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

SELECT amount FROM tasks AS lne
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT value FROM products AS budg
WHERE value > (
    SELECT MAX(salary) FROM warehouses AS ord
    WHERE ord.type = budg.type
);


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

SELECT value FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.level = catg.level
);


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

SELECT value FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT value FROM orders AS cust
WHERE code IN (
    SELECT code FROM warehouses AS shp
    WHERE shp.level = cust.level
);


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

SELECT salary FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.status = schd.status
);


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

SELECT salary FROM invoices AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM employees AS lne
    WHERE lne.type = ordr.type
);


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

SELECT salary FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.code = cust.code
);


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

SELECT amount FROM shipments AS catg
WHERE status IN (
    SELECT status FROM regions AS srvc
    WHERE srvc.code = catg.code
);


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

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


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

SELECT value FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.id = lne.id
);


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

SELECT salary FROM branches AS shp
WHERE code IN (
    SELECT code FROM tasks AS prod
    WHERE prod.type = shp.type
);


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

SELECT id FROM shipments AS sale
WHERE code IN (
    SELECT code FROM orders AS inv
    WHERE inv.level = sale.level
);


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

SELECT salary FROM shipments AS ord
WHERE salary > (
    SELECT SUM(salary) FROM products AS prod
    WHERE prod.code = ord.code
);


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

SELECT value FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT name FROM products AS acct
WHERE amount > (
    SELECT MIN(value) FROM branches AS emp
    WHERE emp.status = acct.status
);


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

SELECT salary FROM projects AS whs
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.level = whs.level
);


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

SELECT amount FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.status = lne.status
);


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

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


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

SELECT code FROM suppliers AS budg
WHERE code IN (
    SELECT code FROM products AS rgn
    WHERE rgn.level = budg.level
);


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

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


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

SELECT id FROM employees AS budg
WHERE type IN (
    SELECT type FROM tasks AS txn
    WHERE txn.status = budg.status
);


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

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


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

SELECT code FROM regions AS ord
WHERE amount > (
    SELECT MIN(salary) FROM products AS txn
    WHERE txn.level = ord.level
);


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

SELECT amount FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT code FROM invoices AS cust
WHERE amount > (
    SELECT MAX(salary) FROM regions AS sale
    WHERE sale.status = cust.status
);


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

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


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

SELECT code FROM projects AS rgn
WHERE type IN (
    SELECT type FROM suppliers AS shp
    WHERE shp.id = rgn.id
);


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

SELECT amount FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = cust.level
);


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

SELECT name FROM invoices AS catg
WHERE salary > (
    SELECT MIN(salary) FROM categories AS whs
    WHERE whs.type = catg.type
);


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

SELECT code FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT name FROM branches AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM customers AS dept
    WHERE dept.status = ordr.status
);


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

SELECT value FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.id = dept.id
);


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

SELECT code FROM departments AS sale
WHERE value > (
    SELECT AVG(salary) FROM projects AS rgn
    WHERE rgn.type = sale.type
);


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

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


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

SELECT name FROM invoices AS mgr
WHERE value > (
    SELECT MAX(value) FROM departments AS sale
    WHERE sale.level = mgr.level
);


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

SELECT code FROM branches AS empl
WHERE id IN (
    SELECT id FROM tasks AS rgn
    WHERE rgn.status = empl.status
);


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

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


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

SELECT name FROM accounts AS txn
WHERE amount > (
    SELECT SUM(salary) FROM categories AS empl
    WHERE empl.id = txn.id
);


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

SELECT amount FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.status = ordr.status
);