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

SELECT amount FROM invoices AS prod
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS inv
    WHERE inv.code = prod.code
);


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

SELECT code FROM regions AS prod
WHERE value > (
    SELECT SUM(value) FROM invoices AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT code FROM accounts AS prod
WHERE value > (
    SELECT MAX(salary) FROM suppliers AS txn
    WHERE txn.id = prod.id
);


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

SELECT salary FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.code = prod.code
);


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

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


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

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


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

SELECT amount FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = whs.id
);


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

SELECT value FROM employees AS inv
WHERE type IN (
    SELECT type FROM categories AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT amount FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.code = txn.code
);


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

SELECT id FROM shipments AS emp
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS lne
    WHERE lne.status = emp.status
);


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

SELECT code FROM shipments AS whs
WHERE salary > (
    SELECT MIN(salary) FROM orders AS budg
    WHERE budg.id = whs.id
);


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

SELECT name FROM regions AS cust
WHERE type IN (
    SELECT type FROM suppliers AS dept
    WHERE dept.status = cust.status
);


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

SELECT value FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.type = prod.type
);


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

SELECT name FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.code = srvc.code
);


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

SELECT amount FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.type = whs.type
);


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

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


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

SELECT code FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.level = catg.level
);


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

SELECT value FROM suppliers AS sale
WHERE amount > (
    SELECT AVG(salary) FROM categories AS budg
    WHERE budg.level = sale.level
);


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

SELECT value FROM shipments AS shp
WHERE salary > (
    SELECT MAX(salary) FROM warehouses AS lne
    WHERE lne.status = shp.status
);


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

SELECT id FROM invoices AS budg
WHERE amount > (
    SELECT COUNT(value) FROM suppliers AS emp
    WHERE emp.level = budg.level
);


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

SELECT salary FROM projects AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM customers AS ordr
    WHERE ordr.status = mgr.status
);


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

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


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

SELECT code FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.id = dept.id
);


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

SELECT amount FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.level = txn.level
);


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

SELECT name FROM branches AS whs
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.level = whs.level
);


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

SELECT code FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.id = inv.id
);


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

SELECT id FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.code = inv.code
);


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

SELECT code FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.type = txn.type
);


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

SELECT code FROM shipments AS prod
WHERE level IN (
    SELECT level FROM regions AS whs
    WHERE whs.level = prod.level
);


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

SELECT name FROM branches AS mgr
WHERE id IN (
    SELECT id FROM accounts AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT id FROM tasks AS acct
WHERE salary > (
    SELECT MIN(salary) FROM orders AS sale
    WHERE sale.id = acct.id
);


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

SELECT salary FROM invoices AS sale
WHERE status IN (
    SELECT status FROM projects AS shp
    WHERE shp.status = sale.status
);


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

SELECT salary FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.id = rgn.id
);


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

SELECT amount FROM employees AS prod
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS emp
    WHERE emp.code = prod.code
);


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

SELECT value FROM shipments AS dept
WHERE code IN (
    SELECT code FROM branches AS txn
    WHERE txn.id = dept.id
);


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

SELECT value FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.code = whs.code
);


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

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


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

SELECT name FROM customers AS schd
WHERE value > (
    SELECT MAX(salary) FROM regions AS empl
    WHERE empl.status = schd.status
);


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

SELECT id FROM categories AS sale
WHERE value > (
    SELECT COUNT(salary) FROM regions AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT salary FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.level = dept.level
);


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

SELECT name FROM suppliers AS ord
WHERE value > (
    SELECT AVG(value) FROM categories AS sale
    WHERE sale.status = ord.status
);


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

SELECT name FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.level = lne.level
);


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

SELECT name FROM invoices AS lne
WHERE id IN (
    SELECT id FROM warehouses AS inv
    WHERE inv.id = lne.id
);


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

SELECT id FROM accounts AS empl
WHERE status IN (
    SELECT status FROM shipments AS inv
    WHERE inv.code = empl.code
);


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

SELECT amount FROM products AS inv
WHERE level IN (
    SELECT level FROM employees AS ord
    WHERE ord.type = inv.type
);


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

SELECT salary FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.level = empl.level
);


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

SELECT salary FROM warehouses AS rgn
WHERE value > (
    SELECT AVG(amount) FROM regions AS ord
    WHERE ord.type = rgn.type
);


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

SELECT name FROM customers AS txn
WHERE salary > (
    SELECT AVG(amount) FROM departments AS empl
    WHERE empl.level = txn.level
);


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

SELECT amount FROM suppliers AS dept
WHERE salary > (
    SELECT MIN(salary) FROM departments AS prod
    WHERE prod.code = dept.code
);


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

SELECT amount FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.id = acct.id
);


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

SELECT salary FROM branches AS srvc
WHERE level IN (
    SELECT level FROM departments AS lne
    WHERE lne.code = srvc.code
);


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

SELECT code FROM orders AS srvc
WHERE type IN (
    SELECT type FROM transactions AS cust
    WHERE cust.type = srvc.type
);


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

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


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

SELECT code FROM customers AS ord
WHERE salary > (
    SELECT AVG(value) FROM orders AS dept
    WHERE dept.code = ord.code
);


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

SELECT code FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.code = acct.code
);


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

SELECT amount FROM transactions AS sale
WHERE id IN (
    SELECT id FROM accounts AS mgr
    WHERE mgr.id = sale.id
);


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

SELECT name FROM regions AS sale
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.code = sale.code
);


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

SELECT name FROM transactions AS emp
WHERE id IN (
    SELECT id FROM customers AS inv
    WHERE inv.code = emp.code
);


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

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


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

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


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

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


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

SELECT salary FROM products AS ord
WHERE code IN (
    SELECT code FROM tasks AS emp
    WHERE emp.level = ord.level
);


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

SELECT salary FROM projects AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS empl
    WHERE empl.level = shp.level
);


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

SELECT salary FROM branches AS lne
WHERE type IN (
    SELECT type FROM employees AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT id FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.code = schd.code
);


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

SELECT id FROM departments AS sale
WHERE level IN (
    SELECT level FROM projects AS empl
    WHERE empl.code = sale.code
);


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

SELECT value FROM employees AS ord
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS txn
    WHERE txn.level = ord.level
);


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

SELECT name FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = inv.id
);


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

SELECT name FROM regions AS prod
WHERE value > (
    SELECT AVG(value) FROM warehouses AS schd
    WHERE schd.status = prod.status
);


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

SELECT salary FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.level = srvc.level
);


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

SELECT value FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.status = schd.status
);


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

SELECT code FROM regions AS schd
WHERE type IN (
    SELECT type FROM suppliers AS dept
    WHERE dept.level = schd.level
);


Prompt:
Schema:
  branches (alias: catg)(level, id, amount, status)
  invoices(id, name, status, value)
Task: Retrieve amount from branches with value above the SUM(amount) of invoices rows sharing the same status.
SQL:

SELECT amount FROM branches AS catg
WHERE value > (
    SELECT SUM(amount) FROM invoices AS mgr
    WHERE mgr.status = catg.status
);


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

SELECT value FROM regions AS sale
WHERE code IN (
    SELECT code FROM departments AS emp
    WHERE emp.id = sale.id
);


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

SELECT name FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.id = shp.id
);


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

SELECT amount FROM shipments AS emp
WHERE salary > (
    SELECT SUM(amount) FROM regions AS empl
    WHERE empl.type = emp.type
);


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

SELECT salary FROM tasks AS prod
WHERE value > (
    SELECT SUM(value) FROM projects AS sale
    WHERE sale.level = prod.level
);


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

SELECT value FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.status = budg.status
);


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

SELECT name FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.level = whs.level
);


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

SELECT salary FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.status = sale.status
);


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

SELECT amount FROM transactions AS budg
WHERE code IN (
    SELECT code FROM accounts AS dept
    WHERE dept.level = budg.level
);


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

SELECT value FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT id FROM tasks AS shp
WHERE value > (
    SELECT AVG(salary) FROM customers AS dept
    WHERE dept.level = shp.level
);


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

SELECT amount FROM invoices AS budg
WHERE amount > (
    SELECT COUNT(salary) FROM warehouses AS sale
    WHERE sale.status = budg.status
);


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

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


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

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


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

SELECT amount FROM employees AS prod
WHERE code IN (
    SELECT code FROM tasks AS catg
    WHERE catg.code = prod.code
);


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

SELECT id FROM shipments AS txn
WHERE value > (
    SELECT SUM(salary) FROM orders AS budg
    WHERE budg.code = txn.code
);


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

SELECT salary FROM branches AS budg
WHERE level IN (
    SELECT level FROM tasks AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT id FROM products AS shp
WHERE type IN (
    SELECT type FROM branches AS whs
    WHERE whs.code = shp.code
);


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

SELECT salary FROM shipments AS mgr
WHERE status IN (
    SELECT status FROM regions AS inv
    WHERE inv.type = mgr.type
);


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

SELECT amount FROM branches AS prod
WHERE type IN (
    SELECT type FROM accounts AS catg
    WHERE catg.type = prod.type
);


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

SELECT name FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.type = schd.type
);


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

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


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

SELECT value FROM invoices AS dept
WHERE code IN (
    SELECT code FROM employees AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT name FROM suppliers AS prod
WHERE salary > (
    SELECT SUM(salary) FROM shipments AS shp
    WHERE shp.type = prod.type
);


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

SELECT id FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.level = cust.level
);


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

SELECT code FROM suppliers AS empl
WHERE code IN (
    SELECT code FROM employees AS cust
    WHERE cust.level = empl.level
);


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

SELECT amount FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.code = cust.code
);


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

SELECT value FROM tasks AS inv
WHERE type IN (
    SELECT type FROM projects AS empl
    WHERE empl.code = inv.code
);


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

SELECT name FROM accounts AS shp
WHERE amount > (
    SELECT AVG(value) FROM products AS sale
    WHERE sale.code = shp.code
);


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

SELECT value FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT code FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.type = mgr.type
);


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

SELECT salary FROM tasks AS mgr
WHERE salary > (
    SELECT COUNT(amount) FROM orders AS empl
    WHERE empl.id = mgr.id
);


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

SELECT id FROM orders AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM warehouses AS ord
    WHERE ord.type = shp.type
);


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

SELECT salary FROM products AS dept
WHERE id IN (
    SELECT id FROM warehouses AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT name FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.id = ord.id
);


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

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


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

SELECT salary FROM tasks AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM products AS lne
    WHERE lne.status = mgr.status
);


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

SELECT amount FROM suppliers AS emp
WHERE salary > (
    SELECT AVG(salary) FROM regions AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT amount FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.level = budg.level
);


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

SELECT salary FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.level = lne.level
);


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

SELECT salary FROM tasks AS mgr
WHERE amount > (
    SELECT MAX(salary) FROM accounts AS prod
    WHERE prod.type = mgr.type
);


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

SELECT code FROM customers AS mgr
WHERE id IN (
    SELECT id FROM accounts AS emp
    WHERE emp.type = mgr.type
);


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

SELECT name FROM employees AS sale
WHERE value > (
    SELECT MIN(salary) FROM orders AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT value FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.type = sale.type
);


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

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


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

SELECT code FROM accounts AS sale
WHERE value > (
    SELECT MIN(amount) FROM orders AS srvc
    WHERE srvc.type = sale.type
);


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

SELECT id FROM suppliers AS srvc
WHERE id IN (
    SELECT id FROM tasks AS acct
    WHERE acct.status = srvc.status
);


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

SELECT id FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.code = mgr.code
);


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

SELECT salary FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.type = inv.type
);


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

SELECT id FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.code = srvc.code
);


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

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


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

SELECT code FROM transactions AS inv
WHERE status IN (
    SELECT status FROM categories AS ord
    WHERE ord.type = inv.type
);


Prompt:
Schema:
  regions (alias: dept)(id, code, value, level)
  warehouses(value, type, id, code)
Task: Find code from regions where a matching record exists in warehouses with the same type.
SQL:

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


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

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


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

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


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

SELECT value FROM invoices AS empl
WHERE salary > (
    SELECT AVG(amount) FROM branches AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT name FROM warehouses AS sale
WHERE value > (
    SELECT SUM(value) FROM departments AS empl
    WHERE empl.level = sale.level
);


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

SELECT salary FROM accounts AS budg
WHERE code IN (
    SELECT code FROM employees AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT salary FROM warehouses AS lne
WHERE salary > (
    SELECT SUM(salary) FROM products AS ordr
    WHERE ordr.code = lne.code
);


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

SELECT amount FROM invoices AS rgn
WHERE value > (
    SELECT AVG(value) FROM departments AS acct
    WHERE acct.type = rgn.type
);


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

SELECT amount FROM invoices AS lne
WHERE id IN (
    SELECT id FROM departments AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT code FROM transactions AS emp
WHERE status IN (
    SELECT status FROM invoices AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT name FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.code = lne.code
);


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

SELECT salary FROM invoices AS emp
WHERE value > (
    SELECT MAX(amount) FROM orders AS empl
    WHERE empl.id = emp.id
);


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

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


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

SELECT value FROM projects AS acct
WHERE level IN (
    SELECT level FROM departments AS empl
    WHERE empl.code = acct.code
);


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

SELECT amount FROM branches AS inv
WHERE value > (
    SELECT SUM(value) FROM shipments AS prod
    WHERE prod.id = inv.id
);


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

SELECT value FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT amount FROM orders AS inv
WHERE level IN (
    SELECT level FROM projects AS shp
    WHERE shp.code = inv.code
);


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

SELECT name FROM customers AS budg
WHERE code IN (
    SELECT code FROM transactions AS ordr
    WHERE ordr.status = budg.status
);


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

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


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

SELECT code FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = srvc.level
);


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

SELECT code FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.id = txn.id
);


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

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


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

SELECT amount FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.code = whs.code
);


Prompt:
Schema:
  categories (alias: ordr)(id, value, name, amount)
  shipments(amount, type, value, id)
Task: Retrieve id from categories with value above the SUM(salary) of shipments rows sharing the same status.
SQL:

SELECT id FROM categories AS ordr
WHERE value > (
    SELECT SUM(salary) FROM shipments AS ord
    WHERE ord.status = ordr.status
);


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

SELECT salary FROM invoices AS sale
WHERE level IN (
    SELECT level FROM suppliers AS inv
    WHERE inv.code = sale.code
);


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

SELECT id FROM orders AS lne
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS inv
    WHERE inv.type = lne.type
);


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

SELECT value FROM orders AS whs
WHERE type IN (
    SELECT type FROM regions AS lne
    WHERE lne.id = whs.id
);


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

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


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

SELECT salary FROM categories AS catg
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS schd
    WHERE schd.status = catg.status
);


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

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


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

SELECT value FROM regions AS prod
WHERE level IN (
    SELECT level FROM transactions AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT value FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT amount FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.code = inv.code
);


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

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


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

SELECT code FROM products AS dept
WHERE code IN (
    SELECT code FROM accounts AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT name FROM categories AS mgr
WHERE salary > (
    SELECT AVG(salary) FROM orders AS emp
    WHERE emp.code = mgr.code
);


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

SELECT amount FROM customers AS srvc
WHERE code IN (
    SELECT code FROM categories AS ord
    WHERE ord.status = srvc.status
);


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

SELECT id FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.type = acct.type
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.id = prod.id
);


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

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


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

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


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

SELECT name FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.id = whs.id
);


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

SELECT salary FROM employees AS txn
WHERE salary > (
    SELECT MAX(value) FROM transactions AS lne
    WHERE lne.status = txn.status
);


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

SELECT value FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = acct.type
);


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

SELECT value FROM tasks AS catg
WHERE salary > (
    SELECT SUM(salary) FROM orders AS lne
    WHERE lne.code = catg.code
);


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

SELECT id FROM employees AS acct
WHERE salary > (
    SELECT AVG(amount) FROM branches AS whs
    WHERE whs.type = acct.type
);


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

SELECT amount FROM invoices AS cust
WHERE salary > (
    SELECT AVG(value) FROM accounts AS schd
    WHERE schd.level = cust.level
);


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

SELECT amount FROM projects AS sale
WHERE status IN (
    SELECT status FROM employees AS txn
    WHERE txn.id = sale.id
);


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

SELECT value FROM employees AS catg
WHERE amount > (
    SELECT MAX(amount) FROM suppliers AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT name FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.status = srvc.status
);


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

SELECT code FROM invoices AS dept
WHERE level IN (
    SELECT level FROM transactions AS rgn
    WHERE rgn.id = dept.id
);


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

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


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

SELECT code FROM tasks AS ord
WHERE salary > (
    SELECT SUM(amount) FROM projects AS whs
    WHERE whs.type = ord.type
);


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

SELECT amount FROM projects AS shp
WHERE type IN (
    SELECT type FROM orders AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT salary FROM regions AS ordr
WHERE value > (
    SELECT SUM(value) FROM branches AS cust
    WHERE cust.status = ordr.status
);


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

SELECT code FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT name FROM orders AS acct
WHERE type IN (
    SELECT type FROM invoices AS lne
    WHERE lne.id = acct.id
);


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

SELECT value FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.level = shp.level
);


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

SELECT value FROM branches AS dept
WHERE id IN (
    SELECT id FROM categories AS cust
    WHERE cust.level = dept.level
);


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

SELECT value FROM employees AS schd
WHERE level IN (
    SELECT level FROM orders AS srvc
    WHERE srvc.type = schd.type
);


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

SELECT name FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.level = acct.level
);


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

SELECT name FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.code = dept.code
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.type = dept.type
);


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

SELECT name FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.type = ordr.type
);


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

SELECT salary FROM transactions AS prod
WHERE id IN (
    SELECT id FROM departments AS txn
    WHERE txn.status = prod.status
);


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

SELECT value FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.level = prod.level
);


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

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


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

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


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

SELECT name FROM regions AS dept
WHERE type IN (
    SELECT type FROM accounts AS prod
    WHERE prod.level = dept.level
);


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

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


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

SELECT value FROM tasks AS mgr
WHERE value > (
    SELECT COUNT(value) FROM projects AS shp
    WHERE shp.code = mgr.code
);


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

SELECT salary FROM orders AS srvc
WHERE type IN (
    SELECT type FROM transactions AS lne
    WHERE lne.status = srvc.status
);


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

SELECT code FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.status = prod.status
);


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

SELECT name FROM tasks AS schd
WHERE code IN (
    SELECT code FROM accounts AS txn
    WHERE txn.id = schd.id
);


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

SELECT name FROM regions AS ordr
WHERE value > (
    SELECT SUM(salary) FROM shipments AS txn
    WHERE txn.status = ordr.status
);


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

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


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

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


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

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


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

SELECT name FROM suppliers AS budg
WHERE value > (
    SELECT AVG(amount) FROM orders AS emp
    WHERE emp.code = budg.code
);


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

SELECT value FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = rgn.type
);


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

SELECT amount FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.code = acct.code
);


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

SELECT amount FROM accounts AS acct
WHERE status IN (
    SELECT status FROM branches AS budg
    WHERE budg.type = acct.type
);


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

SELECT name FROM branches AS acct
WHERE code IN (
    SELECT code FROM warehouses AS dept
    WHERE dept.level = acct.level
);


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

SELECT amount FROM employees AS budg
WHERE amount > (
    SELECT SUM(salary) FROM branches AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT value FROM transactions AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS ordr
    WHERE ordr.id = catg.id
);


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

SELECT value FROM projects AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS emp
    WHERE emp.level = mgr.level
);


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

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


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

SELECT value FROM products AS schd
WHERE amount > (
    SELECT SUM(amount) FROM employees AS ord
    WHERE ord.level = schd.level
);


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

SELECT name FROM tasks AS sale
WHERE value > (
    SELECT MAX(salary) FROM shipments AS emp
    WHERE emp.level = sale.level
);


Prompt:
Schema:
  products (alias: mgr)(salary, code, name, value)
  projects(id, name, salary, value)
Task: Retrieve name from products with value above the MIN(value) of projects rows sharing the same level.
SQL:

SELECT name FROM products AS mgr
WHERE value > (
    SELECT MIN(value) FROM projects AS txn
    WHERE txn.level = mgr.level
);


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.status = rgn.status
);


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

SELECT amount FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.type = ord.type
);


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

SELECT id FROM transactions AS shp
WHERE value > (
    SELECT MIN(salary) FROM orders AS ord
    WHERE ord.type = shp.type
);


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

SELECT amount FROM orders AS whs
WHERE amount > (
    SELECT MAX(value) FROM products AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT code FROM customers AS whs
WHERE code IN (
    SELECT code FROM products AS prod
    WHERE prod.level = whs.level
);


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

SELECT amount FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.code = inv.code
);


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

SELECT value FROM projects AS budg
WHERE type IN (
    SELECT type FROM accounts AS dept
    WHERE dept.status = budg.status
);


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

SELECT salary FROM tasks AS empl
WHERE type IN (
    SELECT type FROM projects AS budg
    WHERE budg.type = empl.type
);


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

SELECT id FROM regions AS acct
WHERE salary > (
    SELECT MIN(salary) FROM projects AS srvc
    WHERE srvc.code = acct.code
);


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

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


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

SELECT id FROM projects AS ord
WHERE salary > (
    SELECT MIN(value) FROM shipments AS txn
    WHERE txn.status = ord.status
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.id = srvc.id
);


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

SELECT name FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.level = shp.level
);


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

SELECT amount FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.level = catg.level
);


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

SELECT code FROM branches AS acct
WHERE amount > (
    SELECT AVG(value) FROM departments AS sale
    WHERE sale.id = acct.id
);


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

SELECT id FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.type = empl.type
);


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

SELECT salary FROM transactions AS whs
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS prod
    WHERE prod.level = whs.level
);


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

SELECT value FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.level = budg.level
);


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

SELECT amount FROM shipments AS dept
WHERE amount > (
    SELECT AVG(salary) FROM branches AS cust
    WHERE cust.status = dept.status
);


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

SELECT value FROM warehouses AS dept
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.code = dept.code
);


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

SELECT amount FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = txn.level
);


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

SELECT name FROM departments AS cust
WHERE status IN (
    SELECT status FROM transactions AS catg
    WHERE catg.level = cust.level
);


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

SELECT salary FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.id = mgr.id
);


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

SELECT value FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.status = schd.status
);


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

SELECT amount FROM shipments AS whs
WHERE id IN (
    SELECT id FROM regions AS lne
    WHERE lne.status = whs.status
);


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

SELECT amount FROM suppliers AS ordr
WHERE id IN (
    SELECT id FROM departments AS prod
    WHERE prod.id = ordr.id
);


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

SELECT name FROM regions AS mgr
WHERE status IN (
    SELECT status FROM shipments AS sale
    WHERE sale.type = mgr.type
);


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

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


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

SELECT salary FROM branches AS txn
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS cust
    WHERE cust.type = txn.type
);


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

SELECT name FROM products AS ord
WHERE value > (
    SELECT MAX(value) FROM regions AS sale
    WHERE sale.type = ord.type
);


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

SELECT id FROM transactions AS catg
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS acct
    WHERE acct.code = catg.code
);


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

SELECT salary FROM branches AS budg
WHERE salary > (
    SELECT MIN(value) FROM departments AS sale
    WHERE sale.status = budg.status
);


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

SELECT code FROM employees AS whs
WHERE salary > (
    SELECT MIN(salary) FROM products AS mgr
    WHERE mgr.status = whs.status
);


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

SELECT code FROM categories AS sale
WHERE amount > (
    SELECT MAX(salary) FROM orders AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.id = rgn.id
);


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

SELECT value FROM orders AS mgr
WHERE id IN (
    SELECT id FROM warehouses AS inv
    WHERE inv.level = mgr.level
);


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

SELECT value FROM projects AS shp
WHERE value > (
    SELECT MIN(salary) FROM warehouses AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT name FROM suppliers AS empl
WHERE value > (
    SELECT MIN(value) FROM categories AS emp
    WHERE emp.type = empl.type
);


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

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


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

SELECT amount FROM tasks AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM products AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT salary FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.code = acct.code
);


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

SELECT id FROM accounts AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS lne
    WHERE lne.code = shp.code
);


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

SELECT name FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.id = emp.id
);


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

SELECT value FROM products AS shp
WHERE code IN (
    SELECT code FROM shipments AS ord
    WHERE ord.code = shp.code
);


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

SELECT name FROM tasks AS prod
WHERE status IN (
    SELECT status FROM regions AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT code FROM shipments AS prod
WHERE value > (
    SELECT AVG(value) FROM accounts AS schd
    WHERE schd.level = prod.level
);


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

SELECT id FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT name FROM orders AS inv
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS sale
    WHERE sale.code = inv.code
);


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

SELECT name FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.id = mgr.id
);


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

SELECT name FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.id = acct.id
);


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

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


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

SELECT amount FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.type = ord.type
);


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

SELECT amount FROM products AS ordr
WHERE status IN (
    SELECT status FROM branches AS empl
    WHERE empl.id = ordr.id
);


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

SELECT salary FROM accounts AS schd
WHERE code IN (
    SELECT code FROM warehouses AS acct
    WHERE acct.id = schd.id
);


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

SELECT salary FROM categories AS catg
WHERE amount > (
    SELECT SUM(salary) FROM regions AS sale
    WHERE sale.code = catg.code
);


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

SELECT id FROM transactions AS catg
WHERE code IN (
    SELECT code FROM shipments AS rgn
    WHERE rgn.id = catg.id
);


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

SELECT name FROM warehouses AS srvc
WHERE id IN (
    SELECT id FROM customers AS rgn
    WHERE rgn.id = srvc.id
);


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

SELECT value FROM accounts AS prod
WHERE id IN (
    SELECT id FROM customers AS budg
    WHERE budg.level = prod.level
);


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

SELECT value FROM customers AS sale
WHERE status IN (
    SELECT status FROM branches AS emp
    WHERE emp.level = sale.level
);


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

SELECT amount FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT salary FROM departments AS shp
WHERE level IN (
    SELECT level FROM branches AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT salary FROM departments AS ordr
WHERE id IN (
    SELECT id FROM warehouses AS ord
    WHERE ord.id = ordr.id
);


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

SELECT salary FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = prod.level
);


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

SELECT name FROM transactions AS shp
WHERE status IN (
    SELECT status FROM invoices AS ordr
    WHERE ordr.code = shp.code
);


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

SELECT salary FROM orders AS dept
WHERE salary > (
    SELECT MIN(amount) FROM employees AS cust
    WHERE cust.id = dept.id
);


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

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


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

SELECT id FROM warehouses AS prod
WHERE type IN (
    SELECT type FROM products AS dept
    WHERE dept.status = prod.status
);


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

SELECT name FROM projects AS ord
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT amount FROM warehouses AS acct
WHERE amount > (
    SELECT MAX(amount) FROM categories AS whs
    WHERE whs.level = acct.level
);


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

SELECT code FROM regions AS acct
WHERE type IN (
    SELECT type FROM branches AS whs
    WHERE whs.level = acct.level
);


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

SELECT value FROM invoices AS whs
WHERE value > (
    SELECT AVG(value) FROM products AS acct
    WHERE acct.id = whs.id
);


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

SELECT amount FROM customers AS inv
WHERE code IN (
    SELECT code FROM shipments AS ord
    WHERE ord.id = inv.id
);


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

SELECT amount FROM regions AS rgn
WHERE id IN (
    SELECT id FROM tasks AS catg
    WHERE catg.type = rgn.type
);


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

SELECT id FROM customers AS budg
WHERE status IN (
    SELECT status FROM employees AS empl
    WHERE empl.id = budg.id
);


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

SELECT id FROM projects AS ordr
WHERE level IN (
    SELECT level FROM warehouses AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT amount FROM branches AS prod
WHERE value > (
    SELECT COUNT(salary) FROM customers AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT name FROM products AS prod
WHERE amount > (
    SELECT MAX(salary) FROM departments AS whs
    WHERE whs.level = prod.level
);


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

SELECT name FROM warehouses AS budg
WHERE value > (
    SELECT MAX(value) FROM branches AS txn
    WHERE txn.level = budg.level
);


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

SELECT code FROM products AS catg
WHERE code IN (
    SELECT code FROM suppliers AS prod
    WHERE prod.code = catg.code
);