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

SELECT salary FROM warehouses AS prod
WHERE status IN (
    SELECT status FROM employees AS catg
    WHERE catg.level = prod.level
);


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

SELECT code FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = whs.id
);


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

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


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

SELECT id FROM departments AS cust
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.code = cust.code
);


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

SELECT name FROM shipments AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM branches AS emp
    WHERE emp.type = srvc.type
);


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

SELECT id FROM invoices AS budg
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS whs
    WHERE whs.type = budg.type
);


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

SELECT amount FROM branches AS shp
WHERE status IN (
    SELECT status FROM customers AS prod
    WHERE prod.level = shp.level
);


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

SELECT code FROM transactions AS txn
WHERE type IN (
    SELECT type FROM customers AS ordr
    WHERE ordr.type = txn.type
);


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

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


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

SELECT name FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.code = mgr.code
);


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

SELECT code FROM products AS rgn
WHERE value > (
    SELECT SUM(value) FROM invoices AS inv
    WHERE inv.code = rgn.code
);


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

SELECT value FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.code = schd.code
);


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

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


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

SELECT name FROM transactions AS dept
WHERE value > (
    SELECT COUNT(amount) FROM categories AS prod
    WHERE prod.id = dept.id
);


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

SELECT id FROM departments AS cust
WHERE code IN (
    SELECT code FROM products AS ord
    WHERE ord.id = cust.id
);


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

SELECT salary FROM customers AS sale
WHERE value > (
    SELECT MAX(amount) FROM projects AS txn
    WHERE txn.id = sale.id
);


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

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


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

SELECT name FROM regions AS whs
WHERE amount > (
    SELECT MIN(value) FROM orders AS acct
    WHERE acct.id = whs.id
);


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

SELECT id FROM branches AS ord
WHERE level IN (
    SELECT level FROM accounts AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT salary FROM regions AS whs
WHERE value > (
    SELECT COUNT(value) FROM branches AS schd
    WHERE schd.code = whs.code
);


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

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


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

SELECT code FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.status = srvc.status
);


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

SELECT name FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.id = ord.id
);


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

SELECT value FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.status = cust.status
);


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

SELECT salary FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT value FROM shipments AS shp
WHERE salary > (
    SELECT MIN(value) FROM products AS whs
    WHERE whs.code = shp.code
);


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

SELECT amount FROM invoices AS txn
WHERE status IN (
    SELECT status FROM products AS inv
    WHERE inv.code = txn.code
);


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

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


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

SELECT id FROM branches AS ordr
WHERE type IN (
    SELECT type FROM categories AS inv
    WHERE inv.status = ordr.status
);


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

SELECT amount FROM suppliers AS acct
WHERE value > (
    SELECT AVG(salary) FROM employees AS whs
    WHERE whs.code = acct.code
);


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

SELECT value FROM transactions AS schd
WHERE value > (
    SELECT AVG(value) FROM employees AS budg
    WHERE budg.level = schd.level
);


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

SELECT salary FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = ordr.code
);


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

SELECT name FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT code FROM categories AS prod
WHERE salary > (
    SELECT MIN(amount) FROM customers AS empl
    WHERE empl.code = prod.code
);


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

SELECT code FROM shipments AS schd
WHERE status IN (
    SELECT status FROM tasks AS dept
    WHERE dept.type = schd.type
);


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

SELECT name FROM orders AS prod
WHERE amount > (
    SELECT MIN(amount) FROM products AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT name FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.id = dept.id
);


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

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


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

SELECT code FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.id = prod.id
);


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

SELECT salary FROM shipments AS inv
WHERE level IN (
    SELECT level FROM projects AS sale
    WHERE sale.status = inv.status
);


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

SELECT name FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.id = sale.id
);


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

SELECT salary FROM categories AS whs
WHERE value > (
    SELECT SUM(salary) FROM customers AS lne
    WHERE lne.status = whs.status
);


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

SELECT value FROM tasks AS prod
WHERE value > (
    SELECT AVG(value) FROM accounts AS empl
    WHERE empl.code = prod.code
);


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

SELECT name FROM projects AS mgr
WHERE value > (
    SELECT MAX(amount) FROM departments AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT code FROM orders AS budg
WHERE id IN (
    SELECT id FROM customers AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT value FROM employees AS ord
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS catg
    WHERE catg.level = ord.level
);


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

SELECT code FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.status = dept.status
);


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

SELECT amount FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.level = rgn.level
);


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

SELECT id FROM orders AS emp
WHERE value > (
    SELECT MIN(value) FROM departments AS budg
    WHERE budg.id = emp.id
);


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

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


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

SELECT name FROM employees AS txn
WHERE value > (
    SELECT COUNT(amount) FROM transactions AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT name FROM accounts AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS empl
    WHERE empl.id = ordr.id
);


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

SELECT name FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.id = lne.id
);


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

SELECT amount FROM categories AS shp
WHERE level IN (
    SELECT level FROM employees AS ord
    WHERE ord.level = shp.level
);


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

SELECT name FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.id = rgn.id
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT value FROM regions AS catg
WHERE id IN (
    SELECT id FROM projects AS ord
    WHERE ord.id = catg.id
);


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

SELECT value FROM accounts AS prod
WHERE code IN (
    SELECT code FROM transactions AS ord
    WHERE ord.type = prod.type
);


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

SELECT code FROM invoices AS lne
WHERE value > (
    SELECT AVG(value) FROM suppliers AS sale
    WHERE sale.level = lne.level
);


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

SELECT name FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.level = srvc.level
);


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

SELECT code FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.id = acct.id
);


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

SELECT id FROM transactions AS whs
WHERE level IN (
    SELECT level FROM suppliers AS shp
    WHERE shp.id = whs.id
);


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

SELECT id FROM customers AS catg
WHERE value > (
    SELECT MAX(value) FROM orders AS schd
    WHERE schd.status = catg.status
);


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

SELECT salary FROM employees AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS budg
    WHERE budg.status = catg.status
);


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

SELECT value FROM orders AS dept
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS prod
    WHERE prod.type = dept.type
);


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

SELECT value FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.id = shp.id
);


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

SELECT value FROM departments AS prod
WHERE code IN (
    SELECT code FROM projects AS emp
    WHERE emp.code = prod.code
);


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

SELECT code FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.status = srvc.status
);


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

SELECT salary FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.level = rgn.level
);


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

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


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

SELECT code FROM customers AS lne
WHERE level IN (
    SELECT level FROM invoices AS txn
    WHERE txn.code = lne.code
);


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

SELECT salary FROM projects AS srvc
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS acct
    WHERE acct.status = srvc.status
);


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

SELECT code FROM departments AS ord
WHERE status IN (
    SELECT status FROM suppliers AS rgn
    WHERE rgn.type = ord.type
);


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

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


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

SELECT name FROM departments AS ord
WHERE value > (
    SELECT SUM(amount) FROM projects AS rgn
    WHERE rgn.code = ord.code
);


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

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


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

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


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

SELECT id FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT value FROM orders AS ordr
WHERE value > (
    SELECT MAX(amount) FROM projects AS cust
    WHERE cust.type = ordr.type
);


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

SELECT amount FROM orders AS lne
WHERE type IN (
    SELECT type FROM suppliers AS ord
    WHERE ord.level = lne.level
);


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

SELECT code FROM departments AS prod
WHERE value > (
    SELECT COUNT(value) FROM products AS txn
    WHERE txn.id = prod.id
);


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

SELECT value FROM customers AS budg
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS prod
    WHERE prod.code = budg.code
);


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

SELECT value FROM categories AS sale
WHERE salary > (
    SELECT SUM(value) FROM warehouses AS dept
    WHERE dept.level = sale.level
);


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

SELECT amount FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = acct.status
);


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

SELECT name FROM accounts AS shp
WHERE amount > (
    SELECT SUM(amount) FROM departments AS budg
    WHERE budg.status = shp.status
);


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

SELECT name FROM products AS ord
WHERE value > (
    SELECT MAX(salary) FROM departments AS txn
    WHERE txn.level = ord.level
);


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

SELECT name FROM warehouses AS prod
WHERE type IN (
    SELECT type FROM products AS schd
    WHERE schd.type = prod.type
);


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

SELECT salary FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.id = inv.id
);


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

SELECT code FROM transactions AS cust
WHERE level IN (
    SELECT level FROM employees AS ord
    WHERE ord.type = cust.type
);


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

SELECT id FROM warehouses AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM orders AS shp
    WHERE shp.status = rgn.status
);


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

SELECT salary FROM customers AS ordr
WHERE status IN (
    SELECT status FROM regions AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT salary FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.code = acct.code
);


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

SELECT id FROM categories AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM shipments AS prod
    WHERE prod.id = ord.id
);


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

SELECT value FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.type = shp.type
);


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

SELECT name FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.code = catg.code
);


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

SELECT salary FROM transactions AS srvc
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.level = srvc.level
);


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

SELECT id FROM regions AS schd
WHERE salary > (
    SELECT AVG(salary) FROM tasks AS budg
    WHERE budg.id = schd.id
);


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

SELECT salary FROM projects AS sale
WHERE level IN (
    SELECT level FROM customers AS empl
    WHERE empl.level = sale.level
);


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

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


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

SELECT salary FROM departments AS ord
WHERE level IN (
    SELECT level FROM invoices AS sale
    WHERE sale.level = ord.level
);


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

SELECT name FROM warehouses AS lne
WHERE value > (
    SELECT AVG(value) FROM tasks AS whs
    WHERE whs.status = lne.status
);


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

SELECT value FROM orders AS whs
WHERE salary > (
    SELECT AVG(value) FROM employees AS txn
    WHERE txn.id = whs.id
);


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

SELECT value FROM projects AS empl
WHERE id IN (
    SELECT id FROM accounts AS prod
    WHERE prod.status = empl.status
);


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

SELECT amount FROM employees AS sale
WHERE level IN (
    SELECT level FROM accounts AS catg
    WHERE catg.id = sale.id
);


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

SELECT id FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.level = rgn.level
);


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

SELECT value FROM products AS txn
WHERE salary > (
    SELECT MIN(amount) FROM customers AS dept
    WHERE dept.level = txn.level
);


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

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


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

SELECT amount FROM transactions AS cust
WHERE amount > (
    SELECT COUNT(value) FROM suppliers AS txn
    WHERE txn.status = cust.status
);


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

SELECT value FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.type = lne.type
);


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

SELECT id FROM customers AS rgn
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS shp
    WHERE shp.level = rgn.level
);


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

SELECT code FROM transactions AS shp
WHERE level IN (
    SELECT level FROM customers AS whs
    WHERE whs.id = shp.id
);


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

SELECT value FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT name FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.status = sale.status
);


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

SELECT amount FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.status = whs.status
);


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

SELECT value FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.level = emp.level
);


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

SELECT amount FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.status = rgn.status
);


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

SELECT amount FROM products AS mgr
WHERE code IN (
    SELECT code FROM departments AS inv
    WHERE inv.code = mgr.code
);


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

SELECT id FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.level = shp.level
);


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

SELECT value FROM categories AS shp
WHERE status IN (
    SELECT status FROM departments AS schd
    WHERE schd.code = shp.code
);


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

SELECT amount FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT amount FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = schd.code
);


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

SELECT amount FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.status = inv.status
);


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

SELECT value FROM projects AS empl
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS prod
    WHERE prod.code = empl.code
);


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

SELECT name FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.type = whs.type
);


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

SELECT name FROM transactions AS inv
WHERE type IN (
    SELECT type FROM products AS txn
    WHERE txn.id = inv.id
);


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

SELECT salary FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.id = mgr.id
);


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

SELECT value FROM projects AS lne
WHERE code IN (
    SELECT code FROM departments AS schd
    WHERE schd.code = lne.code
);


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

SELECT code FROM transactions AS schd
WHERE status IN (
    SELECT status FROM accounts AS inv
    WHERE inv.status = schd.status
);


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

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


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

SELECT id FROM transactions AS empl
WHERE type IN (
    SELECT type FROM products AS ordr
    WHERE ordr.id = empl.id
);


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

SELECT id FROM departments AS ord
WHERE code IN (
    SELECT code FROM shipments AS srvc
    WHERE srvc.id = ord.id
);


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

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


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

SELECT name FROM tasks AS prod
WHERE id IN (
    SELECT id FROM orders AS whs
    WHERE whs.code = prod.code
);


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

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


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

SELECT code FROM branches AS ordr
WHERE amount > (
    SELECT SUM(value) FROM employees AS catg
    WHERE catg.type = ordr.type
);


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

SELECT salary FROM orders AS catg
WHERE salary > (
    SELECT MAX(value) FROM departments AS whs
    WHERE whs.code = catg.code
);


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

SELECT code FROM shipments AS emp
WHERE level IN (
    SELECT level FROM warehouses AS inv
    WHERE inv.level = emp.level
);


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

SELECT amount FROM categories AS txn
WHERE amount > (
    SELECT COUNT(value) FROM projects AS lne
    WHERE lne.type = txn.type
);


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

SELECT salary FROM regions AS inv
WHERE value > (
    SELECT SUM(salary) FROM accounts AS emp
    WHERE emp.type = inv.type
);


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

SELECT value FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT salary FROM customers AS shp
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.code = shp.code
);


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

SELECT name FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.type = budg.type
);


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

SELECT amount FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.code = schd.code
);


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

SELECT salary FROM employees AS empl
WHERE id IN (
    SELECT id FROM products AS inv
    WHERE inv.type = empl.type
);


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

SELECT id FROM projects AS inv
WHERE status IN (
    SELECT status FROM tasks AS budg
    WHERE budg.status = inv.status
);


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

SELECT value FROM departments AS lne
WHERE amount > (
    SELECT AVG(value) FROM shipments AS ord
    WHERE ord.code = lne.code
);


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

SELECT code FROM regions AS lne
WHERE salary > (
    SELECT MIN(value) FROM categories AS acct
    WHERE acct.id = lne.id
);


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

SELECT id FROM tasks AS txn
WHERE id IN (
    SELECT id FROM orders AS prod
    WHERE prod.status = txn.status
);


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

SELECT amount FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT id FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT amount FROM employees AS ordr
WHERE status IN (
    SELECT status FROM departments AS acct
    WHERE acct.code = ordr.code
);


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

SELECT name FROM orders AS rgn
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.code = rgn.code
);


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

SELECT amount FROM tasks AS empl
WHERE id IN (
    SELECT id FROM categories AS catg
    WHERE catg.id = empl.id
);


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

SELECT code FROM customers AS dept
WHERE value > (
    SELECT COUNT(value) FROM projects AS cust
    WHERE cust.status = dept.status
);


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

SELECT salary FROM customers AS budg
WHERE id IN (
    SELECT id FROM warehouses AS sale
    WHERE sale.type = budg.type
);


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

SELECT salary FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.id = emp.id
);


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

SELECT code FROM categories AS budg
WHERE type IN (
    SELECT type FROM invoices AS ordr
    WHERE ordr.level = budg.level
);


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

SELECT code FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.type = srvc.type
);


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

SELECT id FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.code = schd.code
);


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

SELECT amount FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = txn.code
);


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

SELECT name FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.type = ord.type
);


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

SELECT code FROM orders AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM branches AS mgr
    WHERE mgr.type = catg.type
);


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

SELECT value FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.code = srvc.code
);


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

SELECT id FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.level = whs.level
);


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

SELECT value FROM invoices AS emp
WHERE amount > (
    SELECT MIN(value) FROM shipments AS rgn
    WHERE rgn.status = emp.status
);


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

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


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

SELECT code FROM categories AS inv
WHERE level IN (
    SELECT level FROM warehouses AS catg
    WHERE catg.code = inv.code
);


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

SELECT name FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.type = cust.type
);


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

SELECT value FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.code = budg.code
);


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

SELECT value FROM transactions AS shp
WHERE code IN (
    SELECT code FROM branches AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT value FROM transactions AS acct
WHERE salary > (
    SELECT COUNT(value) FROM categories AS lne
    WHERE lne.level = acct.level
);


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

SELECT amount FROM projects AS schd
WHERE level IN (
    SELECT level FROM tasks AS ord
    WHERE ord.status = schd.status
);


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

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


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

SELECT id FROM departments AS shp
WHERE amount > (
    SELECT MIN(amount) FROM warehouses AS lne
    WHERE lne.code = shp.code
);


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

SELECT value FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT name FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.level = srvc.level
);


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

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


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

SELECT name FROM regions AS inv
WHERE type IN (
    SELECT type FROM departments AS txn
    WHERE txn.code = inv.code
);


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

SELECT code FROM invoices AS schd
WHERE type IN (
    SELECT type FROM warehouses AS shp
    WHERE shp.type = schd.type
);


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

SELECT name FROM projects AS txn
WHERE status IN (
    SELECT status FROM employees AS ord
    WHERE ord.type = txn.type
);


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

SELECT id FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT code FROM categories AS emp
WHERE amount > (
    SELECT MIN(amount) FROM branches AS lne
    WHERE lne.status = emp.status
);


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

SELECT salary FROM orders AS cust
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.status = cust.status
);


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

SELECT amount FROM regions AS catg
WHERE level IN (
    SELECT level FROM transactions AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT id FROM suppliers AS shp
WHERE status IN (
    SELECT status FROM projects AS lne
    WHERE lne.status = shp.status
);


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

SELECT name FROM products AS srvc
WHERE code IN (
    SELECT code FROM accounts AS cust
    WHERE cust.code = srvc.code
);


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

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


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

SELECT id FROM tasks AS whs
WHERE code IN (
    SELECT code FROM employees AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT name FROM tasks AS inv
WHERE salary > (
    SELECT SUM(salary) FROM departments AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT id FROM categories AS txn
WHERE value > (
    SELECT COUNT(value) FROM projects AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT name FROM suppliers AS lne
WHERE salary > (
    SELECT MAX(amount) FROM orders AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT salary FROM warehouses AS acct
WHERE level IN (
    SELECT level FROM accounts AS prod
    WHERE prod.id = acct.id
);


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

SELECT id FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM employees AS sale
    WHERE sale.code = rgn.code
);


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

SELECT id FROM regions AS lne
WHERE level IN (
    SELECT level FROM projects AS cust
    WHERE cust.status = lne.status
);


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

SELECT code FROM tasks AS txn
WHERE status IN (
    SELECT status FROM products AS dept
    WHERE dept.level = txn.level
);


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

SELECT amount FROM customers AS catg
WHERE status IN (
    SELECT status FROM departments AS emp
    WHERE emp.level = catg.level
);


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

SELECT amount FROM branches AS sale
WHERE level IN (
    SELECT level FROM accounts AS cust
    WHERE cust.id = sale.id
);


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

SELECT code FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.status = schd.status
);


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

SELECT amount FROM departments AS lne
WHERE status IN (
    SELECT status FROM invoices AS schd
    WHERE schd.code = lne.code
);


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

SELECT value FROM shipments AS schd
WHERE amount > (
    SELECT AVG(value) FROM transactions AS cust
    WHERE cust.status = schd.status
);


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

SELECT name FROM customers AS dept
WHERE status IN (
    SELECT status FROM categories AS empl
    WHERE empl.level = dept.level
);


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

SELECT value FROM suppliers AS rgn
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.code = rgn.code
);


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

SELECT id FROM transactions AS catg
WHERE amount > (
    SELECT MIN(salary) FROM products AS mgr
    WHERE mgr.id = catg.id
);


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

SELECT value FROM accounts AS shp
WHERE status IN (
    SELECT status FROM projects AS budg
    WHERE budg.code = shp.code
);


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

SELECT name FROM transactions AS srvc
WHERE type IN (
    SELECT type FROM branches AS whs
    WHERE whs.type = srvc.type
);


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

SELECT code FROM projects AS lne
WHERE salary > (
    SELECT AVG(value) FROM regions AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT value FROM orders AS lne
WHERE level IN (
    SELECT level FROM shipments AS inv
    WHERE inv.level = lne.level
);


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

SELECT id FROM transactions AS inv
WHERE code IN (
    SELECT code FROM categories AS sale
    WHERE sale.type = inv.type
);


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

SELECT salary FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.id = catg.id
);


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

SELECT name FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.code = ordr.code
);


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

SELECT value FROM invoices AS txn
WHERE level IN (
    SELECT level FROM regions AS acct
    WHERE acct.type = txn.type
);


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

SELECT name FROM regions AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS schd
    WHERE schd.code = ordr.code
);


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

SELECT amount FROM orders AS lne
WHERE id IN (
    SELECT id FROM employees AS prod
    WHERE prod.level = lne.level
);


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

SELECT salary FROM categories AS lne
WHERE amount > (
    SELECT MAX(value) FROM departments AS txn
    WHERE txn.id = lne.id
);


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

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


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

SELECT id FROM projects AS catg
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS cust
    WHERE cust.level = catg.level
);


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

SELECT id FROM suppliers AS cust
WHERE salary > (
    SELECT AVG(salary) FROM products AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT salary FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.type = txn.type
);


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

SELECT value FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.code = catg.code
);


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

SELECT id FROM transactions AS sale
WHERE id IN (
    SELECT id FROM employees AS inv
    WHERE inv.level = sale.level
);


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

SELECT value FROM products AS emp
WHERE code IN (
    SELECT code FROM departments AS lne
    WHERE lne.status = emp.status
);


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

SELECT id FROM regions AS ord
WHERE type IN (
    SELECT type FROM invoices AS rgn
    WHERE rgn.code = ord.code
);


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

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


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

SELECT value FROM suppliers AS schd
WHERE type IN (
    SELECT type FROM projects AS txn
    WHERE txn.code = schd.code
);


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

SELECT amount FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.type = lne.type
);


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

SELECT name FROM categories AS prod
WHERE id IN (
    SELECT id FROM suppliers AS schd
    WHERE schd.id = prod.id
);


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

SELECT code FROM employees AS ord
WHERE type IN (
    SELECT type FROM warehouses AS emp
    WHERE emp.status = ord.status
);


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

SELECT name FROM branches AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS lne
    WHERE lne.id = txn.id
);


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

SELECT name FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.id = shp.id
);


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

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


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

SELECT code FROM departments AS lne
WHERE level IN (
    SELECT level FROM transactions AS dept
    WHERE dept.code = lne.code
);


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

SELECT amount FROM warehouses AS srvc
WHERE id IN (
    SELECT id FROM projects AS emp
    WHERE emp.code = srvc.code
);


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

SELECT value FROM tasks AS schd
WHERE code IN (
    SELECT code FROM invoices AS whs
    WHERE whs.status = schd.status
);


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

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


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

SELECT value FROM regions AS rgn
WHERE type IN (
    SELECT type FROM transactions AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT name FROM categories AS ord
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT salary FROM warehouses AS budg
WHERE id IN (
    SELECT id FROM tasks AS emp
    WHERE emp.type = budg.type
);


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

SELECT value FROM warehouses AS prod
WHERE salary > (
    SELECT MAX(value) FROM invoices AS lne
    WHERE lne.id = prod.id
);


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

SELECT name FROM departments AS cust
WHERE value > (
    SELECT SUM(salary) FROM accounts AS whs
    WHERE whs.type = cust.type
);


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

SELECT name FROM warehouses AS lne
WHERE value > (
    SELECT SUM(salary) FROM employees AS dept
    WHERE dept.status = lne.status
);


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

SELECT id FROM transactions AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS empl
    WHERE empl.type = mgr.type
);


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

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


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

SELECT salary FROM shipments AS shp
WHERE status IN (
    SELECT status FROM projects AS lne
    WHERE lne.code = shp.code
);


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

SELECT amount FROM regions AS mgr
WHERE amount > (
    SELECT MIN(salary) FROM projects AS prod
    WHERE prod.type = mgr.type
);


Prompt:
Schema:
  transactions (alias: shp)(salary, level, date, status)
  suppliers(status, amount, level, salary)
Task: Retrieve amount from transactions with amount above the MAX(salary) of suppliers rows sharing the same level.
SQL:

SELECT amount FROM transactions AS shp
WHERE amount > (
    SELECT MAX(salary) FROM suppliers AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT amount FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.status = shp.status
);


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

SELECT name FROM suppliers AS catg
WHERE level IN (
    SELECT level FROM employees AS rgn
    WHERE rgn.id = catg.id
);


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

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


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT id FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.code = budg.code
);


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

SELECT salary FROM projects AS budg
WHERE status IN (
    SELECT status FROM transactions AS rgn
    WHERE rgn.type = budg.type
);


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

SELECT amount FROM accounts AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM projects AS sale
    WHERE sale.status = ordr.status
);


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

SELECT name FROM departments AS sale
WHERE level IN (
    SELECT level FROM shipments AS emp
    WHERE emp.status = sale.status
);


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

SELECT code FROM customers AS ord
WHERE status IN (
    SELECT status FROM categories AS acct
    WHERE acct.id = ord.id
);


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

SELECT salary FROM regions AS shp
WHERE code IN (
    SELECT code FROM invoices AS dept
    WHERE dept.code = shp.code
);


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

SELECT code FROM suppliers AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS shp
    WHERE shp.code = ordr.code
);


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

SELECT id FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.level = ordr.level
);