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

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


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

SELECT id FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.status = mgr.status
);


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

SELECT id FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.level = sale.level
);


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

SELECT id FROM tasks AS empl
WHERE amount > (
    SELECT COUNT(value) FROM categories AS budg
    WHERE budg.type = empl.type
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.id = dept.id
);


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

SELECT value FROM projects AS ordr
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.level = ordr.level
);


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

SELECT name FROM projects AS srvc
WHERE code IN (
    SELECT code FROM invoices AS prod
    WHERE prod.type = srvc.type
);


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

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


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

SELECT id FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.level = emp.level
);


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

SELECT value FROM departments AS lne
WHERE value > (
    SELECT MIN(value) FROM branches AS dept
    WHERE dept.status = lne.status
);


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

SELECT amount FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = rgn.level
);


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

SELECT value FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.type = shp.type
);


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

SELECT amount FROM categories AS dept
WHERE status IN (
    SELECT status FROM tasks AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT code FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.level = whs.level
);


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

SELECT salary FROM transactions AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT value FROM projects AS txn
WHERE id IN (
    SELECT id FROM employees AS dept
    WHERE dept.status = txn.status
);


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

SELECT value FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.id = prod.id
);


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

SELECT salary FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.code = empl.code
);


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

SELECT amount FROM products AS shp
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS budg
    WHERE budg.type = shp.type
);


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

SELECT id FROM accounts AS mgr
WHERE level IN (
    SELECT level FROM invoices AS dept
    WHERE dept.status = mgr.status
);


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

SELECT id FROM employees AS whs
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS dept
    WHERE dept.type = whs.type
);


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

SELECT code FROM branches AS txn
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS schd
    WHERE schd.code = txn.code
);


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

SELECT salary FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.status = srvc.status
);


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

SELECT code FROM branches AS inv
WHERE code IN (
    SELECT code FROM tasks AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT code FROM tasks AS prod
WHERE id IN (
    SELECT id FROM products AS txn
    WHERE txn.status = prod.status
);


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

SELECT name FROM branches AS acct
WHERE code IN (
    SELECT code FROM invoices AS emp
    WHERE emp.type = acct.type
);


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

SELECT id FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.type = prod.type
);


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

SELECT name FROM employees AS budg
WHERE id IN (
    SELECT id FROM branches AS prod
    WHERE prod.code = budg.code
);


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

SELECT name FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.level = lne.level
);


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

SELECT code FROM regions AS inv
WHERE code IN (
    SELECT code FROM projects AS ord
    WHERE ord.code = inv.code
);


Prompt:
Schema:
  invoices (alias: mgr)(type, salary, value, code)
  suppliers(type, value, salary, amount)
Task: Retrieve salary from invoices with value above the AVG(value) of suppliers rows sharing the same type.
SQL:

SELECT salary FROM invoices AS mgr
WHERE value > (
    SELECT AVG(value) FROM suppliers AS dept
    WHERE dept.type = mgr.type
);


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

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


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

SELECT name FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.status = empl.status
);


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

SELECT id FROM warehouses AS catg
WHERE level IN (
    SELECT level FROM employees AS inv
    WHERE inv.id = catg.id
);


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

SELECT id FROM customers AS rgn
WHERE type IN (
    SELECT type FROM tasks AS cust
    WHERE cust.code = rgn.code
);


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

SELECT amount FROM projects AS dept
WHERE code IN (
    SELECT code FROM employees AS txn
    WHERE txn.code = dept.code
);


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

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


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

SELECT amount FROM invoices AS rgn
WHERE status IN (
    SELECT status FROM categories AS lne
    WHERE lne.code = rgn.code
);


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

SELECT id FROM tasks AS mgr
WHERE type IN (
    SELECT type FROM categories AS emp
    WHERE emp.code = mgr.code
);


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

SELECT code FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.status = dept.status
);


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

SELECT id FROM departments AS ord
WHERE code IN (
    SELECT code FROM suppliers AS emp
    WHERE emp.level = ord.level
);


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

SELECT name FROM suppliers AS whs
WHERE level IN (
    SELECT level FROM branches AS emp
    WHERE emp.id = whs.id
);


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

SELECT salary FROM products AS schd
WHERE value > (
    SELECT COUNT(amount) FROM projects AS prod
    WHERE prod.code = schd.code
);


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

SELECT value FROM warehouses AS sale
WHERE salary > (
    SELECT MIN(amount) FROM regions AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT name FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.type = mgr.type
);


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

SELECT id FROM accounts AS budg
WHERE id IN (
    SELECT id FROM categories AS schd
    WHERE schd.level = budg.level
);


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

SELECT salary FROM accounts AS mgr
WHERE value > (
    SELECT MIN(value) FROM departments AS inv
    WHERE inv.type = mgr.type
);


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

SELECT id FROM branches AS dept
WHERE status IN (
    SELECT status FROM departments AS catg
    WHERE catg.status = dept.status
);


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

SELECT amount FROM warehouses AS shp
WHERE type IN (
    SELECT type FROM customers AS sale
    WHERE sale.status = shp.status
);


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

SELECT value FROM products AS rgn
WHERE value > (
    SELECT SUM(value) FROM projects AS srvc
    WHERE srvc.code = rgn.code
);


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

SELECT salary FROM customers AS srvc
WHERE amount > (
    SELECT SUM(value) FROM warehouses AS txn
    WHERE txn.code = srvc.code
);


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

SELECT value FROM projects AS rgn
WHERE salary > (
    SELECT COUNT(salary) FROM products AS ord
    WHERE ord.status = rgn.status
);


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

SELECT code FROM branches AS rgn
WHERE code IN (
    SELECT code FROM regions AS schd
    WHERE schd.status = rgn.status
);


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

SELECT amount FROM employees AS sale
WHERE salary > (
    SELECT MAX(value) FROM transactions AS cust
    WHERE cust.id = sale.id
);


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

SELECT id FROM suppliers AS budg
WHERE amount > (
    SELECT AVG(value) FROM transactions AS lne
    WHERE lne.level = budg.level
);


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

SELECT id FROM branches AS sale
WHERE value > (
    SELECT MAX(amount) FROM products AS emp
    WHERE emp.id = sale.id
);


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

SELECT name FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.code = ord.code
);


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

SELECT name FROM employees AS inv
WHERE salary > (
    SELECT AVG(value) FROM branches AS cust
    WHERE cust.status = inv.status
);


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

SELECT name FROM categories AS catg
WHERE type IN (
    SELECT type FROM accounts AS mgr
    WHERE mgr.type = catg.type
);


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

SELECT id FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT amount FROM customers AS shp
WHERE type IN (
    SELECT type FROM shipments AS catg
    WHERE catg.status = shp.status
);


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

SELECT salary FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.id = ordr.id
);


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

SELECT value FROM customers AS srvc
WHERE code IN (
    SELECT code FROM orders AS lne
    WHERE lne.type = srvc.type
);


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

SELECT name FROM projects AS mgr
WHERE code IN (
    SELECT code FROM orders AS sale
    WHERE sale.level = mgr.level
);


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

SELECT code FROM employees AS dept
WHERE level IN (
    SELECT level FROM products AS whs
    WHERE whs.level = dept.level
);


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

SELECT amount FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.level = lne.level
);


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

SELECT code FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.code = sale.code
);


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

SELECT code FROM products AS whs
WHERE code IN (
    SELECT code FROM suppliers AS dept
    WHERE dept.status = whs.status
);


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

SELECT id FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.code = emp.code
);


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

SELECT salary FROM warehouses AS ordr
WHERE salary > (
    SELECT AVG(value) FROM branches AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT code FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT name FROM departments AS whs
WHERE status IN (
    SELECT status FROM employees AS schd
    WHERE schd.type = whs.type
);


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

SELECT code FROM employees AS ord
WHERE salary > (
    SELECT AVG(amount) FROM customers AS acct
    WHERE acct.id = ord.id
);


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

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


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

SELECT name FROM orders AS prod
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT name FROM invoices AS cust
WHERE value > (
    SELECT MAX(salary) FROM suppliers AS emp
    WHERE emp.code = cust.code
);


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

SELECT value FROM transactions AS rgn
WHERE salary > (
    SELECT AVG(value) FROM customers AS catg
    WHERE catg.code = rgn.code
);


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

SELECT salary FROM departments AS txn
WHERE value > (
    SELECT AVG(amount) FROM employees AS sale
    WHERE sale.id = txn.id
);


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

SELECT salary FROM products AS budg
WHERE id IN (
    SELECT id FROM employees AS schd
    WHERE schd.code = budg.code
);


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

SELECT name FROM transactions AS emp
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS lne
    WHERE lne.level = emp.level
);


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

SELECT name FROM regions AS whs
WHERE code IN (
    SELECT code FROM invoices AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT id FROM suppliers AS ordr
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS catg
    WHERE catg.id = ordr.id
);


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

SELECT value FROM regions AS srvc
WHERE code IN (
    SELECT code FROM products AS inv
    WHERE inv.type = srvc.type
);


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

SELECT amount FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.id = ord.id
);


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

SELECT name FROM products AS empl
WHERE code IN (
    SELECT code FROM warehouses AS inv
    WHERE inv.level = empl.level
);


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

SELECT name FROM orders AS acct
WHERE code IN (
    SELECT code FROM tasks AS lne
    WHERE lne.code = acct.code
);


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

SELECT name FROM shipments AS whs
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS cust
    WHERE cust.code = whs.code
);


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

SELECT name FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.id = txn.id
);


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

SELECT salary FROM products AS schd
WHERE type IN (
    SELECT type FROM accounts AS lne
    WHERE lne.level = schd.level
);


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

SELECT salary FROM categories AS dept
WHERE level IN (
    SELECT level FROM regions AS txn
    WHERE txn.code = dept.code
);


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

SELECT name FROM accounts AS srvc
WHERE id IN (
    SELECT id FROM projects AS cust
    WHERE cust.id = srvc.id
);


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

SELECT code FROM warehouses AS empl
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT amount FROM employees AS sale
WHERE code IN (
    SELECT code FROM transactions AS ord
    WHERE ord.type = sale.type
);


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

SELECT value FROM suppliers AS budg
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS whs
    WHERE whs.id = budg.id
);


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

SELECT id FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.type = acct.type
);


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

SELECT code FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.status = catg.status
);


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

SELECT id FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.type = sale.type
);


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

SELECT salary FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.status = catg.status
);


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

SELECT amount FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT code FROM orders AS inv
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS lne
    WHERE lne.level = inv.level
);


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

SELECT value FROM suppliers AS acct
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS catg
    WHERE catg.status = acct.status
);


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

SELECT id FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.level = mgr.level
);


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

SELECT salary FROM regions AS inv
WHERE id IN (
    SELECT id FROM branches AS prod
    WHERE prod.level = inv.level
);


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

SELECT amount FROM departments AS emp
WHERE code IN (
    SELECT code FROM shipments AS budg
    WHERE budg.status = emp.status
);


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

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


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

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


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

SELECT code FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.type = budg.type
);


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

SELECT id FROM regions AS mgr
WHERE level IN (
    SELECT level FROM suppliers AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT amount FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT code FROM accounts AS ord
WHERE id IN (
    SELECT id FROM employees AS lne
    WHERE lne.type = ord.type
);


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

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


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

SELECT value FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = prod.level
);


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

SELECT code FROM branches AS mgr
WHERE level IN (
    SELECT level FROM suppliers AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT amount FROM projects AS emp
WHERE amount > (
    SELECT SUM(value) FROM products AS acct
    WHERE acct.code = emp.code
);


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

SELECT value FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.code = shp.code
);


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

SELECT salary FROM branches AS empl
WHERE status IN (
    SELECT status FROM orders AS acct
    WHERE acct.level = empl.level
);


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

SELECT amount FROM shipments AS cust
WHERE type IN (
    SELECT type FROM transactions AS srvc
    WHERE srvc.level = cust.level
);


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

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


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

SELECT name FROM categories AS cust
WHERE type IN (
    SELECT type FROM suppliers AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT name FROM departments AS srvc
WHERE code IN (
    SELECT code FROM transactions AS sale
    WHERE sale.status = srvc.status
);


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

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


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

SELECT value FROM categories AS lne
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS dept
    WHERE dept.status = lne.status
);


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

SELECT id FROM tasks AS srvc
WHERE type IN (
    SELECT type FROM products AS sale
    WHERE sale.type = srvc.type
);


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

SELECT name FROM accounts AS catg
WHERE id IN (
    SELECT id FROM customers AS sale
    WHERE sale.id = catg.id
);


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

SELECT name FROM shipments AS inv
WHERE status IN (
    SELECT status FROM accounts AS sale
    WHERE sale.level = inv.level
);


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

SELECT value FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = whs.type
);


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

SELECT name FROM products AS dept
WHERE value > (
    SELECT SUM(value) FROM warehouses AS lne
    WHERE lne.type = dept.type
);


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

SELECT id FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.level = budg.level
);


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

SELECT code FROM customers AS ordr
WHERE code IN (
    SELECT code FROM regions AS budg
    WHERE budg.type = ordr.type
);


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

SELECT value FROM regions AS schd
WHERE value > (
    SELECT MIN(salary) FROM departments AS txn
    WHERE txn.type = schd.type
);


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

SELECT id FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.id = empl.id
);


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

SELECT name FROM customers AS prod
WHERE code IN (
    SELECT code FROM products AS schd
    WHERE schd.status = prod.status
);


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

SELECT amount FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.type = whs.type
);


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

SELECT value FROM projects AS ordr
WHERE level IN (
    SELECT level FROM warehouses AS dept
    WHERE dept.code = ordr.code
);


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

SELECT id FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.code = emp.code
);


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

SELECT salary FROM shipments AS schd
WHERE value > (
    SELECT COUNT(salary) FROM orders AS shp
    WHERE shp.id = schd.id
);


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

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


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

SELECT id FROM regions AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM warehouses AS empl
    WHERE empl.status = sale.status
);


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

SELECT code FROM projects AS schd
WHERE status IN (
    SELECT status FROM transactions AS budg
    WHERE budg.id = schd.id
);


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

SELECT id FROM employees AS lne
WHERE type IN (
    SELECT type FROM warehouses AS rgn
    WHERE rgn.code = lne.code
);


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

SELECT name FROM projects AS cust
WHERE amount > (
    SELECT SUM(salary) FROM orders AS whs
    WHERE whs.level = cust.level
);


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

SELECT value FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT name FROM invoices AS dept
WHERE value > (
    SELECT MIN(value) FROM tasks AS srvc
    WHERE srvc.code = dept.code
);


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

SELECT code FROM accounts AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT id FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.code = whs.code
);


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

SELECT id FROM orders AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS inv
    WHERE inv.status = ord.status
);


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

SELECT id FROM categories AS mgr
WHERE value > (
    SELECT SUM(value) FROM regions AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT id FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.level = acct.level
);


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

SELECT id FROM employees AS acct
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS inv
    WHERE inv.code = acct.code
);


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

SELECT amount FROM invoices AS sale
WHERE amount > (
    SELECT SUM(amount) FROM orders AS whs
    WHERE whs.level = sale.level
);


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

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


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

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


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

SELECT salary FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.level = budg.level
);


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

SELECT name FROM regions AS acct
WHERE code IN (
    SELECT code FROM tasks AS sale
    WHERE sale.level = acct.level
);


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

SELECT id FROM regions AS ordr
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT code FROM orders AS ordr
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.status = ordr.status
);


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

SELECT salary FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT name FROM invoices AS sale
WHERE code IN (
    SELECT code FROM orders AS catg
    WHERE catg.type = sale.type
);


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

SELECT name FROM tasks AS lne
WHERE code IN (
    SELECT code FROM regions AS shp
    WHERE shp.code = lne.code
);


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

SELECT salary FROM customers AS ordr
WHERE id IN (
    SELECT id FROM categories AS ord
    WHERE ord.level = ordr.level
);


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

SELECT salary FROM projects AS shp
WHERE status IN (
    SELECT status FROM shipments AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT name FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.type = dept.type
);


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

SELECT amount FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.status = rgn.status
);


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

SELECT value FROM departments AS mgr
WHERE level IN (
    SELECT level FROM orders AS acct
    WHERE acct.code = mgr.code
);


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

SELECT amount FROM transactions AS inv
WHERE level IN (
    SELECT level FROM customers AS sale
    WHERE sale.type = inv.type
);


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

SELECT value FROM projects AS srvc
WHERE code IN (
    SELECT code FROM branches AS dept
    WHERE dept.code = srvc.code
);


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

SELECT name FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.id = catg.id
);


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

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


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

SELECT name FROM regions AS ordr
WHERE code IN (
    SELECT code FROM invoices AS inv
    WHERE inv.code = ordr.code
);


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

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


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

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


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

SELECT id FROM orders AS shp
WHERE level IN (
    SELECT level FROM shipments AS txn
    WHERE txn.id = shp.id
);


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

SELECT code FROM warehouses AS shp
WHERE status IN (
    SELECT status FROM accounts AS inv
    WHERE inv.type = shp.type
);


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

SELECT code FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.status = catg.status
);


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

SELECT name FROM shipments AS budg
WHERE level IN (
    SELECT level FROM orders AS inv
    WHERE inv.code = budg.code
);


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

SELECT code FROM warehouses AS schd
WHERE level IN (
    SELECT level FROM branches AS ord
    WHERE ord.level = schd.level
);


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

SELECT id FROM suppliers AS emp
WHERE level IN (
    SELECT level FROM branches AS prod
    WHERE prod.type = emp.type
);


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

SELECT code FROM branches AS emp
WHERE salary > (
    SELECT MAX(amount) FROM employees AS shp
    WHERE shp.status = emp.status
);


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

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


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

SELECT name FROM branches AS sale
WHERE value > (
    SELECT MIN(amount) FROM orders AS lne
    WHERE lne.status = sale.status
);


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.status = whs.status
);


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

SELECT id FROM accounts AS schd
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS emp
    WHERE emp.type = schd.type
);


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

SELECT code FROM shipments AS whs
WHERE value > (
    SELECT MAX(salary) FROM departments AS shp
    WHERE shp.id = whs.id
);


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

SELECT name FROM suppliers AS txn
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS catg
    WHERE catg.id = txn.id
);


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

SELECT name FROM suppliers AS empl
WHERE level IN (
    SELECT level FROM products AS acct
    WHERE acct.code = empl.code
);


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

SELECT amount FROM invoices AS inv
WHERE level IN (
    SELECT level FROM orders AS whs
    WHERE whs.id = inv.id
);


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

SELECT value FROM warehouses AS prod
WHERE status IN (
    SELECT status FROM regions AS acct
    WHERE acct.status = prod.status
);


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

SELECT id FROM shipments AS ordr
WHERE code IN (
    SELECT code FROM suppliers AS sale
    WHERE sale.status = ordr.status
);


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

SELECT salary FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.id = catg.id
);


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

SELECT code FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT value FROM projects AS cust
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.status = cust.status
);


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

SELECT salary FROM departments AS schd
WHERE status IN (
    SELECT status FROM tasks AS inv
    WHERE inv.status = schd.status
);


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

SELECT id FROM invoices AS dept
WHERE type IN (
    SELECT type FROM employees AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT value FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.code = emp.code
);


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

SELECT value FROM projects AS inv
WHERE amount > (
    SELECT MIN(salary) FROM regions AS srvc
    WHERE srvc.level = inv.level
);


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

SELECT id FROM tasks AS srvc
WHERE value > (
    SELECT MAX(salary) FROM warehouses AS acct
    WHERE acct.code = srvc.code
);


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

SELECT code FROM suppliers AS budg
WHERE salary > (
    SELECT MAX(amount) FROM products AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT name FROM suppliers AS catg
WHERE value > (
    SELECT MAX(salary) FROM products AS txn
    WHERE txn.type = catg.type
);


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

SELECT name FROM warehouses AS mgr
WHERE code IN (
    SELECT code FROM accounts AS ord
    WHERE ord.level = mgr.level
);


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

SELECT id FROM employees AS rgn
WHERE value > (
    SELECT AVG(salary) FROM invoices AS inv
    WHERE inv.id = rgn.id
);


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

SELECT id FROM warehouses AS rgn
WHERE amount > (
    SELECT SUM(value) FROM orders AS sale
    WHERE sale.type = rgn.type
);


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

SELECT amount FROM accounts AS prod
WHERE id IN (
    SELECT id FROM departments AS acct
    WHERE acct.level = prod.level
);


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

SELECT id FROM orders AS shp
WHERE code IN (
    SELECT code FROM categories AS sale
    WHERE sale.type = shp.type
);


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

SELECT salary FROM customers AS rgn
WHERE value > (
    SELECT MIN(value) FROM accounts AS prod
    WHERE prod.id = rgn.id
);


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

SELECT amount FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.code = inv.code
);


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

SELECT value FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT id FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.id = whs.id
);


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

SELECT code FROM warehouses AS mgr
WHERE value > (
    SELECT SUM(value) FROM employees AS prod
    WHERE prod.type = mgr.type
);


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

SELECT value FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS emp
    WHERE emp.level = ord.level
);


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

SELECT name FROM projects AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS catg
    WHERE catg.status = ordr.status
);


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

SELECT salary FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.type = emp.type
);


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

SELECT salary FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT code FROM invoices AS schd
WHERE value > (
    SELECT SUM(value) FROM employees AS cust
    WHERE cust.status = schd.status
);


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

SELECT name FROM transactions AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS prod
    WHERE prod.level = whs.level
);


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

SELECT id FROM accounts AS prod
WHERE id IN (
    SELECT id FROM projects AS acct
    WHERE acct.id = prod.id
);


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

SELECT value FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.type = lne.type
);


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

SELECT value FROM suppliers AS schd
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS cust
    WHERE cust.status = schd.status
);


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

SELECT code FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.type = lne.type
);


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

SELECT code FROM departments AS budg
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS ord
    WHERE ord.code = budg.code
);


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

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


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

SELECT salary FROM shipments AS budg
WHERE salary > (
    SELECT AVG(value) FROM invoices AS dept
    WHERE dept.level = budg.level
);


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

SELECT value FROM accounts AS emp
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.level = emp.level
);


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

SELECT value FROM categories AS shp
WHERE id IN (
    SELECT id FROM tasks AS sale
    WHERE sale.code = shp.code
);


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

SELECT code FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.type = cust.type
);


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

SELECT name FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.status = rgn.status
);


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

SELECT id FROM customers AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM tasks AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT name FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.status = acct.status
);


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

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


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

SELECT name FROM categories AS sale
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS whs
    WHERE whs.type = sale.type
);


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

SELECT name FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.level = txn.level
);


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

SELECT value FROM warehouses AS ordr
WHERE level IN (
    SELECT level FROM departments AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT code FROM accounts AS budg
WHERE salary > (
    SELECT MAX(salary) FROM regions AS whs
    WHERE whs.level = budg.level
);


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

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


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

SELECT amount FROM tasks AS txn
WHERE value > (
    SELECT SUM(salary) FROM invoices AS ord
    WHERE ord.status = txn.status
);


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

SELECT value FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.code = srvc.code
);


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

SELECT code FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.status = schd.status
);


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

SELECT value FROM warehouses AS inv
WHERE value > (
    SELECT COUNT(amount) FROM orders AS sale
    WHERE sale.type = inv.type
);


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

SELECT code FROM invoices AS acct
WHERE type IN (
    SELECT type FROM suppliers AS mgr
    WHERE mgr.type = acct.type
);


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

SELECT amount FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT name FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.id = lne.id
);


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

SELECT salary FROM orders AS schd
WHERE status IN (
    SELECT status FROM categories AS inv
    WHERE inv.type = schd.type
);


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

SELECT name FROM invoices AS schd
WHERE status IN (
    SELECT status FROM projects AS catg
    WHERE catg.code = schd.code
);


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

SELECT code FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.type = inv.type
);


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

SELECT value FROM orders AS ord
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS empl
    WHERE empl.type = ord.type
);


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

SELECT code FROM orders AS ordr
WHERE level IN (
    SELECT level FROM customers AS shp
    WHERE shp.code = ordr.code
);


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

SELECT id FROM accounts AS mgr
WHERE salary > (
    SELECT SUM(value) FROM shipments AS txn
    WHERE txn.type = mgr.type
);


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

SELECT value FROM tasks AS acct
WHERE type IN (
    SELECT type FROM invoices AS catg
    WHERE catg.type = acct.type
);


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

SELECT code FROM accounts AS shp
WHERE salary > (
    SELECT AVG(salary) FROM departments AS dept
    WHERE dept.level = shp.level
);


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

SELECT code FROM shipments AS shp
WHERE type IN (
    SELECT type FROM invoices AS schd
    WHERE schd.type = shp.type
);


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

SELECT amount FROM suppliers AS catg
WHERE amount > (
    SELECT SUM(value) FROM projects AS emp
    WHERE emp.code = catg.code
);


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

SELECT id FROM warehouses AS prod
WHERE type IN (
    SELECT type FROM employees AS srvc
    WHERE srvc.status = prod.status
);


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

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


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

SELECT code FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.code = cust.code
);


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

SELECT amount FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.type = ord.type
);


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

SELECT code FROM employees AS mgr
WHERE amount > (
    SELECT MIN(value) FROM projects AS lne
    WHERE lne.id = mgr.id
);


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

SELECT amount FROM orders AS cust
WHERE code IN (
    SELECT code FROM employees AS budg
    WHERE budg.type = cust.type
);


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

SELECT amount FROM employees AS srvc
WHERE id IN (
    SELECT id FROM departments AS dept
    WHERE dept.level = srvc.level
);


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

SELECT amount FROM accounts AS shp
WHERE type IN (
    SELECT type FROM employees AS dept
    WHERE dept.code = shp.code
);


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

SELECT amount FROM categories AS whs
WHERE amount > (
    SELECT AVG(salary) FROM suppliers AS sale
    WHERE sale.id = whs.id
);


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

SELECT salary FROM branches AS cust
WHERE amount > (
    SELECT AVG(value) FROM departments AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT value FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.type = ordr.type
);


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

SELECT value FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.level = inv.level
);


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

SELECT amount FROM regions AS cust
WHERE salary > (
    SELECT AVG(value) FROM shipments AS shp
    WHERE shp.id = cust.id
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.id = dept.id
);


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

SELECT code FROM products AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS schd
    WHERE schd.type = ord.type
);


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

SELECT amount FROM departments AS inv
WHERE status IN (
    SELECT status FROM employees AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT salary FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.status = empl.status
);


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

SELECT salary FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.code = txn.code
);


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

SELECT id FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.type = txn.type
);


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

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


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

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


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

SELECT value FROM orders AS prod
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.level = prod.level
);


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

SELECT salary FROM accounts AS lne
WHERE salary > (
    SELECT MIN(salary) FROM regions AS dept
    WHERE dept.id = lne.id
);


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

SELECT code FROM customers AS rgn
WHERE type IN (
    SELECT type FROM invoices AS catg
    WHERE catg.type = rgn.type
);


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

SELECT id FROM orders AS cust
WHERE salary > (
    SELECT SUM(salary) FROM products AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT name FROM accounts AS whs
WHERE id IN (
    SELECT id FROM categories AS budg
    WHERE budg.code = whs.code
);


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

SELECT id FROM employees AS whs
WHERE salary > (
    SELECT SUM(salary) FROM shipments AS schd
    WHERE schd.status = whs.status
);


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

SELECT amount FROM tasks AS budg
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT value FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.id = shp.id
);


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

SELECT value FROM branches AS budg
WHERE code IN (
    SELECT code FROM customers AS inv
    WHERE inv.level = budg.level
);


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

SELECT id FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.id = rgn.id
);


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

SELECT id FROM regions AS rgn
WHERE amount > (
    SELECT SUM(value) FROM branches AS empl
    WHERE empl.status = rgn.status
);


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

SELECT name FROM orders AS lne
WHERE code IN (
    SELECT code FROM regions AS acct
    WHERE acct.status = lne.status
);


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

SELECT value FROM projects AS rgn
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS acct
    WHERE acct.level = rgn.level
);


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

SELECT amount FROM transactions AS lne
WHERE level IN (
    SELECT level FROM invoices AS ord
    WHERE ord.status = lne.status
);


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

SELECT amount FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.type = sale.type
);


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

SELECT salary FROM invoices AS budg
WHERE value > (
    SELECT AVG(salary) FROM departments AS catg
    WHERE catg.id = budg.id
);


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

SELECT code FROM orders AS catg
WHERE type IN (
    SELECT type FROM warehouses AS whs
    WHERE whs.type = catg.type
);


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

SELECT value FROM warehouses AS dept
WHERE code IN (
    SELECT code FROM regions AS catg
    WHERE catg.code = dept.code
);


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

SELECT salary FROM categories AS txn
WHERE salary > (
    SELECT MIN(value) FROM projects AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT amount FROM employees AS acct
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS mgr
    WHERE mgr.status = acct.status
);


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

SELECT code FROM shipments AS whs
WHERE value > (
    SELECT COUNT(salary) FROM customers AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT value FROM regions AS shp
WHERE id IN (
    SELECT id FROM invoices AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT value FROM categories AS txn
WHERE id IN (
    SELECT id FROM warehouses AS rgn
    WHERE rgn.type = txn.type
);