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

SELECT amount FROM employees AS dept
WHERE code IN (
    SELECT code FROM invoices AS catg
    WHERE catg.type = dept.type
);


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

SELECT id FROM departments AS srvc
WHERE code IN (
    SELECT code FROM categories AS dept
    WHERE dept.id = srvc.id
);


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

SELECT salary FROM departments AS catg
WHERE salary > (
    SELECT MIN(salary) FROM orders AS ordr
    WHERE ordr.id = catg.id
);


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

SELECT value FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.level = inv.level
);


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

SELECT name FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.level = schd.level
);


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

SELECT amount FROM accounts AS sale
WHERE type IN (
    SELECT type FROM departments AS cust
    WHERE cust.code = sale.code
);


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.status = acct.status
);


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

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


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

SELECT id FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.id = rgn.id
);


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

SELECT id FROM invoices AS acct
WHERE level IN (
    SELECT level FROM shipments AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT name FROM customers AS empl
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS cust
    WHERE cust.status = empl.status
);


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

SELECT name FROM accounts AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT value FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT value FROM accounts AS acct
WHERE salary > (
    SELECT AVG(value) FROM departments AS rgn
    WHERE rgn.code = acct.code
);


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

SELECT amount FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.status = srvc.status
);


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

SELECT id FROM shipments AS txn
WHERE amount > (
    SELECT SUM(value) FROM customers AS prod
    WHERE prod.code = txn.code
);


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

SELECT code FROM orders AS catg
WHERE level IN (
    SELECT level FROM warehouses AS dept
    WHERE dept.code = catg.code
);


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

SELECT salary FROM regions AS srvc
WHERE status IN (
    SELECT status FROM categories AS dept
    WHERE dept.level = srvc.level
);


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

SELECT salary FROM products AS mgr
WHERE value > (
    SELECT MIN(value) FROM regions AS acct
    WHERE acct.id = mgr.id
);


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

SELECT name FROM projects AS schd
WHERE salary > (
    SELECT MIN(value) FROM accounts AS acct
    WHERE acct.id = schd.id
);


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

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


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

SELECT name FROM branches AS emp
WHERE amount > (
    SELECT COUNT(salary) FROM invoices AS inv
    WHERE inv.id = emp.id
);


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

SELECT id FROM employees AS dept
WHERE id IN (
    SELECT id FROM branches AS catg
    WHERE catg.code = dept.code
);


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

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


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

SELECT id FROM employees AS shp
WHERE value > (
    SELECT AVG(value) FROM regions AS dept
    WHERE dept.level = shp.level
);


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

SELECT value FROM shipments AS emp
WHERE status IN (
    SELECT status FROM orders AS inv
    WHERE inv.type = emp.type
);


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

SELECT amount FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = mgr.type
);


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

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


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

SELECT id FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.status = ordr.status
);


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

SELECT salary FROM accounts AS schd
WHERE value > (
    SELECT MAX(salary) FROM tasks AS cust
    WHERE cust.level = schd.level
);


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

SELECT id FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.id = txn.id
);


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

SELECT code FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.level = budg.level
);


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

SELECT salary FROM categories AS ord
WHERE code IN (
    SELECT code FROM customers AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT amount FROM customers AS shp
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS schd
    WHERE schd.status = shp.status
);


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

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


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

SELECT id FROM departments AS srvc
WHERE amount > (
    SELECT MAX(salary) FROM branches AS rgn
    WHERE rgn.code = srvc.code
);


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

SELECT name FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.level = ordr.level
);


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

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


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

SELECT name FROM suppliers AS acct
WHERE salary > (
    SELECT MAX(value) FROM projects AS empl
    WHERE empl.status = acct.status
);


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

SELECT value FROM projects AS shp
WHERE level IN (
    SELECT level FROM branches AS emp
    WHERE emp.id = shp.id
);


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

SELECT id FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.level = ordr.level
);


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

SELECT code FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.level = acct.level
);


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

SELECT id FROM departments AS prod
WHERE amount > (
    SELECT AVG(amount) FROM regions AS txn
    WHERE txn.id = prod.id
);


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

SELECT amount FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.level = catg.level
);


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

SELECT value FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.type = srvc.type
);


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

SELECT salary FROM products AS cust
WHERE amount > (
    SELECT MIN(value) FROM employees AS catg
    WHERE catg.type = cust.type
);


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

SELECT value FROM tasks AS ordr
WHERE salary > (
    SELECT MIN(salary) FROM branches AS dept
    WHERE dept.status = ordr.status
);


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

SELECT name FROM regions AS ord
WHERE value > (
    SELECT MAX(value) FROM warehouses AS shp
    WHERE shp.code = ord.code
);


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

SELECT id FROM transactions AS srvc
WHERE code IN (
    SELECT code FROM warehouses AS budg
    WHERE budg.id = srvc.id
);


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

SELECT salary FROM branches AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT code FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.level = ordr.level
);


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

SELECT name FROM projects AS rgn
WHERE type IN (
    SELECT type FROM products AS dept
    WHERE dept.code = rgn.code
);


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

SELECT name FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.type = whs.type
);


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

SELECT salary FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.type = acct.type
);


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

SELECT id FROM regions AS empl
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS prod
    WHERE prod.id = empl.id
);


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

SELECT amount FROM customers AS acct
WHERE value > (
    SELECT MIN(value) FROM orders AS srvc
    WHERE srvc.code = acct.code
);


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

SELECT code FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = emp.id
);


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

SELECT name FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.code = whs.code
);


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

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


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

SELECT value FROM orders AS cust
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS dept
    WHERE dept.level = cust.level
);


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

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


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

SELECT name FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.type = budg.type
);


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

SELECT id FROM tasks AS mgr
WHERE id IN (
    SELECT id FROM projects AS shp
    WHERE shp.code = mgr.code
);


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

SELECT id FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.status = budg.status
);


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

SELECT amount FROM customers AS dept
WHERE code IN (
    SELECT code FROM suppliers AS sale
    WHERE sale.type = dept.type
);


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

SELECT id FROM orders AS sale
WHERE code IN (
    SELECT code FROM suppliers AS catg
    WHERE catg.status = sale.status
);


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

SELECT amount FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.code = inv.code
);


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

SELECT amount FROM customers AS srvc
WHERE status IN (
    SELECT status FROM suppliers AS dept
    WHERE dept.type = srvc.type
);


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

SELECT salary FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.level = ord.level
);


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

SELECT id FROM regions AS budg
WHERE id IN (
    SELECT id FROM tasks AS lne
    WHERE lne.code = budg.code
);


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

SELECT name FROM customers AS empl
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.id = empl.id
);


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

SELECT value FROM departments AS ordr
WHERE id IN (
    SELECT id FROM regions AS budg
    WHERE budg.id = ordr.id
);


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

SELECT amount FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.code = srvc.code
);


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

SELECT amount FROM categories AS acct
WHERE amount > (
    SELECT SUM(value) FROM transactions AS inv
    WHERE inv.level = acct.level
);


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

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


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

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


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

SELECT name FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.status = empl.status
);


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

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


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

SELECT id FROM projects AS txn
WHERE salary > (
    SELECT SUM(salary) FROM transactions AS ord
    WHERE ord.status = txn.status
);


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

SELECT name FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = prod.status
);


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

SELECT salary FROM invoices AS txn
WHERE salary > (
    SELECT MIN(value) FROM departments AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT salary FROM transactions AS dept
WHERE level IN (
    SELECT level FROM shipments AS sale
    WHERE sale.status = dept.status
);


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

SELECT code FROM departments AS lne
WHERE value > (
    SELECT MAX(value) FROM products AS ordr
    WHERE ordr.id = lne.id
);


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

SELECT code FROM warehouses AS sale
WHERE amount > (
    SELECT MIN(salary) FROM categories AS lne
    WHERE lne.level = sale.level
);


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

SELECT amount FROM suppliers AS ord
WHERE level IN (
    SELECT level FROM categories AS dept
    WHERE dept.level = ord.level
);


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

SELECT value FROM employees AS empl
WHERE type IN (
    SELECT type FROM branches AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT salary FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.level = prod.level
);


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

SELECT amount FROM customers AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM regions AS dept
    WHERE dept.level = ordr.level
);


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

SELECT value FROM tasks AS sale
WHERE id IN (
    SELECT id FROM regions AS cust
    WHERE cust.level = sale.level
);


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

SELECT amount FROM suppliers AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS ord
    WHERE ord.type = srvc.type
);


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

SELECT salary FROM branches AS schd
WHERE level IN (
    SELECT level FROM departments AS catg
    WHERE catg.id = schd.id
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.level = prod.level
);


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

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


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

SELECT value FROM categories AS acct
WHERE level IN (
    SELECT level FROM regions AS inv
    WHERE inv.code = acct.code
);


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

SELECT name FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.code = emp.code
);


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

SELECT id FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.level = prod.level
);


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

SELECT value FROM regions AS lne
WHERE value > (
    SELECT AVG(value) FROM departments AS acct
    WHERE acct.status = lne.status
);


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

SELECT value FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.level = dept.level
);


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

SELECT amount FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.type = budg.type
);


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

SELECT code FROM employees AS schd
WHERE status IN (
    SELECT status FROM invoices AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT value FROM categories AS empl
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.code = empl.code
);


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

SELECT name FROM products AS rgn
WHERE code IN (
    SELECT code FROM projects AS lne
    WHERE lne.status = rgn.status
);


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

SELECT id FROM products AS cust
WHERE id IN (
    SELECT id FROM accounts AS txn
    WHERE txn.id = cust.id
);


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

SELECT code FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.status = txn.status
);


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

SELECT salary FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.code = lne.code
);


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

SELECT value FROM shipments AS srvc
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.id = srvc.id
);


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

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


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

SELECT id FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.status = empl.status
);


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

SELECT amount FROM branches AS catg
WHERE id IN (
    SELECT id FROM transactions AS mgr
    WHERE mgr.code = catg.code
);


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

SELECT value FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.id = empl.id
);


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

SELECT name FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.level = ord.level
);


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

SELECT id FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = empl.status
);


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

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


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

SELECT id FROM orders AS rgn
WHERE level IN (
    SELECT level FROM warehouses AS schd
    WHERE schd.id = rgn.id
);


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

SELECT value FROM branches AS whs
WHERE value > (
    SELECT MIN(value) FROM projects AS empl
    WHERE empl.type = whs.type
);


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

SELECT value FROM employees AS inv
WHERE value > (
    SELECT AVG(value) FROM products AS lne
    WHERE lne.id = inv.id
);


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

SELECT value FROM shipments AS emp
WHERE amount > (
    SELECT COUNT(value) FROM orders AS prod
    WHERE prod.status = emp.status
);


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

SELECT value FROM regions AS srvc
WHERE code IN (
    SELECT code FROM tasks AS emp
    WHERE emp.level = srvc.level
);


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

SELECT amount FROM categories AS schd
WHERE amount > (
    SELECT MAX(salary) FROM customers AS emp
    WHERE emp.id = schd.id
);


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

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


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

SELECT salary FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.level = empl.level
);


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

SELECT salary FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.status = budg.status
);


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

SELECT amount FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.level = catg.level
);


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

SELECT id FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.id = txn.id
);


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

SELECT name FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.code = dept.code
);


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

SELECT salary FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.status = schd.status
);


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

SELECT id FROM shipments AS dept
WHERE salary > (
    SELECT SUM(salary) FROM warehouses AS prod
    WHERE prod.code = dept.code
);


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

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


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

SELECT name FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT code FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT name FROM categories AS acct
WHERE code IN (
    SELECT code FROM suppliers AS txn
    WHERE txn.code = acct.code
);


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

SELECT amount FROM accounts AS dept
WHERE salary > (
    SELECT SUM(value) FROM orders AS schd
    WHERE schd.level = dept.level
);


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

SELECT salary FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.type = rgn.type
);


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

SELECT salary FROM accounts AS ord
WHERE id IN (
    SELECT id FROM regions AS inv
    WHERE inv.code = ord.code
);


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

SELECT name FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.id = sale.id
);


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

SELECT salary FROM suppliers AS schd
WHERE id IN (
    SELECT id FROM regions AS shp
    WHERE shp.code = schd.code
);


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

SELECT amount FROM shipments AS empl
WHERE status IN (
    SELECT status FROM categories AS prod
    WHERE prod.status = empl.status
);


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

SELECT code FROM accounts AS shp
WHERE salary > (
    SELECT MIN(value) FROM categories AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT amount FROM suppliers AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS lne
    WHERE lne.id = inv.id
);


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

SELECT code FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.level = budg.level
);


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

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


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

SELECT id FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.type = prod.type
);


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

SELECT value FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.id = whs.id
);


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

SELECT code FROM departments AS empl
WHERE amount > (
    SELECT COUNT(value) FROM transactions AS whs
    WHERE whs.code = empl.code
);


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

SELECT value FROM transactions AS whs
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT amount FROM accounts AS ord
WHERE value > (
    SELECT MIN(salary) FROM products AS inv
    WHERE inv.id = ord.id
);


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

SELECT value FROM tasks AS cust
WHERE type IN (
    SELECT type FROM departments AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT amount FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.status = mgr.status
);


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

SELECT salary FROM employees AS ord
WHERE type IN (
    SELECT type FROM departments AS sale
    WHERE sale.code = ord.code
);


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

SELECT value FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.code = rgn.code
);


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

SELECT id FROM regions AS ordr
WHERE id IN (
    SELECT id FROM invoices AS shp
    WHERE shp.status = ordr.status
);


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

SELECT amount FROM customers AS whs
WHERE code IN (
    SELECT code FROM transactions AS schd
    WHERE schd.code = whs.code
);


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

SELECT id FROM shipments AS empl
WHERE code IN (
    SELECT code FROM branches AS cust
    WHERE cust.id = empl.id
);


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

SELECT amount FROM products AS shp
WHERE amount > (
    SELECT AVG(salary) FROM projects AS catg
    WHERE catg.id = shp.id
);


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

SELECT code FROM employees AS acct
WHERE type IN (
    SELECT type FROM products AS cust
    WHERE cust.id = acct.id
);


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

SELECT salary FROM warehouses AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM products AS prod
    WHERE prod.id = rgn.id
);


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

SELECT amount FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.level = inv.level
);


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

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


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

SELECT name FROM branches AS whs
WHERE id IN (
    SELECT id FROM orders AS emp
    WHERE emp.code = whs.code
);


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

SELECT salary FROM categories AS catg
WHERE value > (
    SELECT AVG(value) FROM invoices AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT amount FROM invoices AS schd
WHERE value > (
    SELECT AVG(amount) FROM departments AS prod
    WHERE prod.id = schd.id
);


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

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


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

SELECT name FROM employees AS prod
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS shp
    WHERE shp.id = prod.id
);


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

SELECT id FROM suppliers AS dept
WHERE code IN (
    SELECT code FROM warehouses AS srvc
    WHERE srvc.level = dept.level
);


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

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


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

SELECT salary FROM invoices AS shp
WHERE id IN (
    SELECT id FROM shipments AS catg
    WHERE catg.type = shp.type
);


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

SELECT value FROM suppliers AS ordr
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.level = ordr.level
);


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

SELECT value FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.type = srvc.type
);


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

SELECT value FROM branches AS ord
WHERE level IN (
    SELECT level FROM products AS shp
    WHERE shp.status = ord.status
);


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

SELECT code FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = budg.status
);


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

SELECT id FROM shipments AS inv
WHERE id IN (
    SELECT id FROM employees AS schd
    WHERE schd.id = inv.id
);


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

SELECT amount FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.status = mgr.status
);


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

SELECT name FROM suppliers AS emp
WHERE level IN (
    SELECT level FROM departments AS cust
    WHERE cust.code = emp.code
);


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

SELECT name FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.type = sale.type
);


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

SELECT amount FROM orders AS mgr
WHERE code IN (
    SELECT code FROM branches AS empl
    WHERE empl.id = mgr.id
);


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

SELECT salary FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.code = lne.code
);


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

SELECT value FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.code = cust.code
);


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

SELECT id FROM accounts AS rgn
WHERE id IN (
    SELECT id FROM regions AS empl
    WHERE empl.status = rgn.status
);


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

SELECT id FROM invoices AS txn
WHERE code IN (
    SELECT code FROM transactions AS cust
    WHERE cust.level = txn.level
);


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

SELECT code FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.id = rgn.id
);


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

SELECT salary FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.status = emp.status
);


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

SELECT value FROM transactions AS acct
WHERE salary > (
    SELECT SUM(amount) FROM departments AS ord
    WHERE ord.status = acct.status
);


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

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


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

SELECT id FROM products AS emp
WHERE amount > (
    SELECT MIN(amount) FROM projects AS shp
    WHERE shp.type = emp.type
);


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

SELECT salary FROM tasks AS catg
WHERE type IN (
    SELECT type FROM departments AS lne
    WHERE lne.type = catg.type
);


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

SELECT amount FROM employees AS sale
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS inv
    WHERE inv.type = sale.type
);


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

SELECT name FROM projects AS whs
WHERE amount > (
    SELECT AVG(value) FROM accounts AS shp
    WHERE shp.type = whs.type
);


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

SELECT code FROM branches AS empl
WHERE level IN (
    SELECT level FROM invoices AS prod
    WHERE prod.status = empl.status
);


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

SELECT value FROM customers AS inv
WHERE amount > (
    SELECT COUNT(value) FROM employees AS catg
    WHERE catg.id = inv.id
);


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

SELECT value FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.id = prod.id
);


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

SELECT salary FROM customers AS empl
WHERE type IN (
    SELECT type FROM invoices AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT salary FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT id FROM accounts AS prod
WHERE value > (
    SELECT COUNT(value) FROM departments AS catg
    WHERE catg.status = prod.status
);


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

SELECT name FROM products AS rgn
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.level = rgn.level
);


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

SELECT name FROM invoices AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS srvc
    WHERE srvc.type = ordr.type
);


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

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


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

SELECT value FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.level = dept.level
);


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

SELECT code FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT id FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.type = txn.type
);


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

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


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

SELECT code FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.status = mgr.status
);


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

SELECT code FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.id = ordr.id
);


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

SELECT name FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.status = schd.status
);


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

SELECT salary FROM projects AS ord
WHERE value > (
    SELECT AVG(value) FROM customers AS shp
    WHERE shp.level = ord.level
);


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

SELECT code FROM orders AS schd
WHERE code IN (
    SELECT code FROM branches AS srvc
    WHERE srvc.type = schd.type
);


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

SELECT name FROM orders AS catg
WHERE salary > (
    SELECT AVG(value) FROM customers AS shp
    WHERE shp.code = catg.code
);


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

SELECT amount FROM customers AS mgr
WHERE id IN (
    SELECT id FROM orders AS lne
    WHERE lne.type = mgr.type
);


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

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


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

SELECT value FROM accounts AS sale
WHERE value > (
    SELECT MAX(value) FROM customers AS dept
    WHERE dept.type = sale.type
);


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

SELECT value FROM shipments AS inv
WHERE salary > (
    SELECT MIN(salary) FROM regions AS dept
    WHERE dept.id = inv.id
);


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

SELECT salary FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.type = ord.type
);


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

SELECT salary FROM transactions AS dept
WHERE id IN (
    SELECT id FROM customers AS sale
    WHERE sale.status = dept.status
);


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

SELECT amount FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.status = whs.status
);


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

SELECT name FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.code = mgr.code
);


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

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


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

SELECT value FROM shipments AS catg
WHERE id IN (
    SELECT id FROM products AS shp
    WHERE shp.type = catg.type
);


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

SELECT amount FROM projects AS shp
WHERE status IN (
    SELECT status FROM warehouses AS inv
    WHERE inv.type = shp.type
);


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

SELECT name FROM suppliers AS srvc
WHERE type IN (
    SELECT type FROM tasks AS sale
    WHERE sale.id = srvc.id
);


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

SELECT salary FROM departments AS sale
WHERE amount > (
    SELECT SUM(value) FROM tasks AS cust
    WHERE cust.type = sale.type
);


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

SELECT name FROM projects AS budg
WHERE id IN (
    SELECT id FROM branches AS schd
    WHERE schd.level = budg.level
);


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

SELECT salary FROM suppliers AS txn
WHERE status IN (
    SELECT status FROM employees AS catg
    WHERE catg.level = txn.level
);


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

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


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

SELECT code FROM shipments AS shp
WHERE value > (
    SELECT MAX(value) FROM invoices AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT code FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.status = cust.status
);


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

SELECT value FROM warehouses AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS budg
    WHERE budg.status = rgn.status
);


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

SELECT id FROM projects AS whs
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.code = whs.code
);


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

SELECT value FROM customers AS dept
WHERE type IN (
    SELECT type FROM transactions AS catg
    WHERE catg.status = dept.status
);


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

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


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

SELECT code FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.status = txn.status
);


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

SELECT value FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.code = dept.code
);


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

SELECT code FROM categories AS srvc
WHERE salary > (
    SELECT AVG(value) FROM orders AS dept
    WHERE dept.level = srvc.level
);


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

SELECT id FROM transactions AS acct
WHERE level IN (
    SELECT level FROM products AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT name FROM orders AS sale
WHERE type IN (
    SELECT type FROM departments AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT id FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.status = cust.status
);


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

SELECT value FROM suppliers AS srvc
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS lne
    WHERE lne.status = srvc.status
);


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

SELECT salary FROM departments AS cust
WHERE salary > (
    SELECT MAX(salary) FROM branches AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT name FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.level = txn.level
);


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

SELECT id FROM invoices AS srvc
WHERE value > (
    SELECT MAX(salary) FROM orders AS shp
    WHERE shp.level = srvc.level
);


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

SELECT id FROM projects AS ord
WHERE level IN (
    SELECT level FROM shipments AS dept
    WHERE dept.type = ord.type
);


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

SELECT name FROM employees AS acct
WHERE id IN (
    SELECT id FROM regions AS cust
    WHERE cust.id = acct.id
);


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

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


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

SELECT salary FROM invoices AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM projects AS dept
    WHERE dept.type = ordr.type
);


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

SELECT salary FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.id = catg.id
);


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

SELECT salary FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT salary FROM suppliers AS prod
WHERE value > (
    SELECT MIN(value) FROM categories AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.code = txn.code
);


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

SELECT salary FROM employees AS emp
WHERE type IN (
    SELECT type FROM customers AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT name FROM projects AS lne
WHERE value > (
    SELECT SUM(amount) FROM products AS schd
    WHERE schd.id = lne.id
);


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

SELECT value FROM branches AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS dept
    WHERE dept.id = rgn.id
);


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

SELECT salary FROM tasks AS inv
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS empl
    WHERE empl.level = inv.level
);


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

SELECT amount FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.id = txn.id
);


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

SELECT salary FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.level = txn.level
);


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

SELECT value FROM shipments AS txn
WHERE code IN (
    SELECT code FROM tasks AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT amount FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.level = empl.level
);


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

SELECT name FROM warehouses AS dept
WHERE salary > (
    SELECT COUNT(value) FROM regions AS catg
    WHERE catg.status = dept.status
);


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

SELECT salary FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.code = srvc.code
);


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

SELECT code FROM transactions AS cust
WHERE code IN (
    SELECT code FROM warehouses AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT name FROM orders AS ord
WHERE amount > (
    SELECT SUM(value) FROM shipments AS cust
    WHERE cust.code = ord.code
);


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

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


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

SELECT salary FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.status = ord.status
);


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

SELECT amount FROM products AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM projects AS emp
    WHERE emp.level = ordr.level
);


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

SELECT name FROM accounts AS budg
WHERE salary > (
    SELECT MAX(amount) FROM customers AS acct
    WHERE acct.id = budg.id
);


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

SELECT value FROM regions AS lne
WHERE salary > (
    SELECT AVG(salary) FROM branches AS whs
    WHERE whs.level = lne.level
);


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

SELECT name FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.code = ord.code
);


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

SELECT value FROM accounts AS ord
WHERE code IN (
    SELECT code FROM products AS empl
    WHERE empl.level = ord.level
);


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

SELECT amount FROM projects AS lne
WHERE type IN (
    SELECT type FROM branches AS inv
    WHERE inv.id = lne.id
);


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

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


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

SELECT salary FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT name FROM tasks AS acct
WHERE level IN (
    SELECT level FROM accounts AS catg
    WHERE catg.type = acct.type
);


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

SELECT code FROM tasks AS empl
WHERE salary > (
    SELECT AVG(value) FROM products AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT amount FROM invoices AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS shp
    WHERE shp.code = schd.code
);


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

SELECT amount FROM suppliers AS lne
WHERE amount > (
    SELECT SUM(value) FROM shipments AS txn
    WHERE txn.type = lne.type
);


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

SELECT name FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT code FROM departments AS txn
WHERE id IN (
    SELECT id FROM branches AS emp
    WHERE emp.code = txn.code
);


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

SELECT id FROM suppliers AS sale
WHERE amount > (
    SELECT MIN(amount) FROM transactions AS emp
    WHERE emp.id = sale.id
);


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

SELECT salary FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.type = rgn.type
);


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

SELECT name FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.id = prod.id
);


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

SELECT name FROM departments AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM orders AS dept
    WHERE dept.level = ordr.level
);


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

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


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

SELECT name FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT name FROM tasks AS inv
WHERE status IN (
    SELECT status FROM products AS prod
    WHERE prod.level = inv.level
);


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

SELECT value FROM orders AS ordr
WHERE value > (
    SELECT SUM(salary) FROM accounts AS acct
    WHERE acct.code = ordr.code
);


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

SELECT salary FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT value FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = emp.type
);


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

SELECT value FROM categories AS catg
WHERE id IN (
    SELECT id FROM projects AS prod
    WHERE prod.type = catg.type
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.code = whs.code
);


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

SELECT amount FROM shipments AS inv
WHERE value > (
    SELECT MIN(value) FROM regions AS budg
    WHERE budg.code = inv.code
);


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

SELECT name FROM accounts AS txn
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.id = txn.id
);


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

SELECT value FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT value FROM products AS txn
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS sale
    WHERE sale.type = txn.type
);


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

SELECT amount FROM accounts AS ordr
WHERE code IN (
    SELECT code FROM customers AS lne
    WHERE lne.level = ordr.level
);


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

SELECT id FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.level = rgn.level
);


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

SELECT code FROM accounts AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS cust
    WHERE cust.code = ordr.code
);


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

SELECT name FROM employees AS sale
WHERE amount > (
    SELECT AVG(amount) FROM products AS lne
    WHERE lne.type = sale.type
);