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

SELECT name FROM warehouses AS sale
WHERE id IN (
    SELECT id FROM regions AS emp
    WHERE emp.code = sale.code
);


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

SELECT name FROM departments AS shp
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS txn
    WHERE txn.id = shp.id
);


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

SELECT salary FROM warehouses AS emp
WHERE status IN (
    SELECT status FROM projects AS schd
    WHERE schd.status = emp.status
);


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

SELECT value FROM shipments AS acct
WHERE code IN (
    SELECT code FROM tasks AS cust
    WHERE cust.id = acct.id
);


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

SELECT id FROM invoices AS mgr
WHERE value > (
    SELECT AVG(amount) FROM customers AS dept
    WHERE dept.status = mgr.status
);


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

SELECT value FROM invoices AS txn
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS catg
    WHERE catg.id = txn.id
);


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

SELECT name FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT salary FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.id = prod.id
);


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

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


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

SELECT name FROM branches AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM categories AS rgn
    WHERE rgn.type = srvc.type
);


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

SELECT name FROM categories AS cust
WHERE amount > (
    SELECT COUNT(amount) FROM products AS inv
    WHERE inv.status = cust.status
);


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

SELECT name FROM invoices AS sale
WHERE value > (
    SELECT COUNT(salary) FROM regions AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT name FROM invoices AS budg
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS rgn
    WHERE rgn.level = budg.level
);


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

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


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

SELECT code FROM warehouses AS catg
WHERE id IN (
    SELECT id FROM products AS dept
    WHERE dept.type = catg.type
);


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

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


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

SELECT value FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT code FROM employees AS whs
WHERE salary > (
    SELECT AVG(value) FROM projects AS budg
    WHERE budg.code = whs.code
);


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

SELECT salary FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.status = ord.status
);


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

SELECT amount FROM branches AS inv
WHERE value > (
    SELECT SUM(salary) FROM accounts AS shp
    WHERE shp.code = inv.code
);


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

SELECT code FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.type = ordr.type
);


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

SELECT salary FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.id = lne.id
);


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

SELECT id FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.code = schd.code
);


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

SELECT salary FROM orders AS acct
WHERE type IN (
    SELECT type FROM warehouses AS ord
    WHERE ord.code = acct.code
);


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

SELECT amount FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.status = dept.status
);


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

SELECT id FROM categories AS mgr
WHERE amount > (
    SELECT AVG(salary) FROM products AS shp
    WHERE shp.type = mgr.type
);


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

SELECT value FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = ord.id
);


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

SELECT name FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT amount FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.type = ord.type
);


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

SELECT code FROM projects AS empl
WHERE status IN (
    SELECT status FROM suppliers AS acct
    WHERE acct.code = empl.code
);


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

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


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

SELECT name FROM invoices AS txn
WHERE type IN (
    SELECT type FROM warehouses AS shp
    WHERE shp.status = txn.status
);


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

SELECT amount FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = shp.type
);


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

SELECT code FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.type = budg.type
);


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

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


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

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


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

SELECT code FROM customers AS srvc
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.id = srvc.id
);


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

SELECT code FROM products AS acct
WHERE salary > (
    SELECT AVG(value) FROM tasks AS budg
    WHERE budg.status = acct.status
);


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

SELECT id FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.status = schd.status
);


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

SELECT code FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.type = schd.type
);


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

SELECT salary FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.id = sale.id
);


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

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


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

SELECT amount FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.id = catg.id
);


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

SELECT amount FROM branches AS txn
WHERE amount > (
    SELECT MIN(amount) FROM warehouses AS inv
    WHERE inv.code = txn.code
);


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

SELECT salary FROM products AS whs
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.id = whs.id
);


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

SELECT code FROM tasks AS lne
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS txn
    WHERE txn.code = lne.code
);


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

SELECT name FROM categories AS ordr
WHERE level IN (
    SELECT level FROM projects AS inv
    WHERE inv.type = ordr.type
);


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

SELECT name FROM employees AS srvc
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS cust
    WHERE cust.level = srvc.level
);


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

SELECT id FROM products AS rgn
WHERE code IN (
    SELECT code FROM tasks AS schd
    WHERE schd.level = rgn.level
);


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

SELECT amount FROM employees AS whs
WHERE amount > (
    SELECT MAX(amount) FROM orders AS empl
    WHERE empl.level = whs.level
);


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

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


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

SELECT amount FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.status = txn.status
);


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

SELECT value FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.id = srvc.id
);


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

SELECT salary FROM shipments AS srvc
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS whs
    WHERE whs.status = srvc.status
);


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

SELECT salary FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.code = dept.code
);


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

SELECT amount FROM customers AS sale
WHERE amount > (
    SELECT MAX(salary) FROM categories AS catg
    WHERE catg.status = sale.status
);


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

SELECT amount FROM tasks AS rgn
WHERE level IN (
    SELECT level FROM departments AS budg
    WHERE budg.type = rgn.type
);


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

SELECT name FROM accounts AS srvc
WHERE code IN (
    SELECT code FROM employees AS rgn
    WHERE rgn.id = srvc.id
);


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

SELECT code FROM products AS emp
WHERE status IN (
    SELECT status FROM tasks AS txn
    WHERE txn.type = emp.type
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.id = txn.id
);


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

SELECT amount FROM warehouses AS txn
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS schd
    WHERE schd.type = txn.type
);


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

SELECT value FROM suppliers AS sale
WHERE amount > (
    SELECT MIN(value) FROM branches AS prod
    WHERE prod.code = sale.code
);


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

SELECT code FROM customers AS schd
WHERE level IN (
    SELECT level FROM categories AS acct
    WHERE acct.code = schd.code
);


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

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


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

SELECT id FROM transactions AS srvc
WHERE level IN (
    SELECT level FROM products AS budg
    WHERE budg.status = srvc.status
);


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

SELECT value FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.level = shp.level
);


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

SELECT value FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.code = catg.code
);


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

SELECT amount FROM suppliers AS dept
WHERE id IN (
    SELECT id FROM projects AS cust
    WHERE cust.level = dept.level
);


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

SELECT value FROM customers AS txn
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.type = txn.type
);


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

SELECT amount FROM regions AS catg
WHERE id IN (
    SELECT id FROM customers AS whs
    WHERE whs.status = catg.status
);


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

SELECT id FROM transactions AS cust
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS prod
    WHERE prod.code = cust.code
);


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

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


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.level = txn.level
);


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

SELECT name FROM employees AS srvc
WHERE amount > (
    SELECT MIN(value) FROM categories AS dept
    WHERE dept.code = srvc.code
);


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

SELECT code FROM projects AS prod
WHERE level IN (
    SELECT level FROM products AS txn
    WHERE txn.id = prod.id
);


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

SELECT id FROM products AS srvc
WHERE type IN (
    SELECT type FROM invoices AS mgr
    WHERE mgr.code = srvc.code
);


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

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


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

SELECT amount FROM customers AS ordr
WHERE id IN (
    SELECT id FROM suppliers AS dept
    WHERE dept.status = ordr.status
);


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

SELECT code FROM products AS sale
WHERE value > (
    SELECT MAX(amount) FROM invoices AS schd
    WHERE schd.level = sale.level
);


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

SELECT code FROM invoices AS cust
WHERE id IN (
    SELECT id FROM branches AS dept
    WHERE dept.code = cust.code
);


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

SELECT amount FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = lne.status
);


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

SELECT name FROM products AS budg
WHERE code IN (
    SELECT code FROM employees AS emp
    WHERE emp.code = budg.code
);


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

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


Prompt:
Schema:
  regions (alias: emp)(date, id, salary, level)
  invoices(salary, date, id, level)
Task: Retrieve amount from regions with salary above the MAX(salary) of invoices rows sharing the same status.
SQL:

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


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

SELECT salary FROM regions AS acct
WHERE amount > (
    SELECT MAX(value) FROM products AS catg
    WHERE catg.status = acct.status
);


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

SELECT name FROM accounts AS shp
WHERE amount > (
    SELECT AVG(amount) FROM products AS catg
    WHERE catg.status = shp.status
);


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

SELECT amount FROM branches AS sale
WHERE id IN (
    SELECT id FROM categories AS txn
    WHERE txn.level = sale.level
);


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

SELECT amount FROM regions AS schd
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS emp
    WHERE emp.id = schd.id
);


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

SELECT name FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = cust.status
);


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

SELECT id FROM invoices AS whs
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS catg
    WHERE catg.code = whs.code
);


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

SELECT salary FROM suppliers AS txn
WHERE amount > (
    SELECT MIN(salary) FROM regions AS rgn
    WHERE rgn.id = txn.id
);


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

SELECT name FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.status = inv.status
);


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

SELECT salary FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = sale.level
);


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

SELECT name FROM transactions AS lne
WHERE amount > (
    SELECT MAX(value) FROM branches AS emp
    WHERE emp.level = lne.level
);


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

SELECT id FROM projects AS txn
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.status = txn.status
);


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

SELECT code FROM suppliers AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM products AS acct
    WHERE acct.level = mgr.level
);


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

SELECT amount FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT id FROM customers AS sale
WHERE id IN (
    SELECT id FROM orders AS lne
    WHERE lne.code = sale.code
);


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

SELECT id FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.id = srvc.id
);


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

SELECT name FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.type = shp.type
);


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

SELECT id FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.code = cust.code
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = ord.type
);


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

SELECT amount FROM shipments AS acct
WHERE type IN (
    SELECT type FROM projects AS schd
    WHERE schd.type = acct.type
);


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

SELECT amount FROM accounts AS txn
WHERE id IN (
    SELECT id FROM projects AS rgn
    WHERE rgn.id = txn.id
);


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

SELECT id FROM regions AS shp
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS acct
    WHERE acct.id = shp.id
);


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

SELECT code FROM employees AS mgr
WHERE amount > (
    SELECT MAX(value) FROM categories AS sale
    WHERE sale.status = mgr.status
);


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

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


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

SELECT salary FROM employees AS ordr
WHERE value > (
    SELECT MIN(value) FROM projects AS cust
    WHERE cust.code = ordr.code
);


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

SELECT id FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.type = acct.type
);


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

SELECT salary FROM shipments AS srvc
WHERE level IN (
    SELECT level FROM categories AS acct
    WHERE acct.level = srvc.level
);


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

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


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

SELECT value FROM invoices AS catg
WHERE value > (
    SELECT MIN(value) FROM customers AS sale
    WHERE sale.status = catg.status
);


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

SELECT value FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT amount FROM regions AS txn
WHERE level IN (
    SELECT level FROM warehouses AS acct
    WHERE acct.code = txn.code
);


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

SELECT salary FROM products AS inv
WHERE status IN (
    SELECT status FROM suppliers AS dept
    WHERE dept.type = inv.type
);


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

SELECT code FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.type = dept.type
);


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

SELECT code FROM invoices AS rgn
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS sale
    WHERE sale.id = rgn.id
);


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

SELECT salary FROM employees AS prod
WHERE value > (
    SELECT MAX(amount) FROM warehouses AS shp
    WHERE shp.id = prod.id
);


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

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


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

SELECT id FROM projects AS inv
WHERE status IN (
    SELECT status FROM accounts AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT amount FROM employees AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM departments AS whs
    WHERE whs.code = ordr.code
);


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

SELECT amount FROM warehouses AS ordr
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS lne
    WHERE lne.status = ordr.status
);


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

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


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

SELECT code FROM tasks AS whs
WHERE value > (
    SELECT MIN(salary) FROM departments AS ordr
    WHERE ordr.id = whs.id
);


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

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


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

SELECT code FROM shipments AS txn
WHERE level IN (
    SELECT level FROM branches AS mgr
    WHERE mgr.id = txn.id
);


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

SELECT salary FROM branches AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT value FROM departments AS emp
WHERE id IN (
    SELECT id FROM projects AS whs
    WHERE whs.type = emp.type
);


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

SELECT value FROM categories AS schd
WHERE code IN (
    SELECT code FROM regions AS whs
    WHERE whs.level = schd.level
);


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

SELECT name FROM branches AS rgn
WHERE value > (
    SELECT SUM(amount) FROM products AS inv
    WHERE inv.type = rgn.type
);


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

SELECT id FROM tasks AS ordr
WHERE id IN (
    SELECT id FROM regions AS dept
    WHERE dept.id = ordr.id
);


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

SELECT salary FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.status = ordr.status
);


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

SELECT amount FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.id = shp.id
);


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

SELECT salary FROM customers AS whs
WHERE code IN (
    SELECT code FROM invoices AS lne
    WHERE lne.code = whs.code
);


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

SELECT amount FROM categories AS budg
WHERE code IN (
    SELECT code FROM orders AS schd
    WHERE schd.type = budg.type
);


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

SELECT salary FROM products AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT salary FROM warehouses AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM branches AS ord
    WHERE ord.level = schd.level
);


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

SELECT salary FROM categories AS srvc
WHERE id IN (
    SELECT id FROM products AS emp
    WHERE emp.type = srvc.type
);


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

SELECT amount FROM orders AS cust
WHERE code IN (
    SELECT code FROM accounts AS lne
    WHERE lne.type = cust.type
);


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

SELECT code FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT salary FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.code = rgn.code
);


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

SELECT id FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM branches AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT salary FROM projects AS shp
WHERE type IN (
    SELECT type FROM categories AS srvc
    WHERE srvc.level = shp.level
);


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

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


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

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS schd
    WHERE schd.code = shp.code
);


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

SELECT id FROM branches AS dept
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.id = dept.id
);


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

SELECT name FROM projects AS sale
WHERE value > (
    SELECT MAX(value) FROM products AS schd
    WHERE schd.level = sale.level
);


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

SELECT name FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.type = schd.type
);


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

SELECT amount FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT value FROM categories AS prod
WHERE status IN (
    SELECT status FROM projects AS txn
    WHERE txn.code = prod.code
);


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

SELECT id FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = ordr.code
);


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

SELECT amount FROM customers AS ord
WHERE status IN (
    SELECT status FROM departments AS schd
    WHERE schd.type = ord.type
);


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

SELECT code FROM invoices AS empl
WHERE status IN (
    SELECT status FROM shipments AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT id FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.type = txn.type
);


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

SELECT value FROM orders AS srvc
WHERE status IN (
    SELECT status FROM customers AS mgr
    WHERE mgr.id = srvc.id
);


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

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


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

SELECT code FROM regions AS whs
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT value FROM regions AS lne
WHERE value > (
    SELECT COUNT(salary) FROM orders AS ord
    WHERE ord.id = lne.id
);


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

SELECT code FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.status = emp.status
);


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

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


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

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


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

SELECT salary FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT amount FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.id = empl.id
);


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

SELECT value FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT amount FROM branches AS emp
WHERE status IN (
    SELECT status FROM projects AS sale
    WHERE sale.status = emp.status
);


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

SELECT id FROM regions AS whs
WHERE type IN (
    SELECT type FROM invoices AS lne
    WHERE lne.level = whs.level
);


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

SELECT amount FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT salary FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.code = empl.code
);


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

SELECT id FROM categories AS emp
WHERE type IN (
    SELECT type FROM projects AS budg
    WHERE budg.id = emp.id
);


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

SELECT amount FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT amount FROM employees AS lne
WHERE id IN (
    SELECT id FROM regions AS schd
    WHERE schd.id = lne.id
);


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

SELECT code FROM projects AS budg
WHERE value > (
    SELECT MIN(amount) FROM branches AS schd
    WHERE schd.status = budg.status
);


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

SELECT code FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.id = inv.id
);


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

SELECT code FROM suppliers AS catg
WHERE id IN (
    SELECT id FROM customers AS mgr
    WHERE mgr.id = catg.id
);


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

SELECT name FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.status = rgn.status
);


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

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


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

SELECT amount FROM invoices AS prod
WHERE salary > (
    SELECT SUM(amount) FROM employees AS schd
    WHERE schd.code = prod.code
);


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

SELECT value FROM categories AS emp
WHERE id IN (
    SELECT id FROM products AS empl
    WHERE empl.type = emp.type
);


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

SELECT value FROM departments AS ord
WHERE status IN (
    SELECT status FROM warehouses AS catg
    WHERE catg.id = ord.id
);


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

SELECT amount FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.code = srvc.code
);


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

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


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

SELECT name FROM tasks AS catg
WHERE type IN (
    SELECT type FROM projects AS ord
    WHERE ord.level = catg.level
);


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

SELECT salary FROM accounts AS whs
WHERE type IN (
    SELECT type FROM orders AS cust
    WHERE cust.status = whs.status
);


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

SELECT code FROM regions AS emp
WHERE id IN (
    SELECT id FROM accounts AS srvc
    WHERE srvc.id = emp.id
);


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

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


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

SELECT code FROM suppliers AS txn
WHERE id IN (
    SELECT id FROM products AS shp
    WHERE shp.level = txn.level
);


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

SELECT salary FROM products AS emp
WHERE value > (
    SELECT MIN(value) FROM tasks AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT id FROM employees AS budg
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.code = budg.code
);


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

SELECT salary FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.id = inv.id
);


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

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


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

SELECT id FROM regions AS prod
WHERE type IN (
    SELECT type FROM customers AS ord
    WHERE ord.code = prod.code
);


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

SELECT amount FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.code = lne.code
);


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

SELECT name FROM employees AS empl
WHERE value > (
    SELECT AVG(value) FROM transactions AS lne
    WHERE lne.code = empl.code
);


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

SELECT amount FROM branches AS mgr
WHERE salary > (
    SELECT COUNT(amount) FROM warehouses AS acct
    WHERE acct.id = mgr.id
);


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

SELECT id FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.id = ord.id
);


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

SELECT id FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.status = sale.status
);


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

SELECT salary FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.status = ord.status
);


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

SELECT salary FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.level = rgn.level
);


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

SELECT salary FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.code = lne.code
);


Prompt:
Schema:
  transactions (alias: srvc)(status, amount, id, value)
  suppliers(amount, status, id, value)
Task: Retrieve code from transactions with value above the MAX(value) of suppliers rows sharing the same code.
SQL:

SELECT code FROM transactions AS srvc
WHERE value > (
    SELECT MAX(value) FROM suppliers AS ordr
    WHERE ordr.code = srvc.code
);


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

SELECT salary FROM employees AS dept
WHERE id IN (
    SELECT id FROM categories AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT salary FROM tasks AS sale
WHERE code IN (
    SELECT code FROM branches AS txn
    WHERE txn.type = sale.type
);


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

SELECT amount FROM shipments AS ordr
WHERE id IN (
    SELECT id FROM tasks AS acct
    WHERE acct.id = ordr.id
);


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

SELECT amount FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT value FROM invoices AS cust
WHERE value > (
    SELECT MAX(salary) FROM warehouses AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT code FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.status = shp.status
);


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

SELECT value FROM transactions AS cust
WHERE level IN (
    SELECT level FROM regions AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT value FROM branches AS sale
WHERE type IN (
    SELECT type FROM regions AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT name FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.status = prod.status
);


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

SELECT salary FROM branches AS ord
WHERE type IN (
    SELECT type FROM orders AS schd
    WHERE schd.type = ord.type
);


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

SELECT code FROM invoices AS acct
WHERE level IN (
    SELECT level FROM regions AS ord
    WHERE ord.code = acct.code
);


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

SELECT salary FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.status = whs.status
);


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

SELECT amount FROM projects AS ordr
WHERE type IN (
    SELECT type FROM branches AS catg
    WHERE catg.type = ordr.type
);


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

SELECT salary FROM regions AS budg
WHERE salary > (
    SELECT MAX(amount) FROM branches AS ord
    WHERE ord.id = budg.id
);


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

SELECT name FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.level = emp.level
);


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

SELECT name FROM transactions AS mgr
WHERE value > (
    SELECT MIN(salary) FROM customers AS whs
    WHERE whs.code = mgr.code
);


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

SELECT name FROM categories AS cust
WHERE id IN (
    SELECT id FROM transactions AS lne
    WHERE lne.type = cust.type
);


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

SELECT salary FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.status = ordr.status
);


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

SELECT value FROM invoices AS inv
WHERE id IN (
    SELECT id FROM suppliers AS schd
    WHERE schd.level = inv.level
);


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

SELECT salary FROM accounts AS whs
WHERE id IN (
    SELECT id FROM employees AS dept
    WHERE dept.type = whs.type
);


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

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


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

SELECT code FROM departments AS shp
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.id = shp.id
);


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

SELECT name FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT name FROM shipments AS acct
WHERE value > (
    SELECT MIN(value) FROM customers AS shp
    WHERE shp.code = acct.code
);


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

SELECT name FROM employees AS schd
WHERE code IN (
    SELECT code FROM tasks AS lne
    WHERE lne.type = schd.type
);


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

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


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

SELECT code FROM branches AS rgn
WHERE salary > (
    SELECT MAX(value) FROM employees AS whs
    WHERE whs.status = rgn.status
);


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

SELECT amount FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.level = lne.level
);


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

SELECT code FROM customers AS empl
WHERE status IN (
    SELECT status FROM warehouses AS prod
    WHERE prod.id = empl.id
);


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

SELECT amount FROM tasks AS sale
WHERE amount > (
    SELECT COUNT(value) FROM products AS schd
    WHERE schd.id = sale.id
);


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

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


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

SELECT value FROM transactions AS srvc
WHERE salary > (
    SELECT COUNT(value) FROM orders AS emp
    WHERE emp.code = srvc.code
);


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

SELECT name FROM branches AS sale
WHERE value > (
    SELECT MAX(salary) FROM suppliers AS schd
    WHERE schd.id = sale.id
);


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

SELECT name FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.id = empl.id
);


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

SELECT code FROM orders AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS txn
    WHERE txn.code = rgn.code
);


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

SELECT amount FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.status = shp.status
);


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

SELECT amount FROM accounts AS dept
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS prod
    WHERE prod.id = dept.id
);


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

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


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

SELECT code FROM departments AS ordr
WHERE id IN (
    SELECT id FROM shipments AS txn
    WHERE txn.id = ordr.id
);


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

SELECT value FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT code FROM products AS schd
WHERE salary > (
    SELECT MAX(amount) FROM employees AS shp
    WHERE shp.code = schd.code
);


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

SELECT amount FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT name FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.code = cust.code
);


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

SELECT code FROM shipments AS lne
WHERE id IN (
    SELECT id FROM projects AS schd
    WHERE schd.id = lne.id
);


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

SELECT value FROM employees AS mgr
WHERE level IN (
    SELECT level FROM orders AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT amount FROM accounts AS prod
WHERE status IN (
    SELECT status FROM customers AS txn
    WHERE txn.level = prod.level
);


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

SELECT amount FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.type = srvc.type
);


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

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


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

SELECT salary FROM suppliers AS acct
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.type = acct.type
);


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

SELECT amount FROM projects AS sale
WHERE id IN (
    SELECT id FROM customers AS prod
    WHERE prod.level = sale.level
);


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

SELECT code FROM tasks AS prod
WHERE salary > (
    SELECT AVG(amount) FROM regions AS empl
    WHERE empl.type = prod.type
);


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

SELECT amount FROM products AS lne
WHERE id IN (
    SELECT id FROM branches AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT amount FROM suppliers AS prod
WHERE amount > (
    SELECT MIN(amount) FROM employees AS whs
    WHERE whs.level = prod.level
);


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

SELECT value FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM orders AS lne
    WHERE lne.status = ordr.status
);


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

SELECT amount FROM products AS prod
WHERE type IN (
    SELECT type FROM warehouses AS ord
    WHERE ord.id = prod.id
);


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

SELECT code FROM invoices AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS cust
    WHERE cust.status = inv.status
);


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

SELECT code FROM transactions AS inv
WHERE status IN (
    SELECT status FROM departments AS prod
    WHERE prod.type = inv.type
);


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

SELECT amount FROM shipments AS shp
WHERE status IN (
    SELECT status FROM branches AS sale
    WHERE sale.id = shp.id
);


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

SELECT value FROM accounts AS dept
WHERE id IN (
    SELECT id FROM projects AS cust
    WHERE cust.status = dept.status
);


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

SELECT value FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.status = inv.status
);


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

SELECT value FROM shipments AS prod
WHERE id IN (
    SELECT id FROM transactions AS acct
    WHERE acct.type = prod.type
);


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

SELECT salary FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.type = empl.type
);


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

SELECT name FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.level = txn.level
);


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

SELECT name FROM transactions AS shp
WHERE code IN (
    SELECT code FROM suppliers AS emp
    WHERE emp.level = shp.level
);


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

SELECT value FROM products AS rgn
WHERE code IN (
    SELECT code FROM regions AS prod
    WHERE prod.id = rgn.id
);


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

SELECT amount FROM orders AS txn
WHERE type IN (
    SELECT type FROM branches AS dept
    WHERE dept.level = txn.level
);


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

SELECT code FROM regions AS catg
WHERE level IN (
    SELECT level FROM transactions AS whs
    WHERE whs.level = catg.level
);


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

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


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

SELECT salary FROM invoices AS cust
WHERE value > (
    SELECT MIN(salary) FROM branches AS acct
    WHERE acct.code = cust.code
);


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

SELECT name FROM customers AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS whs
    WHERE whs.code = schd.code
);


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

SELECT code FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.id = shp.id
);


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

SELECT code FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.status = mgr.status
);


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

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


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

SELECT value FROM categories AS ordr
WHERE id IN (
    SELECT id FROM tasks AS emp
    WHERE emp.level = ordr.level
);


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

SELECT name FROM projects AS catg
WHERE code IN (
    SELECT code FROM tasks AS empl
    WHERE empl.id = catg.id
);


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

SELECT code FROM accounts AS whs
WHERE type IN (
    SELECT type FROM regions AS lne
    WHERE lne.code = whs.code
);


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

SELECT name FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.status = ordr.status
);


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

SELECT salary FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT code FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT code FROM employees AS mgr
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS txn
    WHERE txn.status = mgr.status
);


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

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


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

SELECT value FROM departments AS cust
WHERE type IN (
    SELECT type FROM projects AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT id FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.level = cust.level
);


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

SELECT value FROM tasks AS schd
WHERE salary > (
    SELECT MAX(salary) FROM projects AS budg
    WHERE budg.id = schd.id
);


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

SELECT id FROM branches AS empl
WHERE salary > (
    SELECT MAX(amount) FROM categories AS dept
    WHERE dept.status = empl.status
);


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

SELECT salary FROM customers AS prod
WHERE type IN (
    SELECT type FROM tasks AS lne
    WHERE lne.type = prod.type
);


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

SELECT code FROM categories AS shp
WHERE type IN (
    SELECT type FROM warehouses AS emp
    WHERE emp.level = shp.level
);


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

SELECT amount FROM products AS acct
WHERE status IN (
    SELECT status FROM invoices AS shp
    WHERE shp.status = acct.status
);


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

SELECT name FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.id = schd.id
);


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

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


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

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


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

SELECT amount FROM shipments AS acct
WHERE salary > (
    SELECT AVG(value) FROM invoices AS whs
    WHERE whs.level = acct.level
);


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

SELECT amount FROM branches AS empl
WHERE id IN (
    SELECT id FROM transactions AS lne
    WHERE lne.id = empl.id
);


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

SELECT name FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.code = shp.code
);


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

SELECT id FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.id = sale.id
);