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

SELECT id FROM suppliers AS emp
WHERE value > (
    SELECT MIN(value) FROM orders AS lne
    WHERE lne.type = emp.type
);


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

SELECT value FROM projects AS schd
WHERE value > (
    SELECT SUM(salary) FROM tasks AS cust
    WHERE cust.code = schd.code
);


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

SELECT name FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.id = emp.id
);


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

SELECT value FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.status = ordr.status
);


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

SELECT id FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.level = srvc.level
);


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

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


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

SELECT id FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.id = prod.id
);


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

SELECT salary FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT amount FROM warehouses AS schd
WHERE value > (
    SELECT AVG(amount) FROM products AS catg
    WHERE catg.status = schd.status
);


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

SELECT code FROM categories AS catg
WHERE value > (
    SELECT MAX(amount) FROM projects AS empl
    WHERE empl.id = catg.id
);


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

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


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

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


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

SELECT amount FROM tasks AS whs
WHERE salary > (
    SELECT AVG(salary) FROM branches AS srvc
    WHERE srvc.id = whs.id
);


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

SELECT name FROM employees AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS emp
    WHERE emp.status = schd.status
);


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

SELECT value FROM tasks AS sale
WHERE level IN (
    SELECT level FROM suppliers AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT salary FROM employees AS emp
WHERE code IN (
    SELECT code FROM regions AS lne
    WHERE lne.level = emp.level
);


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

SELECT id FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.code = emp.code
);


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

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


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

SELECT amount FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT code FROM tasks AS acct
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.code = acct.code
);


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

SELECT value FROM shipments AS ord
WHERE amount > (
    SELECT MIN(amount) FROM customers AS whs
    WHERE whs.id = ord.id
);


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

SELECT code FROM orders AS txn
WHERE value > (
    SELECT COUNT(salary) FROM invoices AS budg
    WHERE budg.level = txn.level
);


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

SELECT id FROM accounts AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM branches AS lne
    WHERE lne.id = srvc.id
);


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

SELECT code FROM employees AS emp
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS txn
    WHERE txn.type = emp.type
);


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

SELECT code FROM departments AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM branches AS mgr
    WHERE mgr.code = rgn.code
);


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

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


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

SELECT id FROM warehouses AS schd
WHERE amount > (
    SELECT SUM(value) FROM departments AS emp
    WHERE emp.level = schd.level
);


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

SELECT salary FROM accounts AS whs
WHERE id IN (
    SELECT id FROM categories AS prod
    WHERE prod.level = whs.level
);


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

SELECT name FROM invoices AS ord
WHERE value > (
    SELECT COUNT(salary) FROM products AS emp
    WHERE emp.level = ord.level
);


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

SELECT value FROM tasks AS whs
WHERE code IN (
    SELECT code FROM departments AS schd
    WHERE schd.type = whs.type
);


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

SELECT code FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.level = sale.level
);


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

SELECT value FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.id = budg.id
);


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

SELECT id FROM products AS ordr
WHERE value > (
    SELECT AVG(value) FROM shipments AS srvc
    WHERE srvc.status = ordr.status
);


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

SELECT code FROM warehouses AS shp
WHERE salary > (
    SELECT MIN(value) FROM regions AS cust
    WHERE cust.type = shp.type
);


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

SELECT amount FROM categories AS ordr
WHERE status IN (
    SELECT status FROM regions AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT salary FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.id = prod.id
);


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

SELECT amount FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.code = shp.code
);


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

SELECT id FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.status = dept.status
);


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

SELECT amount FROM products AS txn
WHERE id IN (
    SELECT id FROM employees AS dept
    WHERE dept.type = txn.type
);


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

SELECT code FROM suppliers AS lne
WHERE salary > (
    SELECT COUNT(value) FROM warehouses AS cust
    WHERE cust.level = lne.level
);


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

SELECT code FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = lne.level
);


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

SELECT amount FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.status = txn.status
);


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

SELECT code FROM branches AS prod
WHERE id IN (
    SELECT id FROM accounts AS txn
    WHERE txn.status = prod.status
);


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

SELECT amount FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.id = catg.id
);


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

SELECT salary FROM warehouses AS sale
WHERE value > (
    SELECT MAX(amount) FROM categories AS shp
    WHERE shp.type = sale.type
);


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

SELECT name FROM employees AS shp
WHERE status IN (
    SELECT status FROM departments AS acct
    WHERE acct.status = shp.status
);


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

SELECT code FROM branches AS mgr
WHERE status IN (
    SELECT status FROM employees AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT value FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.type = srvc.type
);


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

SELECT code FROM products AS emp
WHERE amount > (
    SELECT MAX(salary) FROM branches AS inv
    WHERE inv.type = emp.type
);


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

SELECT name FROM orders AS lne
WHERE status IN (
    SELECT status FROM projects AS empl
    WHERE empl.status = lne.status
);


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

SELECT salary FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.level = srvc.level
);


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

SELECT code FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT salary FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.type = txn.type
);


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

SELECT id FROM branches AS empl
WHERE type IN (
    SELECT type FROM transactions AS catg
    WHERE catg.type = empl.type
);


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

SELECT amount FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.level = cust.level
);


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

SELECT name FROM departments AS cust
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.level = cust.level
);


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

SELECT code FROM transactions AS dept
WHERE code IN (
    SELECT code FROM customers AS catg
    WHERE catg.id = dept.id
);


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

SELECT name FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.code = prod.code
);


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

SELECT code FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.status = empl.status
);


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

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


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

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


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

SELECT id FROM orders AS whs
WHERE code IN (
    SELECT code FROM employees AS inv
    WHERE inv.status = whs.status
);


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

SELECT amount FROM projects AS shp
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS ord
    WHERE ord.code = shp.code
);


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

SELECT amount FROM accounts AS emp
WHERE amount > (
    SELECT MAX(salary) FROM products AS prod
    WHERE prod.level = emp.level
);


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

SELECT salary FROM accounts AS budg
WHERE status IN (
    SELECT status FROM warehouses AS empl
    WHERE empl.id = budg.id
);


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

SELECT salary FROM customers AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM transactions AS ord
    WHERE ord.code = ordr.code
);


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

SELECT amount FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.code = ordr.code
);


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

SELECT name FROM tasks AS shp
WHERE salary > (
    SELECT MIN(amount) FROM projects AS acct
    WHERE acct.code = shp.code
);


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

SELECT id FROM products AS ord
WHERE value > (
    SELECT AVG(amount) FROM accounts AS sale
    WHERE sale.id = ord.id
);


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

SELECT name FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.code = mgr.code
);


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

SELECT id FROM orders AS prod
WHERE amount > (
    SELECT SUM(amount) FROM suppliers AS acct
    WHERE acct.level = prod.level
);


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

SELECT code FROM orders AS lne
WHERE level IN (
    SELECT level FROM regions AS dept
    WHERE dept.level = lne.level
);


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

SELECT id FROM transactions AS prod
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS catg
    WHERE catg.id = prod.id
);


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

SELECT id FROM accounts AS ord
WHERE value > (
    SELECT MIN(amount) FROM orders AS dept
    WHERE dept.type = ord.type
);


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

SELECT code FROM tasks AS lne
WHERE amount > (
    SELECT MIN(salary) FROM departments AS sale
    WHERE sale.code = lne.code
);


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

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


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

SELECT id FROM orders AS srvc
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS whs
    WHERE whs.type = srvc.type
);


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

SELECT id FROM products AS shp
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT id FROM invoices AS srvc
WHERE amount > (
    SELECT MIN(amount) FROM customers AS mgr
    WHERE mgr.level = srvc.level
);


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

SELECT code FROM projects AS dept
WHERE amount > (
    SELECT MAX(amount) FROM employees AS txn
    WHERE txn.id = dept.id
);


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

SELECT value FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.level = inv.level
);


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.type = whs.type
);


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

SELECT salary FROM customers AS inv
WHERE type IN (
    SELECT type FROM employees AS cust
    WHERE cust.type = inv.type
);


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

SELECT salary FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.code = shp.code
);


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

SELECT name FROM transactions AS emp
WHERE amount > (
    SELECT AVG(value) FROM departments AS rgn
    WHERE rgn.id = emp.id
);


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

SELECT id FROM departments AS schd
WHERE id IN (
    SELECT id FROM employees AS whs
    WHERE whs.id = schd.id
);


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

SELECT value FROM employees AS lne
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.status = lne.status
);


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

SELECT amount FROM warehouses AS cust
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.code = cust.code
);


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

SELECT amount FROM invoices AS txn
WHERE type IN (
    SELECT type FROM regions AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT id FROM accounts AS txn
WHERE value > (
    SELECT SUM(value) FROM departments AS acct
    WHERE acct.type = txn.type
);


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

SELECT salary FROM categories AS mgr
WHERE id IN (
    SELECT id FROM customers AS lne
    WHERE lne.id = mgr.id
);


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

SELECT amount FROM branches AS catg
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.code = catg.code
);


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

SELECT name FROM categories AS sale
WHERE code IN (
    SELECT code FROM departments AS inv
    WHERE inv.type = sale.type
);


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

SELECT id FROM employees AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS dept
    WHERE dept.type = inv.type
);


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

SELECT salary FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.level = mgr.level
);


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

SELECT amount FROM tasks AS catg
WHERE id IN (
    SELECT id FROM categories AS txn
    WHERE txn.type = catg.type
);


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

SELECT amount FROM orders AS srvc
WHERE id IN (
    SELECT id FROM projects AS prod
    WHERE prod.id = srvc.id
);


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

SELECT id FROM shipments AS ordr
WHERE salary > (
    SELECT SUM(value) FROM branches AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT id FROM departments AS cust
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT name FROM categories AS srvc
WHERE value > (
    SELECT SUM(value) FROM accounts AS lne
    WHERE lne.status = srvc.status
);


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

SELECT id FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.status = empl.status
);


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

SELECT id FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.code = schd.code
);


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

SELECT salary FROM invoices AS rgn
WHERE value > (
    SELECT SUM(salary) FROM projects AS budg
    WHERE budg.code = rgn.code
);


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

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


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

SELECT code FROM branches AS shp
WHERE type IN (
    SELECT type FROM transactions AS inv
    WHERE inv.level = shp.level
);


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

SELECT amount FROM projects AS empl
WHERE value > (
    SELECT COUNT(amount) FROM accounts AS catg
    WHERE catg.id = empl.id
);


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

SELECT id FROM orders AS whs
WHERE status IN (
    SELECT status FROM employees AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT salary FROM projects AS empl
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT value FROM invoices AS budg
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT name FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.level = prod.level
);


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

SELECT salary FROM warehouses AS ord
WHERE value > (
    SELECT AVG(value) FROM products AS prod
    WHERE prod.level = ord.level
);


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

SELECT name FROM warehouses AS prod
WHERE amount > (
    SELECT COUNT(value) FROM projects AS whs
    WHERE whs.type = prod.type
);


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

SELECT salary FROM employees AS acct
WHERE type IN (
    SELECT type FROM shipments AS prod
    WHERE prod.id = acct.id
);


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

SELECT code FROM warehouses AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM employees AS cust
    WHERE cust.level = empl.level
);


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

SELECT name FROM suppliers AS prod
WHERE amount > (
    SELECT MAX(amount) FROM products AS cust
    WHERE cust.id = prod.id
);


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

SELECT id FROM accounts AS schd
WHERE level IN (
    SELECT level FROM orders AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT amount FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.id = catg.id
);


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

SELECT id FROM warehouses AS empl
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS schd
    WHERE schd.code = empl.code
);


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

SELECT code FROM categories AS catg
WHERE level IN (
    SELECT level FROM products AS acct
    WHERE acct.status = catg.status
);


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

SELECT name FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.id = acct.id
);


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

SELECT amount FROM customers AS cust
WHERE value > (
    SELECT MIN(amount) FROM shipments AS whs
    WHERE whs.status = cust.status
);


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

SELECT value FROM categories AS whs
WHERE level IN (
    SELECT level FROM warehouses AS empl
    WHERE empl.status = whs.status
);


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

SELECT name FROM regions AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS prod
    WHERE prod.status = srvc.status
);


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

SELECT value FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.level = cust.level
);


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

SELECT salary FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.type = srvc.type
);


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

SELECT name FROM warehouses AS budg
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS txn
    WHERE txn.type = budg.type
);


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

SELECT salary FROM projects AS schd
WHERE code IN (
    SELECT code FROM shipments AS budg
    WHERE budg.code = schd.code
);


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

SELECT code FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT code FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.level = cust.level
);


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

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


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

SELECT code FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.code = mgr.code
);


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

SELECT amount FROM projects AS sale
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.type = sale.type
);


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

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


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

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


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

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


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

SELECT id FROM customers AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS inv
    WHERE inv.status = schd.status
);


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

SELECT value FROM tasks AS dept
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS cust
    WHERE cust.code = dept.code
);


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

SELECT value FROM products AS acct
WHERE type IN (
    SELECT type FROM suppliers AS schd
    WHERE schd.type = acct.type
);


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

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


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

SELECT salary FROM orders AS budg
WHERE code IN (
    SELECT code FROM departments AS shp
    WHERE shp.status = budg.status
);


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

SELECT value FROM employees AS shp
WHERE id IN (
    SELECT id FROM branches AS whs
    WHERE whs.type = shp.type
);


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

SELECT value FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.status = emp.status
);


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

SELECT code FROM regions AS inv
WHERE level IN (
    SELECT level FROM departments AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT amount FROM tasks AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT amount FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.type = acct.type
);


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

SELECT id FROM departments AS ord
WHERE amount > (
    SELECT MIN(amount) FROM projects AS acct
    WHERE acct.status = ord.status
);


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

SELECT id FROM projects AS prod
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS schd
    WHERE schd.level = prod.level
);


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

SELECT name FROM categories AS mgr
WHERE code IN (
    SELECT code FROM accounts AS prod
    WHERE prod.code = mgr.code
);


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

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


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

SELECT code FROM accounts AS emp
WHERE amount > (
    SELECT COUNT(amount) FROM departments AS sale
    WHERE sale.type = emp.type
);


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

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


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

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


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

SELECT name FROM projects AS inv
WHERE code IN (
    SELECT code FROM suppliers AS catg
    WHERE catg.id = inv.id
);


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

SELECT id FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.level = sale.level
);


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

SELECT amount FROM orders AS prod
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS acct
    WHERE acct.type = prod.type
);


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

SELECT value FROM suppliers AS emp
WHERE id IN (
    SELECT id FROM employees AS sale
    WHERE sale.id = emp.id
);


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

SELECT code FROM tasks AS schd
WHERE salary > (
    SELECT AVG(value) FROM customers AS emp
    WHERE emp.level = schd.level
);


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

SELECT value FROM shipments AS prod
WHERE type IN (
    SELECT type FROM accounts AS inv
    WHERE inv.status = prod.status
);


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

SELECT code FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.code = sale.code
);


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

SELECT code FROM regions AS sale
WHERE amount > (
    SELECT MIN(value) FROM orders AS inv
    WHERE inv.level = sale.level
);


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

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


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

SELECT code FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.type = prod.type
);


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

SELECT code FROM regions AS ord
WHERE value > (
    SELECT MIN(salary) FROM tasks AS lne
    WHERE lne.id = ord.id
);


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

SELECT name FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT amount FROM tasks AS ord
WHERE salary > (
    SELECT MAX(amount) FROM projects AS empl
    WHERE empl.type = ord.type
);


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

SELECT id FROM invoices AS ord
WHERE id IN (
    SELECT id FROM projects AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT id FROM suppliers AS rgn
WHERE salary > (
    SELECT MAX(amount) FROM employees AS empl
    WHERE empl.level = rgn.level
);


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

SELECT name FROM accounts AS sale
WHERE amount > (
    SELECT AVG(amount) FROM orders AS cust
    WHERE cust.code = sale.code
);


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

SELECT value FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.status = budg.status
);


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

SELECT name FROM products AS whs
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS empl
    WHERE empl.status = whs.status
);


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

SELECT id FROM departments AS srvc
WHERE value > (
    SELECT AVG(salary) FROM tasks AS schd
    WHERE schd.status = srvc.status
);


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

SELECT id FROM categories AS rgn
WHERE id IN (
    SELECT id FROM transactions AS schd
    WHERE schd.code = rgn.code
);


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

SELECT salary FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.type = ordr.type
);


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

SELECT salary FROM transactions AS empl
WHERE salary > (
    SELECT MAX(salary) FROM regions AS budg
    WHERE budg.type = empl.type
);


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

SELECT amount FROM suppliers AS ord
WHERE level IN (
    SELECT level FROM orders AS acct
    WHERE acct.id = ord.id
);


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

SELECT amount FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = schd.code
);


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

SELECT salary FROM categories AS catg
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS schd
    WHERE schd.id = catg.id
);


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

SELECT id FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.type = mgr.type
);


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

SELECT salary FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.type = whs.type
);


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

SELECT code FROM employees AS prod
WHERE status IN (
    SELECT status FROM suppliers AS txn
    WHERE txn.id = prod.id
);


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

SELECT salary FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.type = dept.type
);


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

SELECT id FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.code = catg.code
);


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

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


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

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


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

SELECT value FROM departments AS shp
WHERE type IN (
    SELECT type FROM orders AS dept
    WHERE dept.status = shp.status
);


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

SELECT value FROM branches AS rgn
WHERE id IN (
    SELECT id FROM tasks AS prod
    WHERE prod.status = rgn.status
);


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

SELECT code FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.level = mgr.level
);


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

SELECT value FROM regions AS inv
WHERE code IN (
    SELECT code FROM categories AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT value FROM departments AS txn
WHERE amount > (
    SELECT MIN(amount) FROM orders AS catg
    WHERE catg.status = txn.status
);


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

SELECT salary FROM categories AS budg
WHERE salary > (
    SELECT MAX(amount) FROM accounts AS dept
    WHERE dept.id = budg.id
);


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

SELECT name FROM accounts AS empl
WHERE type IN (
    SELECT type FROM shipments AS acct
    WHERE acct.level = empl.level
);


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

SELECT salary FROM shipments AS dept
WHERE id IN (
    SELECT id FROM accounts AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT id FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.status = ord.status
);


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

SELECT name FROM departments AS rgn
WHERE type IN (
    SELECT type FROM employees AS lne
    WHERE lne.code = rgn.code
);


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

SELECT salary FROM departments AS mgr
WHERE type IN (
    SELECT type FROM orders AS shp
    WHERE shp.id = mgr.id
);


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

SELECT code FROM warehouses AS schd
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS acct
    WHERE acct.code = schd.code
);


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

SELECT value FROM orders AS acct
WHERE code IN (
    SELECT code FROM regions AS emp
    WHERE emp.id = acct.id
);


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

SELECT value FROM departments AS srvc
WHERE salary > (
    SELECT MAX(salary) FROM warehouses AS empl
    WHERE empl.id = srvc.id
);


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

SELECT value FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.code = cust.code
);


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

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


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

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


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

SELECT code FROM warehouses AS dept
WHERE status IN (
    SELECT status FROM suppliers AS schd
    WHERE schd.status = dept.status
);


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

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


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

SELECT name FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.type = budg.type
);


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

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


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

SELECT salary FROM categories AS empl
WHERE level IN (
    SELECT level FROM projects AS whs
    WHERE whs.code = empl.code
);


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

SELECT salary FROM regions AS acct
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.status = acct.status
);


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

SELECT code FROM branches AS sale
WHERE amount > (
    SELECT AVG(value) FROM products AS schd
    WHERE schd.status = sale.status
);


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

SELECT id FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.code = budg.code
);


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

SELECT code FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.level = mgr.level
);


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

SELECT code FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.level = sale.level
);


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

SELECT amount FROM regions AS mgr
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS ord
    WHERE ord.type = mgr.type
);


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

SELECT salary FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.id = budg.id
);


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

SELECT amount FROM invoices AS txn
WHERE level IN (
    SELECT level FROM branches AS lne
    WHERE lne.status = txn.status
);


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

SELECT id FROM regions AS empl
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS acct
    WHERE acct.status = empl.status
);


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

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


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

SELECT amount FROM departments AS srvc
WHERE id IN (
    SELECT id FROM tasks AS rgn
    WHERE rgn.level = srvc.level
);


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

SELECT id FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.level = catg.level
);


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

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


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

SELECT salary FROM suppliers AS inv
WHERE value > (
    SELECT AVG(amount) FROM categories AS ord
    WHERE ord.type = inv.type
);


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

SELECT code FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.code = txn.code
);


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

SELECT amount FROM shipments AS catg
WHERE code IN (
    SELECT code FROM invoices AS ord
    WHERE ord.type = catg.type
);


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

SELECT name FROM departments AS acct
WHERE id IN (
    SELECT id FROM invoices AS budg
    WHERE budg.id = acct.id
);


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

SELECT name FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.level = inv.level
);


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

SELECT amount FROM products AS budg
WHERE amount > (
    SELECT AVG(amount) FROM categories AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT amount FROM suppliers AS cust
WHERE status IN (
    SELECT status FROM regions AS ord
    WHERE ord.code = cust.code
);


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

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


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

SELECT id FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = whs.status
);


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

SELECT id FROM products AS shp
WHERE status IN (
    SELECT status FROM warehouses AS budg
    WHERE budg.id = shp.id
);


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

SELECT amount FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.type = whs.type
);


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

SELECT value FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.type = schd.type
);


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

SELECT code FROM warehouses AS whs
WHERE amount > (
    SELECT MAX(value) FROM regions AS ord
    WHERE ord.id = whs.id
);


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

SELECT amount FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.code = budg.code
);


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

SELECT name FROM regions AS catg
WHERE level IN (
    SELECT level FROM products AS shp
    WHERE shp.type = catg.type
);


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

SELECT code FROM projects AS catg
WHERE amount > (
    SELECT MAX(amount) FROM branches AS ordr
    WHERE ordr.id = catg.id
);


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

SELECT id FROM projects AS ordr
WHERE value > (
    SELECT AVG(amount) FROM accounts AS inv
    WHERE inv.type = ordr.type
);


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

SELECT value FROM transactions AS dept
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.level = dept.level
);


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

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


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

SELECT value FROM regions AS dept
WHERE status IN (
    SELECT status FROM tasks AS ord
    WHERE ord.id = dept.id
);


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

SELECT value FROM orders AS acct
WHERE salary > (
    SELECT MIN(value) FROM employees AS inv
    WHERE inv.type = acct.type
);


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

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


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

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


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

SELECT code FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.id = cust.id
);


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

SELECT code FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT amount FROM accounts AS schd
WHERE type IN (
    SELECT type FROM warehouses AS budg
    WHERE budg.status = schd.status
);


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

SELECT amount FROM projects AS whs
WHERE level IN (
    SELECT level FROM products AS sale
    WHERE sale.status = whs.status
);


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

SELECT amount FROM orders AS cust
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT value FROM products AS dept
WHERE value > (
    SELECT MAX(amount) FROM orders AS schd
    WHERE schd.type = dept.type
);


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

SELECT amount FROM customers AS prod
WHERE salary > (
    SELECT MIN(value) FROM employees AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT salary FROM tasks AS cust
WHERE value > (
    SELECT SUM(salary) FROM accounts AS ord
    WHERE ord.type = cust.type
);


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

SELECT id FROM orders AS mgr
WHERE type IN (
    SELECT type FROM departments AS cust
    WHERE cust.status = mgr.status
);


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

SELECT name FROM invoices AS schd
WHERE code IN (
    SELECT code FROM transactions AS srvc
    WHERE srvc.type = schd.type
);


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

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


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

SELECT value FROM customers AS schd
WHERE level IN (
    SELECT level FROM accounts AS lne
    WHERE lne.type = schd.type
);


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

SELECT salary FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT value FROM transactions AS catg
WHERE value > (
    SELECT MIN(amount) FROM customers AS sale
    WHERE sale.level = catg.level
);


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

SELECT value FROM orders AS ord
WHERE id IN (
    SELECT id FROM branches AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT value FROM projects AS acct
WHERE status IN (
    SELECT status FROM categories AS empl
    WHERE empl.type = acct.type
);


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

SELECT amount FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.id = whs.id
);


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

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


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

SELECT code FROM employees AS cust
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.level = cust.level
);


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

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


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

SELECT id FROM regions AS txn
WHERE salary > (
    SELECT COUNT(value) FROM transactions AS lne
    WHERE lne.status = txn.status
);


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

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


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

SELECT value FROM accounts AS empl
WHERE code IN (
    SELECT code FROM departments AS catg
    WHERE catg.level = empl.level
);


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

SELECT amount FROM departments AS empl
WHERE value > (
    SELECT SUM(amount) FROM shipments AS lne
    WHERE lne.type = empl.type
);


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

SELECT id FROM products AS lne
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS cust
    WHERE cust.id = lne.id
);


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

SELECT name FROM transactions AS inv
WHERE code IN (
    SELECT code FROM projects AS shp
    WHERE shp.id = inv.id
);


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

SELECT code FROM accounts AS inv
WHERE amount > (
    SELECT AVG(value) FROM invoices AS catg
    WHERE catg.type = inv.type
);


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

SELECT id FROM warehouses AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT amount FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.level = prod.level
);


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

SELECT name FROM employees AS txn
WHERE salary > (
    SELECT AVG(amount) FROM projects AS catg
    WHERE catg.code = txn.code
);


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

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


Prompt:
Schema:
  suppliers (alias: shp)(type, level, salary, code)
  employees(code, salary, amount, level)
Task: Retrieve code from suppliers with amount above the COUNT(amount) of employees rows sharing the same type.
SQL:

SELECT code FROM suppliers AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS lne
    WHERE lne.type = shp.type
);


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

SELECT amount FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.level = whs.level
);


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

SELECT salary FROM suppliers AS dept
WHERE level IN (
    SELECT level FROM products AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT salary FROM accounts AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS schd
    WHERE schd.level = empl.level
);


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

SELECT id FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM customers AS lne
    WHERE lne.type = ordr.type
);


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

SELECT value FROM tasks AS budg
WHERE type IN (
    SELECT type FROM customers AS emp
    WHERE emp.level = budg.level
);


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

SELECT name FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.status = acct.status
);


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

SELECT salary FROM customers AS prod
WHERE value > (
    SELECT AVG(value) FROM branches AS catg
    WHERE catg.status = prod.status
);


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

SELECT id FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.level = ordr.level
);


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

SELECT amount FROM employees AS lne
WHERE value > (
    SELECT AVG(salary) FROM transactions AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT value FROM transactions AS budg
WHERE code IN (
    SELECT code FROM tasks AS shp
    WHERE shp.status = budg.status
);


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

SELECT code FROM employees AS ord
WHERE amount > (
    SELECT MAX(value) FROM invoices AS txn
    WHERE txn.type = ord.type
);


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

SELECT amount FROM transactions AS shp
WHERE level IN (
    SELECT level FROM projects AS whs
    WHERE whs.code = shp.code
);


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

SELECT name FROM accounts AS emp
WHERE status IN (
    SELECT status FROM departments AS mgr
    WHERE mgr.level = emp.level
);


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

SELECT name FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.status = whs.status
);


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

SELECT name FROM orders AS prod
WHERE id IN (
    SELECT id FROM regions AS budg
    WHERE budg.status = prod.status
);


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

SELECT salary FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.level = schd.level
);


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

SELECT name FROM shipments AS prod
WHERE salary > (
    SELECT COUNT(value) FROM employees AS ord
    WHERE ord.type = prod.type
);


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

SELECT code FROM suppliers AS lne
WHERE status IN (
    SELECT status FROM tasks AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT value FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.type = prod.type
);