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

SELECT name FROM accounts AS acct
WHERE code IN (
    SELECT code FROM projects AS dept
    WHERE dept.code = acct.code
);


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

SELECT name FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.level = catg.level
);


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

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


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

SELECT value FROM categories AS shp
WHERE value > (
    SELECT AVG(salary) FROM accounts AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT code FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.id = emp.id
);


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

SELECT name FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.type = empl.type
);


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

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


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

SELECT id FROM regions AS lne
WHERE status IN (
    SELECT status FROM branches AS mgr
    WHERE mgr.level = lne.level
);


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

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


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

SELECT id FROM products AS emp
WHERE level IN (
    SELECT level FROM transactions AS ord
    WHERE ord.id = emp.id
);


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

SELECT value FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.code = ordr.code
);


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.code = empl.code
);


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

SELECT amount FROM employees AS whs
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS emp
    WHERE emp.id = whs.id
);


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

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


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

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


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

SELECT id FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.code = schd.code
);


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

SELECT name FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM products AS srvc
    WHERE srvc.level = budg.level
);


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

SELECT amount FROM invoices AS acct
WHERE value > (
    SELECT MIN(value) FROM orders AS shp
    WHERE shp.status = acct.status
);


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

SELECT value FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.level = srvc.level
);


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

SELECT amount FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = emp.code
);


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

SELECT value FROM products AS budg
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS empl
    WHERE empl.level = budg.level
);


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

SELECT value FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.type = prod.type
);


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

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


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

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


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

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


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

SELECT name FROM employees AS empl
WHERE salary > (
    SELECT MAX(value) FROM tasks AS cust
    WHERE cust.level = empl.level
);


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

SELECT name FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.status = empl.status
);


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

SELECT id FROM accounts AS catg
WHERE amount > (
    SELECT MAX(value) FROM tasks AS txn
    WHERE txn.type = catg.type
);


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

SELECT value FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.type = mgr.type
);


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

SELECT code FROM regions AS ord
WHERE salary > (
    SELECT MAX(value) FROM employees AS dept
    WHERE dept.code = ord.code
);


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

SELECT name FROM departments AS cust
WHERE level IN (
    SELECT level FROM accounts AS lne
    WHERE lne.id = cust.id
);


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

SELECT id FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.id = emp.id
);


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

SELECT name FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.code = ordr.code
);


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

SELECT name FROM accounts AS txn
WHERE code IN (
    SELECT code FROM transactions AS shp
    WHERE shp.type = txn.type
);


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

SELECT code FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.type = prod.type
);


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

SELECT amount FROM tasks AS ordr
WHERE type IN (
    SELECT type FROM accounts AS acct
    WHERE acct.code = ordr.code
);


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

SELECT code FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.id = inv.id
);


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

SELECT amount FROM tasks AS inv
WHERE amount > (
    SELECT MIN(amount) FROM departments AS lne
    WHERE lne.type = inv.type
);


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

SELECT id FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT code FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.type = rgn.type
);


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

SELECT code FROM customers AS acct
WHERE type IN (
    SELECT type FROM invoices AS budg
    WHERE budg.id = acct.id
);


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

SELECT code FROM tasks AS whs
WHERE salary > (
    SELECT MAX(value) FROM categories AS cust
    WHERE cust.type = whs.type
);


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

SELECT amount FROM projects AS cust
WHERE status IN (
    SELECT status FROM suppliers AS empl
    WHERE empl.level = cust.level
);


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

SELECT salary FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.code = empl.code
);


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

SELECT amount FROM orders AS catg
WHERE level IN (
    SELECT level FROM products AS lne
    WHERE lne.id = catg.id
);


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

SELECT code FROM customers AS txn
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS lne
    WHERE lne.type = txn.type
);


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

SELECT name FROM transactions AS prod
WHERE status IN (
    SELECT status FROM projects AS budg
    WHERE budg.type = prod.type
);


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

SELECT name FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.type = cust.type
);


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

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


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

SELECT id FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.level = whs.level
);


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

SELECT salary FROM suppliers AS acct
WHERE code IN (
    SELECT code FROM branches AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT name FROM customers AS whs
WHERE type IN (
    SELECT type FROM projects AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT value FROM orders AS emp
WHERE status IN (
    SELECT status FROM employees AS ord
    WHERE ord.id = emp.id
);


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

SELECT salary FROM transactions AS shp
WHERE level IN (
    SELECT level FROM tasks AS rgn
    WHERE rgn.type = shp.type
);


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

SELECT amount FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.status = mgr.status
);


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

SELECT value FROM products AS budg
WHERE value > (
    SELECT MIN(amount) FROM departments AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT name FROM departments AS emp
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS empl
    WHERE empl.code = emp.code
);


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

SELECT code FROM products AS cust
WHERE id IN (
    SELECT id FROM accounts AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT value FROM transactions AS mgr
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS empl
    WHERE empl.type = mgr.type
);


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

SELECT value FROM transactions AS schd
WHERE value > (
    SELECT AVG(value) FROM products AS empl
    WHERE empl.code = schd.code
);


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

SELECT value FROM departments AS shp
WHERE value > (
    SELECT MAX(amount) FROM shipments AS whs
    WHERE whs.status = shp.status
);


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

SELECT code FROM warehouses AS budg
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.status = budg.status
);


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

SELECT salary FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.code = catg.code
);


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

SELECT id FROM customers AS srvc
WHERE value > (
    SELECT COUNT(salary) FROM warehouses AS whs
    WHERE whs.status = srvc.status
);


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

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


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

SELECT salary FROM suppliers AS schd
WHERE status IN (
    SELECT status FROM tasks AS budg
    WHERE budg.level = schd.level
);


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

SELECT name FROM tasks AS dept
WHERE level IN (
    SELECT level FROM regions AS emp
    WHERE emp.level = dept.level
);


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

SELECT name FROM transactions AS inv
WHERE id IN (
    SELECT id FROM departments AS acct
    WHERE acct.code = inv.code
);


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

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


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

SELECT id FROM products AS rgn
WHERE value > (
    SELECT SUM(value) FROM transactions AS txn
    WHERE txn.level = rgn.level
);


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

SELECT code FROM suppliers AS rgn
WHERE code IN (
    SELECT code FROM employees AS whs
    WHERE whs.code = rgn.code
);


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

SELECT name FROM products AS emp
WHERE salary > (
    SELECT MAX(value) FROM shipments AS inv
    WHERE inv.code = emp.code
);


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

SELECT amount FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.id = shp.id
);


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

SELECT salary FROM projects AS sale
WHERE level IN (
    SELECT level FROM employees AS catg
    WHERE catg.code = sale.code
);


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

SELECT value FROM regions AS dept
WHERE status IN (
    SELECT status FROM warehouses AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT name FROM products AS sale
WHERE salary > (
    SELECT MIN(salary) FROM departments AS srvc
    WHERE srvc.level = sale.level
);


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

SELECT code FROM regions AS sale
WHERE id IN (
    SELECT id FROM tasks AS whs
    WHERE whs.status = sale.status
);


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

SELECT value FROM invoices AS acct
WHERE amount > (
    SELECT MAX(amount) FROM regions AS shp
    WHERE shp.code = acct.code
);


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

SELECT value FROM customers AS cust
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS emp
    WHERE emp.status = cust.status
);


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

SELECT amount FROM projects AS mgr
WHERE value > (
    SELECT MAX(value) FROM suppliers AS sale
    WHERE sale.id = mgr.id
);


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

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


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

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


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

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


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

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


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

SELECT code FROM employees AS budg
WHERE level IN (
    SELECT level FROM branches AS catg
    WHERE catg.level = budg.level
);


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

SELECT value FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT value FROM customers AS prod
WHERE type IN (
    SELECT type FROM orders AS schd
    WHERE schd.id = prod.id
);


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

SELECT code FROM regions AS whs
WHERE status IN (
    SELECT status FROM invoices AS dept
    WHERE dept.code = whs.code
);


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

SELECT value FROM invoices AS catg
WHERE type IN (
    SELECT type FROM regions AS inv
    WHERE inv.type = catg.type
);


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

SELECT amount FROM shipments AS sale
WHERE status IN (
    SELECT status FROM tasks AS cust
    WHERE cust.id = sale.id
);


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

SELECT amount FROM regions AS prod
WHERE status IN (
    SELECT status FROM invoices AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT value FROM orders AS empl
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.level = empl.level
);


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

SELECT id FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.code = cust.code
);


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

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


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

SELECT name FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.code = emp.code
);


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

SELECT name FROM accounts AS cust
WHERE status IN (
    SELECT status FROM products AS inv
    WHERE inv.status = cust.status
);


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

SELECT id FROM employees AS shp
WHERE code IN (
    SELECT code FROM departments AS budg
    WHERE budg.status = shp.status
);


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

SELECT name FROM invoices AS inv
WHERE salary > (
    SELECT AVG(salary) FROM customers AS ord
    WHERE ord.code = inv.code
);


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

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


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

SELECT id FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.type = catg.type
);


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

SELECT value FROM transactions AS rgn
WHERE status IN (
    SELECT status FROM customers AS budg
    WHERE budg.status = rgn.status
);


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

SELECT value FROM tasks AS lne
WHERE status IN (
    SELECT status FROM invoices AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT amount FROM suppliers AS inv
WHERE status IN (
    SELECT status FROM warehouses AS cust
    WHERE cust.type = inv.type
);


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

SELECT id FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.level = txn.level
);


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

SELECT value FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.level = ord.level
);


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

SELECT amount FROM employees AS whs
WHERE value > (
    SELECT COUNT(salary) FROM products AS inv
    WHERE inv.id = whs.id
);


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

SELECT salary FROM invoices AS emp
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.code = emp.code
);


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

SELECT name FROM branches AS ordr
WHERE status IN (
    SELECT status FROM departments AS schd
    WHERE schd.type = ordr.type
);


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

SELECT id FROM categories AS catg
WHERE amount > (
    SELECT MAX(value) FROM products AS shp
    WHERE shp.type = catg.type
);


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

SELECT value FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.id = schd.id
);


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

SELECT salary FROM departments AS prod
WHERE amount > (
    SELECT SUM(value) FROM transactions AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT salary FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.code = txn.code
);


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

SELECT id FROM accounts AS empl
WHERE value > (
    SELECT MAX(amount) FROM customers AS shp
    WHERE shp.code = empl.code
);


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

SELECT value FROM projects AS srvc
WHERE type IN (
    SELECT type FROM transactions AS sale
    WHERE sale.code = srvc.code
);


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

SELECT salary FROM accounts AS schd
WHERE amount > (
    SELECT SUM(salary) FROM regions AS budg
    WHERE budg.status = schd.status
);


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

SELECT salary FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.level = catg.level
);


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

SELECT salary FROM regions AS empl
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS emp
    WHERE emp.code = empl.code
);


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

SELECT id FROM projects AS txn
WHERE salary > (
    SELECT AVG(amount) FROM branches AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT id FROM projects AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM employees AS cust
    WHERE cust.type = ordr.type
);


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

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


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

SELECT id FROM customers AS whs
WHERE level IN (
    SELECT level FROM transactions AS srvc
    WHERE srvc.status = whs.status
);


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

SELECT code FROM invoices AS catg
WHERE salary > (
    SELECT SUM(value) FROM customers AS shp
    WHERE shp.status = catg.status
);


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

SELECT value FROM categories AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT salary FROM branches AS prod
WHERE amount > (
    SELECT AVG(amount) FROM departments AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT code FROM customers AS mgr
WHERE amount > (
    SELECT AVG(value) FROM categories AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT value FROM suppliers AS catg
WHERE value > (
    SELECT AVG(value) FROM employees AS ord
    WHERE ord.level = catg.level
);


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

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


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

SELECT name FROM warehouses AS txn
WHERE status IN (
    SELECT status FROM branches AS cust
    WHERE cust.id = txn.id
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.code = shp.code
);


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

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


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

SELECT name FROM transactions AS whs
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT code FROM employees AS cust
WHERE value > (
    SELECT SUM(amount) FROM accounts AS emp
    WHERE emp.level = cust.level
);


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

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


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

SELECT code FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.code = empl.code
);


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

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


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

SELECT code FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.level = rgn.level
);


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

SELECT value FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = whs.level
);


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

SELECT salary FROM invoices AS mgr
WHERE value > (
    SELECT MIN(salary) FROM warehouses AS whs
    WHERE whs.type = mgr.type
);


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

SELECT name FROM shipments AS sale
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.type = sale.type
);


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

SELECT name FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = inv.level
);


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

SELECT amount FROM orders AS txn
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS ord
    WHERE ord.type = txn.type
);


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

SELECT salary FROM branches AS inv
WHERE value > (
    SELECT MIN(salary) FROM warehouses AS shp
    WHERE shp.code = inv.code
);


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

SELECT amount FROM tasks AS emp
WHERE value > (
    SELECT MIN(salary) FROM regions AS rgn
    WHERE rgn.id = emp.id
);


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

SELECT amount FROM tasks AS catg
WHERE value > (
    SELECT MAX(value) FROM departments AS dept
    WHERE dept.id = catg.id
);


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

SELECT code FROM shipments AS whs
WHERE salary > (
    SELECT SUM(amount) FROM departments AS emp
    WHERE emp.id = whs.id
);


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

SELECT amount FROM transactions AS cust
WHERE type IN (
    SELECT type FROM orders AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT amount FROM shipments AS txn
WHERE level IN (
    SELECT level FROM projects AS lne
    WHERE lne.level = txn.level
);


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

SELECT name FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.id = emp.id
);


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

SELECT id FROM orders AS srvc
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.id = srvc.id
);


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

SELECT amount FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = srvc.type
);


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

SELECT salary FROM accounts AS catg
WHERE level IN (
    SELECT level FROM suppliers AS mgr
    WHERE mgr.status = catg.status
);


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

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


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

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


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

SELECT amount FROM departments AS lne
WHERE salary > (
    SELECT MIN(value) FROM categories AS ord
    WHERE ord.level = lne.level
);


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

SELECT amount FROM invoices AS cust
WHERE status IN (
    SELECT status FROM accounts AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT code FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.level = budg.level
);


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

SELECT code FROM categories AS inv
WHERE value > (
    SELECT COUNT(salary) FROM departments AS empl
    WHERE empl.status = inv.status
);


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

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


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

SELECT amount FROM projects AS catg
WHERE id IN (
    SELECT id FROM categories AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT name FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.id = emp.id
);


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

SELECT name FROM warehouses AS shp
WHERE amount > (
    SELECT MAX(salary) FROM projects AS ord
    WHERE ord.type = shp.type
);


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

SELECT id FROM warehouses AS srvc
WHERE level IN (
    SELECT level FROM shipments AS txn
    WHERE txn.id = srvc.id
);


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

SELECT code FROM branches AS acct
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS whs
    WHERE whs.type = acct.type
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT id FROM projects AS emp
WHERE type IN (
    SELECT type FROM branches AS acct
    WHERE acct.status = emp.status
);


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

SELECT amount FROM transactions AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS empl
    WHERE empl.status = ord.status
);


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

SELECT id FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = dept.type
);


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

SELECT salary FROM suppliers AS lne
WHERE amount > (
    SELECT AVG(amount) FROM regions AS mgr
    WHERE mgr.level = lne.level
);


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

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


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

SELECT name FROM invoices AS mgr
WHERE salary > (
    SELECT SUM(value) FROM regions AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT name FROM categories AS prod
WHERE level IN (
    SELECT level FROM accounts AS sale
    WHERE sale.id = prod.id
);


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

SELECT amount FROM customers AS mgr
WHERE value > (
    SELECT SUM(value) FROM accounts AS cust
    WHERE cust.status = mgr.status
);


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

SELECT value FROM customers AS budg
WHERE value > (
    SELECT SUM(amount) FROM departments AS whs
    WHERE whs.type = budg.type
);


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

SELECT amount FROM shipments AS prod
WHERE salary > (
    SELECT COUNT(value) FROM suppliers AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT value FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.type = lne.type
);


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

SELECT amount FROM projects AS srvc
WHERE id IN (
    SELECT id FROM tasks AS sale
    WHERE sale.level = srvc.level
);


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

SELECT amount FROM departments AS sale
WHERE status IN (
    SELECT status FROM tasks AS txn
    WHERE txn.id = sale.id
);


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

SELECT id FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.id = rgn.id
);


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

SELECT name FROM suppliers AS txn
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS emp
    WHERE emp.code = txn.code
);


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

SELECT code FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.id = cust.id
);


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

SELECT id FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.id = rgn.id
);


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

SELECT value FROM transactions AS ord
WHERE value > (
    SELECT SUM(amount) FROM orders AS emp
    WHERE emp.status = ord.status
);


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

SELECT id FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.status = sale.status
);


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

SELECT code FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.code = acct.code
);


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

SELECT id FROM tasks AS rgn
WHERE code IN (
    SELECT code FROM invoices AS budg
    WHERE budg.type = rgn.type
);


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

SELECT name FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT salary FROM warehouses AS schd
WHERE level IN (
    SELECT level FROM customers AS dept
    WHERE dept.code = schd.code
);


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

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


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

SELECT code FROM departments AS shp
WHERE status IN (
    SELECT status FROM suppliers AS cust
    WHERE cust.id = shp.id
);


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

SELECT id FROM branches AS prod
WHERE value > (
    SELECT COUNT(value) FROM shipments AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT salary FROM suppliers AS schd
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.code = schd.code
);


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

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


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

SELECT name FROM customers AS txn
WHERE status IN (
    SELECT status FROM warehouses AS cust
    WHERE cust.id = txn.id
);


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

SELECT name FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.type = empl.type
);


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

SELECT amount FROM departments AS ord
WHERE value > (
    SELECT MAX(value) FROM products AS catg
    WHERE catg.code = ord.code
);


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

SELECT code FROM invoices AS emp
WHERE amount > (
    SELECT MIN(amount) FROM branches AS schd
    WHERE schd.code = emp.code
);


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

SELECT id FROM warehouses AS acct
WHERE code IN (
    SELECT code FROM shipments AS lne
    WHERE lne.status = acct.status
);


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

SELECT value FROM regions AS catg
WHERE status IN (
    SELECT status FROM suppliers AS emp
    WHERE emp.level = catg.level
);


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

SELECT amount FROM projects AS acct
WHERE type IN (
    SELECT type FROM accounts AS shp
    WHERE shp.code = acct.code
);


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

SELECT code FROM suppliers AS budg
WHERE level IN (
    SELECT level FROM tasks AS ord
    WHERE ord.id = budg.id
);


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

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


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

SELECT code FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT value FROM tasks AS lne
WHERE value > (
    SELECT MAX(salary) FROM projects AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT value FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.id = emp.id
);


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

SELECT value FROM products AS catg
WHERE id IN (
    SELECT id FROM transactions AS txn
    WHERE txn.code = catg.code
);


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

SELECT id FROM transactions AS sale
WHERE amount > (
    SELECT SUM(salary) FROM products AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT value FROM transactions AS acct
WHERE value > (
    SELECT AVG(value) FROM suppliers AS budg
    WHERE budg.code = acct.code
);


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

SELECT code FROM orders AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS sale
    WHERE sale.status = rgn.status
);


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

SELECT salary FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.status = empl.status
);


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

SELECT id FROM suppliers AS dept
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS inv
    WHERE inv.code = dept.code
);


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

SELECT id FROM shipments AS txn
WHERE id IN (
    SELECT id FROM warehouses AS inv
    WHERE inv.status = txn.status
);


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

SELECT id FROM shipments AS schd
WHERE salary > (
    SELECT SUM(amount) FROM projects AS emp
    WHERE emp.level = schd.level
);


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

SELECT id FROM regions AS ord
WHERE status IN (
    SELECT status FROM employees AS schd
    WHERE schd.type = ord.type
);


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

SELECT code FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.code = lne.code
);


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

SELECT salary FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.code = cust.code
);


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

SELECT amount FROM invoices AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS dept
    WHERE dept.level = ordr.level
);


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

SELECT id FROM suppliers AS catg
WHERE id IN (
    SELECT id FROM shipments AS emp
    WHERE emp.type = catg.type
);


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

SELECT code FROM shipments AS whs
WHERE status IN (
    SELECT status FROM departments AS lne
    WHERE lne.status = whs.status
);


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

SELECT code FROM warehouses AS schd
WHERE type IN (
    SELECT type FROM transactions AS acct
    WHERE acct.status = schd.status
);


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

SELECT value FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.id = schd.id
);


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

SELECT code FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.level = empl.level
);


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

SELECT id FROM categories AS txn
WHERE code IN (
    SELECT code FROM orders AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT id FROM tasks AS ord
WHERE status IN (
    SELECT status FROM orders AS catg
    WHERE catg.level = ord.level
);


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

SELECT salary FROM warehouses AS prod
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.code = prod.code
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.id = prod.id
);


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

SELECT value FROM customers AS sale
WHERE salary > (
    SELECT MIN(value) FROM tasks AS srvc
    WHERE srvc.level = sale.level
);


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

SELECT amount FROM products AS emp
WHERE salary > (
    SELECT MAX(value) FROM tasks AS prod
    WHERE prod.type = emp.type
);


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

SELECT id FROM tasks AS inv
WHERE value > (
    SELECT AVG(salary) FROM shipments AS ordr
    WHERE ordr.code = inv.code
);


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

SELECT value FROM categories AS inv
WHERE id IN (
    SELECT id FROM tasks AS acct
    WHERE acct.type = inv.type
);


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

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


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

SELECT name FROM branches AS ord
WHERE type IN (
    SELECT type FROM products AS schd
    WHERE schd.type = ord.type
);


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

SELECT name FROM products AS emp
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS lne
    WHERE lne.id = emp.id
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.level = acct.level
);


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

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


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

SELECT id FROM invoices AS cust
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT amount FROM customers AS prod
WHERE status IN (
    SELECT status FROM suppliers AS shp
    WHERE shp.id = prod.id
);


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

SELECT salary FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.code = empl.code
);


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

SELECT name FROM invoices AS emp
WHERE level IN (
    SELECT level FROM projects AS ordr
    WHERE ordr.id = emp.id
);


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

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


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

SELECT amount FROM projects AS budg
WHERE level IN (
    SELECT level FROM categories AS ord
    WHERE ord.type = budg.type
);


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

SELECT amount FROM products AS whs
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS emp
    WHERE emp.id = whs.id
);


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

SELECT id FROM employees AS srvc
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS inv
    WHERE inv.status = srvc.status
);


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

SELECT salary FROM suppliers AS empl
WHERE amount > (
    SELECT AVG(amount) FROM products AS whs
    WHERE whs.code = empl.code
);


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

SELECT salary FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.level = dept.level
);


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

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


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

SELECT salary FROM regions AS ord
WHERE type IN (
    SELECT type FROM products AS txn
    WHERE txn.status = ord.status
);


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

SELECT amount FROM accounts AS prod
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS sale
    WHERE sale.status = prod.status
);


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

SELECT amount FROM regions AS srvc
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS txn
    WHERE txn.id = srvc.id
);


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

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


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

SELECT amount FROM shipments AS lne
WHERE value > (
    SELECT MAX(amount) FROM branches AS empl
    WHERE empl.level = lne.level
);


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

SELECT amount FROM employees AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM shipments AS mgr
    WHERE mgr.id = shp.id
);


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

SELECT value FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.level = budg.level
);


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

SELECT code FROM departments AS rgn
WHERE value > (
    SELECT MAX(value) FROM categories AS dept
    WHERE dept.level = rgn.level
);


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

SELECT code FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = ord.level
);


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

SELECT code FROM customers AS inv
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.id = inv.id
);


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

SELECT salary FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.code = schd.code
);


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

SELECT amount FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.code = dept.code
);


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

SELECT salary FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.level = prod.level
);


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

SELECT salary FROM invoices AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS rgn
    WHERE rgn.id = whs.id
);


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

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


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

SELECT id FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.type = empl.type
);


Prompt:
Schema:
  employees (alias: empl)(name, type, level, id)
  products(value, id, salary, type)
Task: Retrieve id from employees with value above the COUNT(salary) of products rows sharing the same level.
SQL:

SELECT id FROM employees AS empl
WHERE value > (
    SELECT COUNT(salary) FROM products AS txn
    WHERE txn.level = empl.level
);


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

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


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

SELECT amount FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.level = dept.level
);


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

SELECT id FROM suppliers AS ord
WHERE id IN (
    SELECT id FROM invoices AS prod
    WHERE prod.level = ord.level
);


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

SELECT id FROM branches AS acct
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS emp
    WHERE emp.status = acct.status
);


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

SELECT id FROM employees AS prod
WHERE code IN (
    SELECT code FROM regions AS budg
    WHERE budg.type = prod.type
);


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

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


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

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


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

SELECT value FROM invoices AS txn
WHERE type IN (
    SELECT type FROM warehouses AS whs
    WHERE whs.id = txn.id
);


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

SELECT salary FROM customers AS empl
WHERE value > (
    SELECT MAX(amount) FROM warehouses AS shp
    WHERE shp.status = empl.status
);


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

SELECT name FROM transactions AS inv
WHERE level IN (
    SELECT level FROM regions AS emp
    WHERE emp.level = inv.level
);


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

SELECT code FROM shipments AS cust
WHERE salary > (
    SELECT AVG(amount) FROM regions AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT amount FROM categories AS budg
WHERE level IN (
    SELECT level FROM transactions AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT code FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT id FROM regions AS ordr
WHERE value > (
    SELECT MAX(salary) FROM projects AS whs
    WHERE whs.level = ordr.level
);


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

SELECT name FROM employees AS empl
WHERE salary > (
    SELECT AVG(salary) FROM branches AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT salary FROM departments AS whs
WHERE id IN (
    SELECT id FROM invoices AS emp
    WHERE emp.id = whs.id
);


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

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


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

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


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

SELECT name FROM shipments AS whs
WHERE amount > (
    SELECT MIN(salary) FROM transactions AS shp
    WHERE shp.level = whs.level
);


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

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


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

SELECT id FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.level = empl.level
);


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

SELECT salary FROM departments AS txn
WHERE type IN (
    SELECT type FROM transactions AS budg
    WHERE budg.code = txn.code
);


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

SELECT name FROM accounts AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS shp
    WHERE shp.type = lne.type
);


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

SELECT code FROM customers AS mgr
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.type = mgr.type
);


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

SELECT salary FROM departments AS cust
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS whs
    WHERE whs.id = cust.id
);


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

SELECT salary FROM projects AS cust
WHERE id IN (
    SELECT id FROM employees AS ord
    WHERE ord.status = cust.status
);


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

SELECT id FROM suppliers AS prod
WHERE amount > (
    SELECT COUNT(value) FROM customers AS inv
    WHERE inv.code = prod.code
);


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

SELECT id FROM transactions AS catg
WHERE amount > (
    SELECT MAX(value) FROM projects AS sale
    WHERE sale.type = catg.type
);


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

SELECT id FROM departments AS emp
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS empl
    WHERE empl.id = emp.id
);


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

SELECT id FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.type = prod.type
);