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

SELECT salary FROM regions AS inv
WHERE id IN (
    SELECT id FROM invoices AS sale
    WHERE sale.status = inv.status
);


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

SELECT code FROM warehouses AS whs
WHERE level IN (
    SELECT level FROM regions AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT code FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.status = shp.status
);


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

SELECT code FROM departments AS lne
WHERE level IN (
    SELECT level FROM projects AS inv
    WHERE inv.id = lne.id
);


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

SELECT code FROM invoices AS sale
WHERE status IN (
    SELECT status FROM employees AS cust
    WHERE cust.code = sale.code
);


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

SELECT name FROM departments AS sale
WHERE code IN (
    SELECT code FROM suppliers AS txn
    WHERE txn.code = sale.code
);


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

SELECT id FROM departments AS sale
WHERE code IN (
    SELECT code FROM categories AS mgr
    WHERE mgr.id = sale.id
);


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

SELECT amount FROM employees AS mgr
WHERE status IN (
    SELECT status FROM warehouses AS budg
    WHERE budg.level = mgr.level
);


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

SELECT amount FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.level = txn.level
);


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT salary FROM regions AS catg
WHERE amount > (
    SELECT AVG(value) FROM accounts AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT id FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT name FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.type = ord.type
);


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

SELECT code FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.type = cust.type
);


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

SELECT amount FROM categories AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS budg
    WHERE budg.status = ordr.status
);


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

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


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

SELECT name FROM departments AS mgr
WHERE status IN (
    SELECT status FROM tasks AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT code FROM accounts AS whs
WHERE level IN (
    SELECT level FROM suppliers AS schd
    WHERE schd.level = whs.level
);


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

SELECT value FROM employees AS rgn
WHERE salary > (
    SELECT SUM(salary) FROM shipments AS budg
    WHERE budg.status = rgn.status
);


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

SELECT code FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.code = schd.code
);


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

SELECT salary FROM shipments AS cust
WHERE level IN (
    SELECT level FROM products AS empl
    WHERE empl.status = cust.status
);


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

SELECT id FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.type = txn.type
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.id = emp.id
);


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

SELECT value FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.code = schd.code
);


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

SELECT salary FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.type = lne.type
);


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

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


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

SELECT code FROM departments AS rgn
WHERE salary > (
    SELECT COUNT(salary) FROM warehouses AS empl
    WHERE empl.level = rgn.level
);


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

SELECT id FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.level = sale.level
);


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

SELECT id FROM warehouses AS prod
WHERE code IN (
    SELECT code FROM branches AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT name FROM suppliers AS dept
WHERE value > (
    SELECT COUNT(value) FROM warehouses AS empl
    WHERE empl.status = dept.status
);


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

SELECT id FROM customers AS emp
WHERE type IN (
    SELECT type FROM branches AS whs
    WHERE whs.level = emp.level
);


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

SELECT value FROM invoices AS schd
WHERE level IN (
    SELECT level FROM customers AS ordr
    WHERE ordr.id = schd.id
);


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

SELECT name FROM invoices AS shp
WHERE level IN (
    SELECT level FROM warehouses AS dept
    WHERE dept.id = shp.id
);


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

SELECT value FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.code = srvc.code
);


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

SELECT value FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.id = emp.id
);


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

SELECT value FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.id = ord.id
);


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

SELECT amount FROM tasks AS cust
WHERE value > (
    SELECT AVG(amount) FROM regions AS budg
    WHERE budg.level = cust.level
);


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

SELECT salary FROM tasks AS schd
WHERE value > (
    SELECT AVG(salary) FROM branches AS inv
    WHERE inv.code = schd.code
);


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

SELECT value FROM categories AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM orders AS lne
    WHERE lne.level = ordr.level
);


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

SELECT id FROM transactions AS catg
WHERE id IN (
    SELECT id FROM warehouses AS shp
    WHERE shp.level = catg.level
);


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

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


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

SELECT name FROM warehouses AS shp
WHERE amount > (
    SELECT MAX(value) FROM accounts AS dept
    WHERE dept.code = shp.code
);


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

SELECT code FROM departments AS shp
WHERE type IN (
    SELECT type FROM suppliers AS prod
    WHERE prod.level = shp.level
);


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

SELECT salary FROM tasks AS inv
WHERE id IN (
    SELECT id FROM regions AS empl
    WHERE empl.code = inv.code
);


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

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


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

SELECT salary FROM departments AS dept
WHERE id IN (
    SELECT id FROM tasks AS empl
    WHERE empl.id = dept.id
);


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

SELECT id FROM transactions AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS rgn
    WHERE rgn.status = catg.status
);


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

SELECT code FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.type = empl.type
);


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

SELECT code FROM departments AS cust
WHERE id IN (
    SELECT id FROM projects AS shp
    WHERE shp.type = cust.type
);


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

SELECT id FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.level = whs.level
);


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

SELECT name FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.code = budg.code
);


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

SELECT id FROM projects AS ordr
WHERE code IN (
    SELECT code FROM accounts AS ord
    WHERE ord.type = ordr.type
);


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

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


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

SELECT code FROM employees AS txn
WHERE status IN (
    SELECT status FROM products AS ord
    WHERE ord.status = txn.status
);


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

SELECT name FROM employees AS schd
WHERE salary > (
    SELECT MAX(salary) FROM projects AS inv
    WHERE inv.level = schd.level
);


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

SELECT amount FROM employees AS ord
WHERE value > (
    SELECT MIN(value) FROM departments AS mgr
    WHERE mgr.type = ord.type
);


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

SELECT value FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = rgn.id
);


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

SELECT amount FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.code = ord.code
);


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

SELECT amount FROM shipments AS prod
WHERE level IN (
    SELECT level FROM warehouses AS emp
    WHERE emp.status = prod.status
);


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

SELECT amount FROM transactions AS budg
WHERE salary > (
    SELECT MIN(value) FROM invoices AS inv
    WHERE inv.status = budg.status
);


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

SELECT id FROM customers AS mgr
WHERE status IN (
    SELECT status FROM categories AS catg
    WHERE catg.level = mgr.level
);


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

SELECT id FROM regions AS empl
WHERE salary > (
    SELECT MAX(amount) FROM categories AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT id FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.level = txn.level
);


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

SELECT name FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.code = inv.code
);


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

SELECT name FROM regions AS acct
WHERE type IN (
    SELECT type FROM invoices AS whs
    WHERE whs.level = acct.level
);


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

SELECT code FROM accounts AS inv
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT salary FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.id = ordr.id
);


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

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


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

SELECT amount FROM departments AS cust
WHERE id IN (
    SELECT id FROM employees AS schd
    WHERE schd.type = cust.type
);


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

SELECT name FROM products AS empl
WHERE id IN (
    SELECT id FROM warehouses AS sale
    WHERE sale.type = empl.type
);


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

SELECT id FROM regions AS budg
WHERE salary > (
    SELECT COUNT(value) FROM orders AS whs
    WHERE whs.status = budg.status
);


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

SELECT amount FROM invoices AS srvc
WHERE code IN (
    SELECT code FROM orders AS budg
    WHERE budg.status = srvc.status
);


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

SELECT name FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.code = acct.code
);


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

SELECT name FROM accounts AS acct
WHERE code IN (
    SELECT code FROM departments AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT amount FROM suppliers AS catg
WHERE code IN (
    SELECT code FROM accounts AS emp
    WHERE emp.status = catg.status
);


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

SELECT id FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = srvc.id
);


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

SELECT salary FROM categories AS catg
WHERE code IN (
    SELECT code FROM accounts AS acct
    WHERE acct.type = catg.type
);


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

SELECT value FROM projects AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS acct
    WHERE acct.status = lne.status
);


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

SELECT code FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.type = dept.type
);


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

SELECT id FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.status = empl.status
);


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

SELECT salary FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.code = sale.code
);


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

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


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

SELECT name FROM invoices AS sale
WHERE value > (
    SELECT SUM(amount) FROM employees AS cust
    WHERE cust.code = sale.code
);


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

SELECT name FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.code = whs.code
);


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

SELECT salary FROM projects AS srvc
WHERE value > (
    SELECT AVG(value) FROM accounts AS emp
    WHERE emp.id = srvc.id
);


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

SELECT value FROM orders AS whs
WHERE id IN (
    SELECT id FROM tasks AS emp
    WHERE emp.status = whs.status
);


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

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


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

SELECT value FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.type = catg.type
);


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

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


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

SELECT name FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.id = sale.id
);


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

SELECT amount FROM projects AS mgr
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS lne
    WHERE lne.code = mgr.code
);


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

SELECT name FROM suppliers AS budg
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.code = budg.code
);


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

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


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

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


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

SELECT salary FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT code FROM orders AS acct
WHERE salary > (
    SELECT MAX(value) FROM suppliers AS sale
    WHERE sale.status = acct.status
);


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

SELECT value FROM suppliers AS ordr
WHERE id IN (
    SELECT id FROM warehouses AS ord
    WHERE ord.id = ordr.id
);


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

SELECT code FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.level = lne.level
);


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

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


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

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


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

SELECT name FROM projects AS empl
WHERE id IN (
    SELECT id FROM categories AS shp
    WHERE shp.level = empl.level
);


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

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


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

SELECT salary FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.status = schd.status
);


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

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


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

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


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

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


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

SELECT name FROM orders AS txn
WHERE salary > (
    SELECT SUM(salary) FROM projects AS inv
    WHERE inv.id = txn.id
);


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

SELECT salary FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.type = rgn.type
);


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

SELECT value FROM tasks AS budg
WHERE value > (
    SELECT COUNT(salary) FROM categories AS emp
    WHERE emp.status = budg.status
);


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

SELECT name FROM transactions AS sale
WHERE value > (
    SELECT MIN(salary) FROM projects AS inv
    WHERE inv.type = sale.type
);


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

SELECT salary FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.type = emp.type
);


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

SELECT name FROM orders AS dept
WHERE id IN (
    SELECT id FROM tasks AS srvc
    WHERE srvc.id = dept.id
);


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

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


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

SELECT amount FROM warehouses AS srvc
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.code = srvc.code
);


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

SELECT amount FROM tasks AS srvc
WHERE code IN (
    SELECT code FROM accounts AS ordr
    WHERE ordr.level = srvc.level
);


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

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


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

SELECT code FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.status = schd.status
);


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

SELECT value FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = catg.level
);


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

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


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

SELECT salary FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.status = prod.status
);


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

SELECT name FROM shipments AS ord
WHERE id IN (
    SELECT id FROM categories AS txn
    WHERE txn.type = ord.type
);


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

SELECT id FROM departments AS whs
WHERE amount > (
    SELECT SUM(amount) FROM employees AS mgr
    WHERE mgr.id = whs.id
);


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

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


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

SELECT id FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.status = ordr.status
);


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

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


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

SELECT name FROM accounts AS lne
WHERE amount > (
    SELECT MIN(salary) FROM products AS txn
    WHERE txn.type = lne.type
);


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

SELECT salary FROM shipments AS mgr
WHERE status IN (
    SELECT status FROM departments AS emp
    WHERE emp.code = mgr.code
);


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

SELECT amount FROM transactions AS mgr
WHERE code IN (
    SELECT code FROM projects AS budg
    WHERE budg.id = mgr.id
);


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

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


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

SELECT code FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.status = txn.status
);


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

SELECT id FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.id = sale.id
);


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

SELECT id FROM warehouses AS shp
WHERE code IN (
    SELECT code FROM suppliers AS ord
    WHERE ord.level = shp.level
);


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

SELECT salary FROM customers AS ordr
WHERE status IN (
    SELECT status FROM orders AS catg
    WHERE catg.status = ordr.status
);


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

SELECT name FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.level = acct.level
);


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

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


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

SELECT value FROM employees AS schd
WHERE value > (
    SELECT MIN(salary) FROM regions AS sale
    WHERE sale.status = schd.status
);


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

SELECT amount FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.id = empl.id
);


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

SELECT salary FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.id = mgr.id
);


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

SELECT id FROM customers AS budg
WHERE amount > (
    SELECT MIN(amount) FROM products AS srvc
    WHERE srvc.id = budg.id
);


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

SELECT salary FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.type = mgr.type
);


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

SELECT salary FROM branches AS budg
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS shp
    WHERE shp.level = budg.level
);


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

SELECT salary FROM regions AS mgr
WHERE type IN (
    SELECT type FROM categories AS sale
    WHERE sale.id = mgr.id
);


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

SELECT salary FROM orders AS inv
WHERE status IN (
    SELECT status FROM employees AS srvc
    WHERE srvc.status = inv.status
);


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

SELECT name FROM products AS inv
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS budg
    WHERE budg.level = inv.level
);


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

SELECT id FROM customers AS emp
WHERE status IN (
    SELECT status FROM warehouses AS prod
    WHERE prod.type = emp.type
);


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

SELECT code FROM tasks AS whs
WHERE value > (
    SELECT AVG(amount) FROM employees AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT id FROM tasks AS prod
WHERE amount > (
    SELECT MIN(amount) FROM branches AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT value FROM categories AS budg
WHERE salary > (
    SELECT SUM(salary) FROM products AS sale
    WHERE sale.type = budg.type
);


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

SELECT salary FROM warehouses AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS dept
    WHERE dept.level = whs.level
);


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

SELECT salary FROM branches AS ord
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.id = ord.id
);


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

SELECT salary FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.id = emp.id
);


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

SELECT name FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.type = acct.type
);


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

SELECT value FROM suppliers AS ord
WHERE id IN (
    SELECT id FROM branches AS prod
    WHERE prod.type = ord.type
);


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

SELECT id FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.type = sale.type
);


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

SELECT name FROM branches AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM customers AS txn
    WHERE txn.type = ordr.type
);


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

SELECT value FROM branches AS rgn
WHERE value > (
    SELECT COUNT(value) FROM warehouses AS inv
    WHERE inv.type = rgn.type
);


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

SELECT salary FROM categories AS schd
WHERE id IN (
    SELECT id FROM transactions AS srvc
    WHERE srvc.type = schd.type
);


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

SELECT salary FROM accounts AS dept
WHERE value > (
    SELECT COUNT(value) FROM products AS acct
    WHERE acct.code = dept.code
);


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

SELECT name FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT salary FROM categories AS dept
WHERE amount > (
    SELECT SUM(salary) FROM departments AS acct
    WHERE acct.status = dept.status
);


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

SELECT id FROM projects AS emp
WHERE code IN (
    SELECT code FROM branches AS dept
    WHERE dept.code = emp.code
);


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

SELECT code FROM transactions AS cust
WHERE id IN (
    SELECT id FROM suppliers AS lne
    WHERE lne.type = cust.type
);


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

SELECT id FROM employees AS rgn
WHERE amount > (
    SELECT MAX(amount) FROM branches AS lne
    WHERE lne.code = rgn.code
);


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

SELECT amount FROM departments AS cust
WHERE level IN (
    SELECT level FROM projects AS txn
    WHERE txn.type = cust.type
);


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

SELECT value FROM suppliers AS prod
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS cust
    WHERE cust.id = prod.id
);


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

SELECT salary FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.id = sale.id
);


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

SELECT code FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.code = mgr.code
);


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

SELECT name FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.id = sale.id
);


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

SELECT salary FROM orders AS ordr
WHERE status IN (
    SELECT status FROM accounts AS empl
    WHERE empl.status = ordr.status
);


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

SELECT salary FROM categories AS txn
WHERE level IN (
    SELECT level FROM employees AS inv
    WHERE inv.status = txn.status
);


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

SELECT code FROM categories AS inv
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS schd
    WHERE schd.type = inv.type
);


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

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


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

SELECT salary FROM shipments AS schd
WHERE id IN (
    SELECT id FROM categories AS whs
    WHERE whs.status = schd.status
);


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

SELECT code FROM branches AS srvc
WHERE status IN (
    SELECT status FROM departments AS budg
    WHERE budg.type = srvc.type
);


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

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


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

SELECT code FROM regions AS mgr
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT value FROM suppliers AS whs
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT amount FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.id = schd.id
);


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

SELECT name FROM warehouses AS lne
WHERE id IN (
    SELECT id FROM suppliers AS rgn
    WHERE rgn.status = lne.status
);


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

SELECT id FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.id = schd.id
);


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

SELECT name FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = srvc.type
);


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

SELECT code FROM projects AS rgn
WHERE id IN (
    SELECT id FROM departments AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT amount FROM accounts AS shp
WHERE id IN (
    SELECT id FROM branches AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT id FROM tasks AS dept
WHERE amount > (
    SELECT SUM(salary) FROM products AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT amount FROM shipments AS sale
WHERE salary > (
    SELECT AVG(value) FROM customers AS srvc
    WHERE srvc.type = sale.type
);


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

SELECT salary FROM projects AS emp
WHERE level IN (
    SELECT level FROM branches AS inv
    WHERE inv.status = emp.status
);


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

SELECT amount FROM warehouses AS dept
WHERE salary > (
    SELECT MIN(salary) FROM tasks AS shp
    WHERE shp.type = dept.type
);


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

SELECT value FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.type = shp.type
);


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

SELECT name FROM categories AS inv
WHERE level IN (
    SELECT level FROM employees AS sale
    WHERE sale.level = inv.level
);


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

SELECT name FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.level = emp.level
);


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

SELECT amount FROM shipments AS dept
WHERE level IN (
    SELECT level FROM departments AS shp
    WHERE shp.id = dept.id
);


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

SELECT value FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.type = lne.type
);


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

SELECT amount FROM categories AS mgr
WHERE type IN (
    SELECT type FROM accounts AS rgn
    WHERE rgn.code = mgr.code
);


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

SELECT id FROM departments AS ord
WHERE status IN (
    SELECT status FROM shipments AS whs
    WHERE whs.type = ord.type
);


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

SELECT code FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.id = budg.id
);


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

SELECT amount FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.status = cust.status
);


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

SELECT code FROM customers AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM regions AS txn
    WHERE txn.type = rgn.type
);


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

SELECT salary FROM shipments AS ordr
WHERE status IN (
    SELECT status FROM tasks AS lne
    WHERE lne.id = ordr.id
);


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

SELECT salary FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.type = dept.type
);


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

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


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

SELECT salary FROM suppliers AS prod
WHERE status IN (
    SELECT status FROM regions AS schd
    WHERE schd.type = prod.type
);


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

SELECT salary FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.type = empl.type
);


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

SELECT salary FROM accounts AS shp
WHERE code IN (
    SELECT code FROM customers AS ordr
    WHERE ordr.id = shp.id
);


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

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


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

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


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

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


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

SELECT salary FROM products AS empl
WHERE level IN (
    SELECT level FROM warehouses AS inv
    WHERE inv.id = empl.id
);


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

SELECT id FROM departments AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM warehouses AS shp
    WHERE shp.type = ordr.type
);


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

SELECT name FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.type = budg.type
);


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

SELECT code FROM categories AS srvc
WHERE value > (
    SELECT MIN(value) FROM departments AS whs
    WHERE whs.type = srvc.type
);


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

SELECT salary FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.id = rgn.id
);


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

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


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

SELECT salary FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.level = catg.level
);


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

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


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

SELECT amount FROM shipments AS schd
WHERE amount > (
    SELECT SUM(value) FROM accounts AS budg
    WHERE budg.code = schd.code
);


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

SELECT salary FROM accounts AS ord
WHERE value > (
    SELECT MAX(salary) FROM departments AS prod
    WHERE prod.id = ord.id
);


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

SELECT code FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.code = empl.code
);


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

SELECT salary FROM suppliers AS prod
WHERE id IN (
    SELECT id FROM warehouses AS txn
    WHERE txn.code = prod.code
);


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

SELECT salary FROM customers AS txn
WHERE status IN (
    SELECT status FROM accounts AS shp
    WHERE shp.id = txn.id
);


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

SELECT value FROM regions AS acct
WHERE id IN (
    SELECT id FROM orders AS empl
    WHERE empl.level = acct.level
);


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

SELECT salary FROM tasks AS prod
WHERE type IN (
    SELECT type FROM warehouses AS srvc
    WHERE srvc.id = prod.id
);


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

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


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

SELECT value FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.id = lne.id
);


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

SELECT value FROM products AS ord
WHERE status IN (
    SELECT status FROM regions AS lne
    WHERE lne.id = ord.id
);


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

SELECT amount FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.code = lne.code
);


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

SELECT salary FROM projects AS ordr
WHERE status IN (
    SELECT status FROM tasks AS prod
    WHERE prod.status = ordr.status
);


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

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


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

SELECT salary FROM products AS cust
WHERE code IN (
    SELECT code FROM orders AS dept
    WHERE dept.type = cust.type
);


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

SELECT salary FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.code = inv.code
);


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

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


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

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


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

SELECT amount FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.level = inv.level
);


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

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


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

SELECT code FROM invoices AS catg
WHERE status IN (
    SELECT status FROM transactions AS srvc
    WHERE srvc.id = catg.id
);


Prompt:
Schema:
  suppliers (alias: acct)(type, level, id, name)
  orders(id, level, salary, type)
Task: Retrieve id from suppliers with salary above the COUNT(salary) of orders rows sharing the same level.
SQL:

SELECT id FROM suppliers AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS txn
    WHERE txn.level = acct.level
);


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

SELECT value FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.type = acct.type
);


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

SELECT value FROM orders AS cust
WHERE type IN (
    SELECT type FROM warehouses AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT amount FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.level = acct.level
);


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

SELECT name FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.type = srvc.type
);


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

SELECT salary FROM branches AS cust
WHERE salary > (
    SELECT MAX(amount) FROM departments AS lne
    WHERE lne.status = cust.status
);


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

SELECT value FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.level = mgr.level
);


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

SELECT value FROM regions AS txn
WHERE amount > (
    SELECT SUM(salary) FROM projects AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT code FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.status = ordr.status
);


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

SELECT amount FROM branches AS txn
WHERE code IN (
    SELECT code FROM transactions AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT salary FROM projects AS ordr
WHERE id IN (
    SELECT id FROM accounts AS shp
    WHERE shp.level = ordr.level
);


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

SELECT salary FROM suppliers AS budg
WHERE status IN (
    SELECT status FROM regions AS txn
    WHERE txn.id = budg.id
);


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

SELECT name FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.type = srvc.type
);


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

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


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

SELECT id FROM accounts AS ord
WHERE value > (
    SELECT SUM(amount) FROM departments AS whs
    WHERE whs.status = ord.status
);


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

SELECT amount FROM invoices AS acct
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.level = acct.level
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.level = catg.level
);


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

SELECT name FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT amount FROM regions AS lne
WHERE level IN (
    SELECT level FROM customers AS schd
    WHERE schd.code = lne.code
);


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

SELECT name FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = dept.type
);


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

SELECT code FROM projects AS acct
WHERE salary > (
    SELECT MIN(amount) FROM employees AS budg
    WHERE budg.code = acct.code
);


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

SELECT id FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.code = txn.code
);


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

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


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

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


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

SELECT salary FROM departments AS srvc
WHERE code IN (
    SELECT code FROM invoices AS whs
    WHERE whs.code = srvc.code
);


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

SELECT salary FROM employees AS mgr
WHERE value > (
    SELECT MAX(amount) FROM projects AS empl
    WHERE empl.type = mgr.type
);


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

SELECT salary FROM shipments AS txn
WHERE code IN (
    SELECT code FROM categories AS ord
    WHERE ord.status = txn.status
);


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

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


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

SELECT value FROM transactions AS sale
WHERE value > (
    SELECT MAX(salary) FROM products AS prod
    WHERE prod.code = sale.code
);


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

SELECT amount FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.type = whs.type
);


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

SELECT id FROM invoices AS sale
WHERE salary > (
    SELECT AVG(value) FROM categories AS shp
    WHERE shp.status = sale.status
);


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

SELECT value FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT amount FROM warehouses AS ordr
WHERE value > (
    SELECT MIN(amount) FROM branches AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.code = txn.code
);


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

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


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

SELECT value FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.type = ord.type
);


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

SELECT name FROM orders AS emp
WHERE value > (
    SELECT AVG(salary) FROM transactions AS txn
    WHERE txn.id = emp.id
);


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

SELECT amount FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.level = lne.level
);


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

SELECT code FROM transactions AS catg
WHERE type IN (
    SELECT type FROM warehouses AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT amount FROM departments AS mgr
WHERE id IN (
    SELECT id FROM orders AS sale
    WHERE sale.type = mgr.type
);


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

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


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

SELECT code FROM accounts AS ord
WHERE salary > (
    SELECT MAX(salary) FROM employees AS txn
    WHERE txn.id = ord.id
);


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

SELECT salary FROM tasks AS budg
WHERE salary > (
    SELECT MIN(value) FROM warehouses AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT code FROM invoices AS ord
WHERE amount > (
    SELECT AVG(amount) FROM departments AS txn
    WHERE txn.status = ord.status
);


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.code = dept.code
);


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

SELECT value FROM employees AS sale
WHERE amount > (
    SELECT MIN(salary) FROM categories AS dept
    WHERE dept.level = sale.level
);


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

SELECT code FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.type = whs.type
);


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

SELECT code FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT value FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.type = ordr.type
);


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

SELECT salary FROM regions AS mgr
WHERE id IN (
    SELECT id FROM invoices AS empl
    WHERE empl.code = mgr.code
);


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

SELECT salary FROM tasks AS ordr
WHERE status IN (
    SELECT status FROM transactions AS ord
    WHERE ord.id = ordr.id
);


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

SELECT salary FROM invoices AS schd
WHERE value > (
    SELECT COUNT(amount) FROM transactions AS lne
    WHERE lne.status = schd.status
);


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

SELECT salary FROM invoices AS prod
WHERE code IN (
    SELECT code FROM customers AS empl
    WHERE empl.id = prod.id
);


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

SELECT salary FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT id FROM invoices AS inv
WHERE amount > (
    SELECT MAX(amount) FROM employees AS budg
    WHERE budg.level = inv.level
);


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

SELECT salary FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.level = emp.level
);


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

SELECT id FROM categories AS rgn
WHERE salary > (
    SELECT MIN(value) FROM projects AS whs
    WHERE whs.status = rgn.status
);


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

SELECT salary FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.level = lne.level
);


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

SELECT name FROM orders AS inv
WHERE status IN (
    SELECT status FROM invoices AS acct
    WHERE acct.level = inv.level
);


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

SELECT salary FROM accounts AS lne
WHERE status IN (
    SELECT status FROM regions AS txn
    WHERE txn.status = lne.status
);


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

SELECT name FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.status = mgr.status
);