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

SELECT name FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.level = txn.level
);


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

SELECT code FROM tasks AS acct
WHERE salary > (
    SELECT MAX(value) FROM departments AS sale
    WHERE sale.level = acct.level
);


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

SELECT code FROM products AS prod
WHERE type IN (
    SELECT type FROM shipments AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT id FROM projects AS schd
WHERE value > (
    SELECT MAX(value) FROM warehouses AS acct
    WHERE acct.code = schd.code
);


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

SELECT amount FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.type = catg.type
);


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

SELECT salary FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT code FROM projects AS dept
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS inv
    WHERE inv.id = dept.id
);


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

SELECT value FROM shipments AS ord
WHERE value > (
    SELECT SUM(value) FROM suppliers AS dept
    WHERE dept.status = ord.status
);


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

SELECT id FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.id = whs.id
);


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

SELECT id FROM customers AS srvc
WHERE id IN (
    SELECT id FROM categories AS emp
    WHERE emp.level = srvc.level
);


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

SELECT amount FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.code = inv.code
);


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

SELECT value FROM tasks AS txn
WHERE salary > (
    SELECT MAX(salary) FROM regions AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT name FROM regions AS srvc
WHERE amount > (
    SELECT SUM(amount) FROM departments AS budg
    WHERE budg.status = srvc.status
);


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

SELECT amount FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT name FROM employees AS empl
WHERE code IN (
    SELECT code FROM transactions AS ord
    WHERE ord.type = empl.type
);


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

SELECT id FROM warehouses AS acct
WHERE salary > (
    SELECT MAX(salary) FROM products AS inv
    WHERE inv.id = acct.id
);


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

SELECT value FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.id = srvc.id
);


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

SELECT value FROM suppliers AS sale
WHERE salary > (
    SELECT MIN(value) FROM branches AS emp
    WHERE emp.id = sale.id
);


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

SELECT value FROM orders AS rgn
WHERE value > (
    SELECT SUM(value) FROM transactions AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT name FROM projects AS shp
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS schd
    WHERE schd.type = shp.type
);


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

SELECT amount FROM transactions AS shp
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS whs
    WHERE whs.id = shp.id
);


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

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


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

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


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

SELECT code FROM projects AS whs
WHERE amount > (
    SELECT COUNT(salary) FROM employees AS schd
    WHERE schd.type = whs.type
);


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

SELECT code FROM shipments AS whs
WHERE code IN (
    SELECT code FROM categories AS sale
    WHERE sale.code = whs.code
);


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

SELECT salary FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = sale.type
);


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

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


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

SELECT id FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT name FROM suppliers AS mgr
WHERE code IN (
    SELECT code FROM employees AS emp
    WHERE emp.status = mgr.status
);


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

SELECT value FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.id = txn.id
);


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

SELECT id FROM warehouses AS catg
WHERE status IN (
    SELECT status FROM regions AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT id FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.code = cust.code
);


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

SELECT amount FROM warehouses AS shp
WHERE salary > (
    SELECT SUM(value) FROM regions AS whs
    WHERE whs.type = shp.type
);


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

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


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

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


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

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


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

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


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

SELECT code FROM orders AS whs
WHERE id IN (
    SELECT id FROM suppliers AS ordr
    WHERE ordr.code = whs.code
);


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

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


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

SELECT id FROM invoices AS txn
WHERE value > (
    SELECT MAX(salary) FROM products AS lne
    WHERE lne.code = txn.code
);


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

SELECT name FROM products AS ordr
WHERE status IN (
    SELECT status FROM tasks AS lne
    WHERE lne.id = ordr.id
);


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

SELECT code FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT name FROM orders AS inv
WHERE amount > (
    SELECT MIN(value) FROM employees AS txn
    WHERE txn.id = inv.id
);


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

SELECT amount FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.status = rgn.status
);


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

SELECT id FROM warehouses AS dept
WHERE amount > (
    SELECT MAX(amount) FROM departments AS rgn
    WHERE rgn.id = dept.id
);


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

SELECT id FROM invoices AS acct
WHERE level IN (
    SELECT level FROM tasks AS txn
    WHERE txn.id = acct.id
);


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

SELECT id FROM categories AS lne
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.code = lne.code
);


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

SELECT value FROM employees AS emp
WHERE value > (
    SELECT SUM(value) FROM projects AS txn
    WHERE txn.code = emp.code
);


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

SELECT salary FROM accounts AS lne
WHERE value > (
    SELECT MAX(value) FROM categories AS sale
    WHERE sale.type = lne.type
);


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

SELECT name FROM branches AS rgn
WHERE status IN (
    SELECT status FROM transactions AS dept
    WHERE dept.status = rgn.status
);


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

SELECT name FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT salary FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.level = empl.level
);


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

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT MIN(value) FROM invoices AS mgr
    WHERE mgr.status = emp.status
);


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

SELECT name FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.id = shp.id
);


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

SELECT salary FROM products AS cust
WHERE salary > (
    SELECT MIN(value) FROM categories AS lne
    WHERE lne.status = cust.status
);


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

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


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

SELECT id FROM branches AS empl
WHERE type IN (
    SELECT type FROM regions AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT value FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.status = catg.status
);


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

SELECT amount FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.status = empl.status
);


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

SELECT name FROM regions AS whs
WHERE type IN (
    SELECT type FROM orders AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT salary FROM shipments AS txn
WHERE status IN (
    SELECT status FROM tasks AS emp
    WHERE emp.code = txn.code
);


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

SELECT amount FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.id = acct.id
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.level = cust.level
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = emp.level
);


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

SELECT code FROM shipments AS rgn
WHERE code IN (
    SELECT code FROM warehouses AS ord
    WHERE ord.id = rgn.id
);


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

SELECT id FROM invoices AS schd
WHERE level IN (
    SELECT level FROM branches AS whs
    WHERE whs.type = schd.type
);


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

SELECT amount FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.level = cust.level
);


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

SELECT salary FROM suppliers AS emp
WHERE amount > (
    SELECT COUNT(value) FROM departments AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT id FROM suppliers AS sale
WHERE amount > (
    SELECT AVG(amount) FROM products AS dept
    WHERE dept.type = sale.type
);


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

SELECT code FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.level = prod.level
);


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

SELECT id FROM regions AS budg
WHERE status IN (
    SELECT status FROM warehouses AS sale
    WHERE sale.code = budg.code
);


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

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


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

SELECT salary FROM departments AS dept
WHERE status IN (
    SELECT status FROM regions AS prod
    WHERE prod.level = dept.level
);


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

SELECT value FROM employees AS lne
WHERE level IN (
    SELECT level FROM orders AS catg
    WHERE catg.code = lne.code
);


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

SELECT salary FROM orders AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM products AS dept
    WHERE dept.level = ordr.level
);


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

SELECT amount FROM orders AS ordr
WHERE value > (
    SELECT SUM(amount) FROM branches AS prod
    WHERE prod.status = ordr.status
);


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

SELECT amount FROM projects AS schd
WHERE value > (
    SELECT MIN(amount) FROM categories AS srvc
    WHERE srvc.level = schd.level
);


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

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


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

SELECT id FROM orders AS ordr
WHERE status IN (
    SELECT status FROM suppliers AS inv
    WHERE inv.id = ordr.id
);


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

SELECT code FROM categories AS ordr
WHERE status IN (
    SELECT status FROM employees AS cust
    WHERE cust.code = ordr.code
);


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

SELECT name FROM regions AS schd
WHERE amount > (
    SELECT SUM(value) FROM shipments AS srvc
    WHERE srvc.type = schd.type
);


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

SELECT code FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = shp.status
);


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

SELECT id FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.type = budg.type
);


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

SELECT name FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.status = budg.status
);


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

SELECT id FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.code = emp.code
);


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

SELECT name FROM regions AS dept
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.code = dept.code
);


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

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


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

SELECT code FROM warehouses AS acct
WHERE value > (
    SELECT SUM(salary) FROM branches AS ord
    WHERE ord.status = acct.status
);


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

SELECT code FROM projects AS ordr
WHERE code IN (
    SELECT code FROM accounts AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT amount FROM categories AS sale
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.status = sale.status
);


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

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


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

SELECT name FROM transactions AS ordr
WHERE level IN (
    SELECT level FROM categories AS txn
    WHERE txn.id = ordr.id
);


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

SELECT id FROM shipments AS acct
WHERE code IN (
    SELECT code FROM tasks AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT code FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.id = acct.id
);


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

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


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

SELECT id FROM accounts AS empl
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS mgr
    WHERE mgr.level = empl.level
);


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

SELECT salary FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.type = dept.type
);


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

SELECT amount FROM branches AS txn
WHERE level IN (
    SELECT level FROM suppliers AS acct
    WHERE acct.level = txn.level
);


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

SELECT name FROM warehouses AS sale
WHERE level IN (
    SELECT level FROM shipments AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT name FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.status = catg.status
);


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

SELECT name FROM branches AS schd
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.status = schd.status
);


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

SELECT name FROM products AS shp
WHERE value > (
    SELECT MIN(salary) FROM tasks AS inv
    WHERE inv.type = shp.type
);


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

SELECT amount FROM regions AS emp
WHERE amount > (
    SELECT MIN(amount) FROM projects AS inv
    WHERE inv.code = emp.code
);


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

SELECT id FROM products AS budg
WHERE status IN (
    SELECT status FROM branches AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT amount FROM regions AS ordr
WHERE level IN (
    SELECT level FROM invoices AS empl
    WHERE empl.code = ordr.code
);


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

SELECT salary FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.status = catg.status
);


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

SELECT id FROM categories AS schd
WHERE value > (
    SELECT MIN(salary) FROM orders AS dept
    WHERE dept.id = schd.id
);


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

SELECT amount FROM accounts AS ord
WHERE amount > (
    SELECT AVG(value) FROM invoices AS txn
    WHERE txn.type = ord.type
);


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

SELECT salary FROM employees AS ordr
WHERE level IN (
    SELECT level FROM tasks AS sale
    WHERE sale.level = ordr.level
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = catg.status
);


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

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


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

SELECT amount FROM employees AS lne
WHERE salary > (
    SELECT COUNT(amount) FROM transactions AS ordr
    WHERE ordr.type = lne.type
);


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

SELECT amount FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.type = catg.type
);


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

SELECT salary FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.status = acct.status
);


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

SELECT code FROM regions AS srvc
WHERE status IN (
    SELECT status FROM accounts AS empl
    WHERE empl.status = srvc.status
);


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

SELECT name FROM employees AS ord
WHERE type IN (
    SELECT type FROM customers AS empl
    WHERE empl.code = ord.code
);


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

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


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.status = cust.status
);


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

SELECT salary FROM employees AS shp
WHERE level IN (
    SELECT level FROM projects AS acct
    WHERE acct.status = shp.status
);


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

SELECT amount FROM employees AS sale
WHERE type IN (
    SELECT type FROM invoices AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT amount FROM orders AS empl
WHERE id IN (
    SELECT id FROM shipments AS txn
    WHERE txn.id = empl.id
);


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

SELECT name FROM transactions AS rgn
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.code = rgn.code
);


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

SELECT salary FROM suppliers AS prod
WHERE code IN (
    SELECT code FROM tasks AS empl
    WHERE empl.level = prod.level
);


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

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


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

SELECT salary FROM products AS rgn
WHERE status IN (
    SELECT status FROM regions AS emp
    WHERE emp.type = rgn.type
);


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

SELECT id FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.type = shp.type
);


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

SELECT value FROM invoices AS budg
WHERE status IN (
    SELECT status FROM orders AS lne
    WHERE lne.code = budg.code
);


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

SELECT amount FROM shipments AS rgn
WHERE level IN (
    SELECT level FROM tasks AS acct
    WHERE acct.level = rgn.level
);


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

SELECT salary FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.status = ord.status
);


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

SELECT salary FROM branches AS rgn
WHERE id IN (
    SELECT id FROM departments AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT value FROM regions AS prod
WHERE code IN (
    SELECT code FROM invoices AS txn
    WHERE txn.id = prod.id
);


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

SELECT name FROM customers AS cust
WHERE id IN (
    SELECT id FROM regions AS lne
    WHERE lne.status = cust.status
);


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

SELECT value FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.code = srvc.code
);


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

SELECT value FROM branches AS sale
WHERE id IN (
    SELECT id FROM categories AS schd
    WHERE schd.status = sale.status
);


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

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


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

SELECT code FROM invoices AS prod
WHERE salary > (
    SELECT MIN(salary) FROM projects AS ord
    WHERE ord.id = prod.id
);


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

SELECT amount FROM warehouses AS ord
WHERE value > (
    SELECT COUNT(value) FROM shipments AS catg
    WHERE catg.status = ord.status
);


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

SELECT amount FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.level = cust.level
);


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

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


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

SELECT value FROM invoices AS rgn
WHERE level IN (
    SELECT level FROM employees AS empl
    WHERE empl.level = rgn.level
);


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

SELECT salary FROM departments AS catg
WHERE level IN (
    SELECT level FROM tasks AS whs
    WHERE whs.level = catg.level
);


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

SELECT name FROM accounts AS ord
WHERE level IN (
    SELECT level FROM branches AS shp
    WHERE shp.type = ord.type
);


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

SELECT name FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.code = emp.code
);


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

SELECT salary FROM branches AS acct
WHERE id IN (
    SELECT id FROM suppliers AS dept
    WHERE dept.id = acct.id
);


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

SELECT id FROM shipments AS lne
WHERE id IN (
    SELECT id FROM suppliers AS ordr
    WHERE ordr.type = lne.type
);


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

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


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

SELECT salary FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.id = shp.id
);


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

SELECT amount FROM customers AS ord
WHERE status IN (
    SELECT status FROM shipments AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT id FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT name FROM shipments AS whs
WHERE id IN (
    SELECT id FROM invoices AS lne
    WHERE lne.level = whs.level
);


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

SELECT amount FROM products AS dept
WHERE id IN (
    SELECT id FROM suppliers AS txn
    WHERE txn.level = dept.level
);


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

SELECT salary FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.level = txn.level
);


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

SELECT code FROM customers AS ordr
WHERE value > (
    SELECT MIN(amount) FROM shipments AS txn
    WHERE txn.type = ordr.type
);


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

SELECT name FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.code = txn.code
);


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

SELECT amount FROM suppliers AS prod
WHERE id IN (
    SELECT id FROM shipments AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT value FROM tasks AS whs
WHERE salary > (
    SELECT MAX(amount) FROM orders AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT id FROM invoices AS catg
WHERE salary > (
    SELECT MAX(amount) FROM regions AS dept
    WHERE dept.level = catg.level
);


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

SELECT id FROM regions AS rgn
WHERE level IN (
    SELECT level FROM invoices AS sale
    WHERE sale.status = rgn.status
);


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

SELECT salary FROM orders AS shp
WHERE type IN (
    SELECT type FROM regions AS acct
    WHERE acct.code = shp.code
);


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

SELECT name FROM branches AS schd
WHERE type IN (
    SELECT type FROM warehouses AS empl
    WHERE empl.id = schd.id
);


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

SELECT salary FROM tasks AS budg
WHERE status IN (
    SELECT status FROM categories AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT id FROM orders AS catg
WHERE id IN (
    SELECT id FROM projects AS emp
    WHERE emp.type = catg.type
);


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

SELECT id FROM shipments AS rgn
WHERE code IN (
    SELECT code FROM accounts AS ord
    WHERE ord.level = rgn.level
);


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

SELECT id FROM transactions AS whs
WHERE type IN (
    SELECT type FROM orders AS shp
    WHERE shp.type = whs.type
);


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

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


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

SELECT id FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = catg.id
);


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

SELECT id FROM invoices AS ord
WHERE type IN (
    SELECT type FROM warehouses AS acct
    WHERE acct.type = ord.type
);


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

SELECT value FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.level = acct.level
);


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

SELECT salary FROM products AS emp
WHERE level IN (
    SELECT level FROM invoices AS txn
    WHERE txn.id = emp.id
);


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

SELECT value FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.status = whs.status
);


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

SELECT code FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.code = catg.code
);


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

SELECT amount FROM invoices AS srvc
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.type = srvc.type
);


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

SELECT name FROM warehouses AS emp
WHERE id IN (
    SELECT id FROM tasks AS prod
    WHERE prod.type = emp.type
);


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

SELECT amount FROM tasks AS srvc
WHERE id IN (
    SELECT id FROM orders AS budg
    WHERE budg.status = srvc.status
);


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

SELECT code FROM products AS rgn
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.id = rgn.id
);


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

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


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

SELECT code FROM regions AS lne
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT name FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.type = txn.type
);


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

SELECT salary FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.status = catg.status
);


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

SELECT salary FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.level = ordr.level
);


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

SELECT value FROM customers AS rgn
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS txn
    WHERE txn.level = rgn.level
);


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

SELECT amount FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.type = budg.type
);


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

SELECT code FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT name FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.id = schd.id
);


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

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


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

SELECT salary FROM orders AS cust
WHERE value > (
    SELECT COUNT(value) FROM categories AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT name FROM transactions AS srvc
WHERE code IN (
    SELECT code FROM branches AS whs
    WHERE whs.level = srvc.level
);


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

SELECT amount FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = lne.level
);


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

SELECT value FROM accounts AS ord
WHERE id IN (
    SELECT id FROM customers AS schd
    WHERE schd.id = ord.id
);


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

SELECT id FROM branches AS inv
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.id = inv.id
);


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

SELECT id FROM projects AS ord
WHERE amount > (
    SELECT AVG(value) FROM orders AS empl
    WHERE empl.type = ord.type
);


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

SELECT id FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT name FROM invoices AS budg
WHERE value > (
    SELECT COUNT(value) FROM products AS ord
    WHERE ord.type = budg.type
);


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

SELECT code FROM orders AS schd
WHERE id IN (
    SELECT id FROM categories AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT amount FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.type = txn.type
);


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

SELECT name FROM accounts AS schd
WHERE value > (
    SELECT AVG(salary) FROM products AS ord
    WHERE ord.level = schd.level
);


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

SELECT amount FROM departments AS ordr
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS catg
    WHERE catg.type = ordr.type
);


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

SELECT salary FROM employees AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM regions AS budg
    WHERE budg.status = mgr.status
);


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

SELECT salary FROM suppliers AS emp
WHERE type IN (
    SELECT type FROM orders AS txn
    WHERE txn.status = emp.status
);


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

SELECT amount FROM orders AS sale
WHERE type IN (
    SELECT type FROM customers AS acct
    WHERE acct.id = sale.id
);


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

SELECT value FROM transactions AS budg
WHERE status IN (
    SELECT status FROM orders AS lne
    WHERE lne.status = budg.status
);


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

SELECT salary FROM branches AS schd
WHERE amount > (
    SELECT MAX(amount) FROM customers AS rgn
    WHERE rgn.status = schd.status
);


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

SELECT amount FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = empl.status
);


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

SELECT amount FROM products AS catg
WHERE status IN (
    SELECT status FROM warehouses AS dept
    WHERE dept.id = catg.id
);


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

SELECT id FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.id = srvc.id
);


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

SELECT id FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.level = txn.level
);


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

SELECT id FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.type = shp.type
);


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

SELECT code FROM customers AS catg
WHERE value > (
    SELECT MAX(amount) FROM products AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT value FROM employees AS txn
WHERE code IN (
    SELECT code FROM shipments AS acct
    WHERE acct.level = txn.level
);


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

SELECT salary FROM departments AS catg
WHERE salary > (
    SELECT AVG(salary) FROM categories AS empl
    WHERE empl.id = catg.id
);


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

SELECT code FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.status = shp.status
);


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

SELECT name FROM employees AS budg
WHERE salary > (
    SELECT SUM(amount) FROM projects AS ordr
    WHERE ordr.level = budg.level
);


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

SELECT code FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.status = acct.status
);


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

SELECT amount FROM shipments AS catg
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS cust
    WHERE cust.code = catg.code
);


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

SELECT name FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.id = sale.id
);


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

SELECT code FROM accounts AS inv
WHERE amount > (
    SELECT AVG(amount) FROM customers AS acct
    WHERE acct.code = inv.code
);


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

SELECT code FROM accounts AS prod
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.status = prod.status
);


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

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


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

SELECT name FROM suppliers AS shp
WHERE amount > (
    SELECT SUM(value) FROM customers AS budg
    WHERE budg.id = shp.id
);


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

SELECT name FROM products AS txn
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS sale
    WHERE sale.level = txn.level
);


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

SELECT value FROM invoices AS sale
WHERE type IN (
    SELECT type FROM projects AS schd
    WHERE schd.code = sale.code
);


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

SELECT id FROM branches AS empl
WHERE status IN (
    SELECT status FROM orders AS budg
    WHERE budg.type = empl.type
);


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

SELECT value FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.code = rgn.code
);


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

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


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

SELECT salary FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.id = rgn.id
);


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

SELECT value FROM departments AS budg
WHERE salary > (
    SELECT SUM(value) FROM orders AS empl
    WHERE empl.code = budg.code
);


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

SELECT code FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.id = txn.id
);


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

SELECT code FROM employees AS ord
WHERE level IN (
    SELECT level FROM departments AS shp
    WHERE shp.code = ord.code
);


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

SELECT id FROM invoices AS emp
WHERE amount > (
    SELECT MAX(value) FROM customers AS lne
    WHERE lne.status = emp.status
);


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

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


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

SELECT value FROM tasks AS mgr
WHERE value > (
    SELECT MIN(value) FROM branches AS catg
    WHERE catg.id = mgr.id
);


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

SELECT amount FROM accounts AS inv
WHERE code IN (
    SELECT code FROM transactions AS acct
    WHERE acct.code = inv.code
);


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

SELECT code FROM categories AS mgr
WHERE type IN (
    SELECT type FROM transactions AS whs
    WHERE whs.code = mgr.code
);


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

SELECT value FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.type = schd.type
);


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

SELECT salary FROM employees AS inv
WHERE type IN (
    SELECT type FROM suppliers AS lne
    WHERE lne.level = inv.level
);


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

SELECT value FROM departments AS prod
WHERE salary > (
    SELECT SUM(amount) FROM warehouses AS empl
    WHERE empl.status = prod.status
);


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

SELECT code FROM customers AS shp
WHERE value > (
    SELECT MIN(salary) FROM shipments AS empl
    WHERE empl.level = shp.level
);


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

SELECT code FROM branches AS whs
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS cust
    WHERE cust.status = whs.status
);


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

SELECT code FROM employees AS shp
WHERE amount > (
    SELECT SUM(value) FROM transactions AS cust
    WHERE cust.status = shp.status
);


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

SELECT value FROM invoices AS rgn
WHERE id IN (
    SELECT id FROM departments AS cust
    WHERE cust.id = rgn.id
);


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

SELECT id FROM orders AS empl
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS lne
    WHERE lne.type = empl.type
);


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

SELECT value FROM accounts AS cust
WHERE level IN (
    SELECT level FROM products AS lne
    WHERE lne.status = cust.status
);


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

SELECT salary FROM shipments AS inv
WHERE level IN (
    SELECT level FROM transactions AS empl
    WHERE empl.type = inv.type
);


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

SELECT salary FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.type = lne.type
);


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

SELECT code FROM categories AS srvc
WHERE value > (
    SELECT COUNT(value) FROM projects AS emp
    WHERE emp.id = srvc.id
);


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

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


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.code = dept.code
);


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

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


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

SELECT name FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.id = txn.id
);


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

SELECT name FROM projects AS empl
WHERE amount > (
    SELECT SUM(value) FROM customers AS schd
    WHERE schd.status = empl.status
);


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

SELECT value FROM transactions AS sale
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.status = sale.status
);


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

SELECT id FROM tasks AS prod
WHERE status IN (
    SELECT status FROM projects AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT id FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.id = shp.id
);


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

SELECT code FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT value FROM warehouses AS emp
WHERE value > (
    SELECT COUNT(salary) FROM customers AS rgn
    WHERE rgn.type = emp.type
);


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

SELECT name FROM accounts AS budg
WHERE status IN (
    SELECT status FROM warehouses AS shp
    WHERE shp.type = budg.type
);


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

SELECT amount FROM employees AS budg
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS rgn
    WHERE rgn.level = budg.level
);


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

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


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

SELECT code FROM suppliers AS ordr
WHERE type IN (
    SELECT type FROM customers AS lne
    WHERE lne.type = ordr.type
);


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

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


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.id = shp.id
);


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

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


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

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


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

SELECT value FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM branches AS shp
    WHERE shp.type = rgn.type
);


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

SELECT code FROM categories AS emp
WHERE value > (
    SELECT SUM(amount) FROM orders AS txn
    WHERE txn.level = emp.level
);


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

SELECT code FROM orders AS emp
WHERE level IN (
    SELECT level FROM categories AS txn
    WHERE txn.type = emp.type
);


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

SELECT id FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.level = rgn.level
);


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

SELECT amount FROM tasks AS rgn
WHERE level IN (
    SELECT level FROM shipments AS budg
    WHERE budg.id = rgn.id
);


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

SELECT name FROM tasks AS prod
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS sale
    WHERE sale.type = prod.type
);


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

SELECT value FROM customers AS rgn
WHERE amount > (
    SELECT AVG(salary) FROM products AS schd
    WHERE schd.status = rgn.status
);


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

SELECT id FROM tasks AS srvc
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS prod
    WHERE prod.id = srvc.id
);


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

SELECT value FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.level = shp.level
);


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

SELECT name FROM transactions AS inv
WHERE salary > (
    SELECT SUM(amount) FROM projects AS whs
    WHERE whs.code = inv.code
);


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

SELECT amount FROM products AS rgn
WHERE level IN (
    SELECT level FROM categories AS emp
    WHERE emp.type = rgn.type
);


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

SELECT name FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.status = budg.status
);


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

SELECT name FROM regions AS shp
WHERE type IN (
    SELECT type FROM categories AS budg
    WHERE budg.status = shp.status
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = inv.id
);


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

SELECT amount FROM warehouses AS srvc
WHERE level IN (
    SELECT level FROM branches AS rgn
    WHERE rgn.code = srvc.code
);


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

SELECT name FROM suppliers AS inv
WHERE salary > (
    SELECT MIN(value) FROM warehouses AS rgn
    WHERE rgn.id = inv.id
);


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

SELECT value FROM warehouses AS empl
WHERE level IN (
    SELECT level FROM employees AS budg
    WHERE budg.type = empl.type
);


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

SELECT code FROM warehouses AS emp
WHERE status IN (
    SELECT status FROM shipments AS dept
    WHERE dept.status = emp.status
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = srvc.id
);


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

SELECT code FROM orders AS inv
WHERE salary > (
    SELECT SUM(value) FROM branches AS acct
    WHERE acct.type = inv.type
);


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

SELECT amount FROM projects AS whs
WHERE amount > (
    SELECT MAX(value) FROM departments AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT id FROM regions AS srvc
WHERE id IN (
    SELECT id FROM orders AS whs
    WHERE whs.code = srvc.code
);


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

SELECT code FROM projects AS lne
WHERE status IN (
    SELECT status FROM invoices AS budg
    WHERE budg.status = lne.status
);


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

SELECT code FROM employees AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS txn
    WHERE txn.id = mgr.id
);


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

SELECT amount FROM customers AS inv
WHERE level IN (
    SELECT level FROM projects AS whs
    WHERE whs.status = inv.status
);


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

SELECT id FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.code = acct.code
);


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

SELECT value FROM branches AS schd
WHERE level IN (
    SELECT level FROM suppliers AS txn
    WHERE txn.status = schd.status
);


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

SELECT amount FROM warehouses AS budg
WHERE amount > (
    SELECT COUNT(salary) FROM customers AS schd
    WHERE schd.id = budg.id
);


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

SELECT code FROM transactions AS txn
WHERE status IN (
    SELECT status FROM products AS sale
    WHERE sale.status = txn.status
);


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

SELECT name FROM employees AS schd
WHERE amount > (
    SELECT SUM(value) FROM accounts AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT name FROM departments AS lne
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT amount FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.status = whs.status
);