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

SELECT amount FROM invoices AS prod
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS whs
    WHERE whs.code = prod.code
);


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

SELECT name FROM regions AS rgn
WHERE value > (
    SELECT SUM(salary) FROM products AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT amount FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.id = emp.id
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.level = catg.level
);


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

SELECT salary FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.code = prod.code
);


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

SELECT code FROM categories AS cust
WHERE status IN (
    SELECT status FROM departments AS inv
    WHERE inv.id = cust.id
);


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

SELECT code FROM categories AS budg
WHERE id IN (
    SELECT id FROM accounts AS lne
    WHERE lne.level = budg.level
);


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

SELECT value FROM warehouses AS whs
WHERE level IN (
    SELECT level FROM branches AS shp
    WHERE shp.code = whs.code
);


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

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


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

SELECT salary FROM suppliers AS prod
WHERE amount > (
    SELECT AVG(value) FROM accounts AS lne
    WHERE lne.id = prod.id
);


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

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


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

SELECT code FROM invoices AS lne
WHERE salary > (
    SELECT SUM(value) FROM orders AS dept
    WHERE dept.id = lne.id
);


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

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


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

SELECT code FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.level = dept.level
);


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

SELECT value FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.id = dept.id
);


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

SELECT code FROM invoices AS mgr
WHERE code IN (
    SELECT code FROM categories AS prod
    WHERE prod.type = mgr.type
);


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

SELECT name FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.code = lne.code
);


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

SELECT value FROM branches AS emp
WHERE value > (
    SELECT MIN(value) FROM invoices AS prod
    WHERE prod.code = emp.code
);


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

SELECT amount FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.level = srvc.level
);


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

SELECT name FROM shipments AS sale
WHERE salary > (
    SELECT MIN(amount) FROM categories AS cust
    WHERE cust.level = sale.level
);


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

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


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

SELECT amount FROM orders AS sale
WHERE status IN (
    SELECT status FROM shipments AS inv
    WHERE inv.level = sale.level
);


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

SELECT id FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.id = acct.id
);


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

SELECT name FROM employees AS dept
WHERE value > (
    SELECT MIN(amount) FROM invoices AS emp
    WHERE emp.level = dept.level
);


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

SELECT id FROM regions AS whs
WHERE type IN (
    SELECT type FROM tasks AS acct
    WHERE acct.status = whs.status
);


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

SELECT value FROM branches AS catg
WHERE level IN (
    SELECT level FROM tasks AS inv
    WHERE inv.id = catg.id
);


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

SELECT id FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = whs.status
);


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

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


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

SELECT code FROM invoices AS whs
WHERE type IN (
    SELECT type FROM regions AS budg
    WHERE budg.id = whs.id
);


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

SELECT salary FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.status = schd.status
);


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

SELECT id FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.code = ordr.code
);


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

SELECT amount FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.status = dept.status
);


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

SELECT amount FROM employees AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM orders AS srvc
    WHERE srvc.status = ordr.status
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT amount FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.status = budg.status
);


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

SELECT name FROM transactions AS srvc
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS whs
    WHERE whs.status = srvc.status
);


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

SELECT name FROM projects AS acct
WHERE level IN (
    SELECT level FROM invoices AS shp
    WHERE shp.level = acct.level
);


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

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


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

SELECT salary FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT amount FROM employees AS sale
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS srvc
    WHERE srvc.code = sale.code
);


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

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


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

SELECT salary FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.level = txn.level
);


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

SELECT amount FROM projects AS cust
WHERE status IN (
    SELECT status FROM branches AS budg
    WHERE budg.code = cust.code
);


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

SELECT amount FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.id = inv.id
);


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

SELECT amount FROM warehouses AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM departments AS budg
    WHERE budg.status = mgr.status
);


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

SELECT amount FROM regions AS schd
WHERE amount > (
    SELECT SUM(value) FROM shipments AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT id FROM customers AS ordr
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.level = ordr.level
);


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

SELECT salary FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.type = emp.type
);


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

SELECT value FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.code = sale.code
);


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

SELECT salary FROM branches AS emp
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS mgr
    WHERE mgr.id = emp.id
);


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

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


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

SELECT name FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.level = prod.level
);


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

SELECT amount FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.type = empl.type
);


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

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


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

SELECT salary FROM transactions AS shp
WHERE status IN (
    SELECT status FROM warehouses AS catg
    WHERE catg.code = shp.code
);


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

SELECT salary FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.code = schd.code
);


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

SELECT id FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.id = srvc.id
);


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

SELECT code FROM transactions AS shp
WHERE value > (
    SELECT MIN(salary) FROM shipments AS txn
    WHERE txn.level = shp.level
);


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

SELECT salary FROM projects AS schd
WHERE code IN (
    SELECT code FROM orders AS shp
    WHERE shp.code = schd.code
);


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

SELECT amount FROM transactions AS srvc
WHERE amount > (
    SELECT SUM(amount) FROM employees AS empl
    WHERE empl.id = srvc.id
);


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

SELECT amount FROM warehouses AS budg
WHERE code IN (
    SELECT code FROM invoices AS cust
    WHERE cust.type = budg.type
);


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

SELECT amount FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.status = shp.status
);


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

SELECT value FROM invoices AS schd
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS catg
    WHERE catg.level = schd.level
);


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

SELECT id FROM departments AS whs
WHERE code IN (
    SELECT code FROM branches AS rgn
    WHERE rgn.status = whs.status
);


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

SELECT value FROM transactions AS mgr
WHERE salary > (
    SELECT SUM(value) FROM categories AS schd
    WHERE schd.type = mgr.type
);


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

SELECT code FROM tasks AS catg
WHERE salary > (
    SELECT AVG(amount) FROM employees AS cust
    WHERE cust.code = catg.code
);


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

SELECT value FROM employees AS empl
WHERE value > (
    SELECT COUNT(value) FROM categories AS schd
    WHERE schd.id = empl.id
);


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

SELECT name FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.code = schd.code
);


Prompt:
Schema:
  products (alias: inv)(code, name, date, level)
  branches(amount, type, salary, 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 inv
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.id = inv.id
);


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

SELECT name FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.status = rgn.status
);


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

SELECT salary FROM suppliers AS whs
WHERE salary > (
    SELECT MAX(value) FROM invoices AS empl
    WHERE empl.code = whs.code
);


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

SELECT id FROM accounts AS ordr
WHERE code IN (
    SELECT code FROM transactions AS emp
    WHERE emp.code = ordr.code
);


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

SELECT code FROM warehouses AS sale
WHERE value > (
    SELECT AVG(salary) FROM products AS schd
    WHERE schd.level = sale.level
);


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

SELECT id FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.type = inv.type
);


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

SELECT salary FROM customers AS budg
WHERE amount > (
    SELECT MIN(value) FROM transactions AS ord
    WHERE ord.status = budg.status
);


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

SELECT id FROM accounts AS sale
WHERE salary > (
    SELECT MIN(amount) FROM tasks AS prod
    WHERE prod.id = sale.id
);


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

SELECT id FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.type = txn.type
);


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

SELECT id FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.code = ordr.code
);


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

SELECT value FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.status = txn.status
);


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

SELECT name FROM suppliers AS txn
WHERE amount > (
    SELECT COUNT(value) FROM orders AS prod
    WHERE prod.code = txn.code
);


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

SELECT amount FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.type = lne.type
);


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

SELECT amount FROM employees AS sale
WHERE id IN (
    SELECT id FROM warehouses AS prod
    WHERE prod.status = sale.status
);


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

SELECT name FROM suppliers AS whs
WHERE amount > (
    SELECT MIN(salary) FROM orders AS lne
    WHERE lne.code = whs.code
);


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

SELECT code FROM tasks AS ordr
WHERE level IN (
    SELECT level FROM products AS ord
    WHERE ord.type = ordr.type
);


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

SELECT code FROM products AS schd
WHERE amount > (
    SELECT AVG(value) FROM projects AS emp
    WHERE emp.level = schd.level
);


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

SELECT id FROM accounts AS dept
WHERE salary > (
    SELECT AVG(amount) FROM regions AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT code FROM transactions AS rgn
WHERE salary > (
    SELECT COUNT(value) FROM suppliers AS ordr
    WHERE ordr.level = rgn.level
);


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

SELECT salary FROM departments AS acct
WHERE amount > (
    SELECT MIN(value) FROM accounts AS shp
    WHERE shp.id = acct.id
);


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

SELECT value FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.status = ord.status
);


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

SELECT code FROM shipments AS dept
WHERE type IN (
    SELECT type FROM employees AS inv
    WHERE inv.type = dept.type
);


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

SELECT salary FROM products AS catg
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.type = catg.type
);


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

SELECT code FROM regions AS emp
WHERE code IN (
    SELECT code FROM products AS cust
    WHERE cust.type = emp.type
);


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

SELECT code FROM projects AS empl
WHERE value > (
    SELECT AVG(value) FROM transactions AS cust
    WHERE cust.type = empl.type
);


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

SELECT id FROM transactions AS acct
WHERE code IN (
    SELECT code FROM customers AS srvc
    WHERE srvc.type = acct.type
);


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

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


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

SELECT amount FROM shipments AS txn
WHERE status IN (
    SELECT status FROM branches AS sale
    WHERE sale.type = txn.type
);


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

SELECT salary FROM employees AS acct
WHERE value > (
    SELECT MIN(amount) FROM warehouses AS txn
    WHERE txn.id = acct.id
);


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

SELECT value FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT name FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT amount FROM projects AS cust
WHERE value > (
    SELECT MIN(amount) FROM tasks AS whs
    WHERE whs.id = cust.id
);


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

SELECT id FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.level = txn.level
);


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

SELECT id FROM regions AS cust
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.status = cust.status
);


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

SELECT name FROM customers AS srvc
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.type = srvc.type
);


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

SELECT name FROM employees AS whs
WHERE value > (
    SELECT AVG(amount) FROM invoices AS acct
    WHERE acct.type = whs.type
);


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

SELECT name FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.code = inv.code
);


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

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


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

SELECT amount FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.type = budg.type
);


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

SELECT amount FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.status = whs.status
);


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

SELECT code FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.code = srvc.code
);


Prompt:
Schema:
  branches (alias: inv)(status, salary, level, amount)
  shipments(level, amount, type, salary)
Task: Retrieve salary from branches with amount above the MAX(salary) of shipments rows sharing the same level.
SQL:

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


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

SELECT name FROM invoices AS mgr
WHERE id IN (
    SELECT id FROM transactions AS prod
    WHERE prod.type = mgr.type
);


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

SELECT name FROM branches AS whs
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS srvc
    WHERE srvc.id = whs.id
);


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

SELECT amount FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.status = budg.status
);


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

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


Prompt:
Schema:
  projects (alias: catg)(type, salary, amount, value)
  shipments(date, level, type, salary)
Task: Retrieve value from projects with salary above the COUNT(salary) of shipments rows sharing the same type.
SQL:

SELECT value FROM projects AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS dept
    WHERE dept.type = catg.type
);


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

SELECT amount FROM branches AS acct
WHERE amount > (
    SELECT MAX(value) FROM orders AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT amount FROM projects AS rgn
WHERE amount > (
    SELECT SUM(value) FROM customers AS schd
    WHERE schd.type = rgn.type
);


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = whs.status
);


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

SELECT value FROM products AS prod
WHERE code IN (
    SELECT code FROM projects AS mgr
    WHERE mgr.type = prod.type
);


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

SELECT amount FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.id = cust.id
);


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

SELECT id FROM transactions AS dept
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.status = dept.status
);


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

SELECT code FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.id = shp.id
);


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

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


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

SELECT code FROM shipments AS prod
WHERE value > (
    SELECT SUM(salary) FROM transactions AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT id FROM shipments AS inv
WHERE value > (
    SELECT COUNT(value) FROM projects AS cust
    WHERE cust.id = inv.id
);


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

SELECT id FROM categories AS acct
WHERE level IN (
    SELECT level FROM suppliers AS inv
    WHERE inv.type = acct.type
);


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

SELECT name FROM invoices AS shp
WHERE salary > (
    SELECT MAX(value) FROM transactions AS txn
    WHERE txn.code = shp.code
);


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

SELECT amount FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.id = rgn.id
);


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

SELECT value FROM projects AS lne
WHERE level IN (
    SELECT level FROM employees AS shp
    WHERE shp.code = lne.code
);


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

SELECT id FROM suppliers AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS ord
    WHERE ord.status = schd.status
);


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

SELECT amount FROM employees AS whs
WHERE id IN (
    SELECT id FROM regions AS acct
    WHERE acct.code = whs.code
);


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

SELECT salary FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.code = budg.code
);


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

SELECT code FROM suppliers AS emp
WHERE type IN (
    SELECT type FROM departments AS acct
    WHERE acct.level = emp.level
);


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

SELECT name FROM orders AS budg
WHERE value > (
    SELECT MIN(amount) FROM employees AS cust
    WHERE cust.id = budg.id
);


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

SELECT code FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.type = ordr.type
);


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

SELECT value FROM customers AS inv
WHERE code IN (
    SELECT code FROM shipments AS sale
    WHERE sale.code = inv.code
);


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

SELECT code FROM projects AS inv
WHERE amount > (
    SELECT AVG(salary) FROM branches AS schd
    WHERE schd.level = inv.level
);


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

SELECT name FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.id = dept.id
);


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

SELECT name FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.type = srvc.type
);


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

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


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

SELECT code FROM orders AS cust
WHERE code IN (
    SELECT code FROM warehouses AS sale
    WHERE sale.code = cust.code
);


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

SELECT code FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.code = dept.code
);


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

SELECT amount FROM suppliers AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS schd
    WHERE schd.type = txn.type
);


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

SELECT amount FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.status = schd.status
);


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

SELECT code FROM departments AS rgn
WHERE id IN (
    SELECT id FROM products AS shp
    WHERE shp.status = rgn.status
);


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

SELECT value FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = shp.id
);


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

SELECT value FROM shipments AS shp
WHERE value > (
    SELECT MIN(salary) FROM transactions AS emp
    WHERE emp.status = shp.status
);


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

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


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

SELECT id FROM accounts AS budg
WHERE salary > (
    SELECT MAX(value) FROM branches AS lne
    WHERE lne.id = budg.id
);


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

SELECT code FROM accounts AS schd
WHERE value > (
    SELECT AVG(salary) FROM branches AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT code FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.level = catg.level
);


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

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


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

SELECT value FROM branches AS prod
WHERE type IN (
    SELECT type FROM invoices AS sale
    WHERE sale.id = prod.id
);


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

SELECT amount FROM regions AS rgn
WHERE id IN (
    SELECT id FROM customers AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT salary FROM warehouses AS lne
WHERE salary > (
    SELECT MAX(salary) FROM categories AS budg
    WHERE budg.level = lne.level
);


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

SELECT value FROM orders AS sale
WHERE status IN (
    SELECT status FROM accounts AS dept
    WHERE dept.level = sale.level
);


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

SELECT id FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.code = cust.code
);


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

SELECT name FROM suppliers AS rgn
WHERE value > (
    SELECT COUNT(amount) FROM invoices AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT name FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT code FROM categories AS catg
WHERE salary > (
    SELECT AVG(value) FROM tasks AS inv
    WHERE inv.status = catg.status
);


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

SELECT salary FROM regions AS cust
WHERE status IN (
    SELECT status FROM employees AS sale
    WHERE sale.id = cust.id
);


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

SELECT amount FROM products AS schd
WHERE code IN (
    SELECT code FROM employees AS budg
    WHERE budg.code = schd.code
);


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

SELECT amount FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.id = schd.id
);


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

SELECT amount FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT salary FROM shipments AS sale
WHERE value > (
    SELECT SUM(amount) FROM transactions AS inv
    WHERE inv.type = sale.type
);


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

SELECT name FROM employees AS ordr
WHERE value > (
    SELECT AVG(salary) FROM categories AS acct
    WHERE acct.code = ordr.code
);


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

SELECT salary FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT name FROM departments AS cust
WHERE amount > (
    SELECT MIN(value) FROM tasks AS emp
    WHERE emp.code = cust.code
);


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

SELECT salary FROM branches AS rgn
WHERE value > (
    SELECT MIN(amount) FROM tasks AS schd
    WHERE schd.status = rgn.status
);


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

SELECT name FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.type = dept.type
);


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

SELECT code FROM shipments AS budg
WHERE type IN (
    SELECT type FROM branches AS rgn
    WHERE rgn.code = budg.code
);


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

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


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

SELECT salary FROM customers AS lne
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT id FROM shipments AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM categories AS sale
    WHERE sale.code = ordr.code
);


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

SELECT amount FROM categories AS whs
WHERE amount > (
    SELECT AVG(amount) FROM departments AS acct
    WHERE acct.code = whs.code
);


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

SELECT amount FROM orders AS emp
WHERE code IN (
    SELECT code FROM invoices AS lne
    WHERE lne.status = emp.status
);


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

SELECT amount FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.type = sale.type
);


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

SELECT value FROM projects AS dept
WHERE id IN (
    SELECT id FROM tasks AS empl
    WHERE empl.level = dept.level
);


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

SELECT salary FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.type = schd.type
);


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

SELECT amount FROM shipments AS cust
WHERE value > (
    SELECT AVG(salary) FROM categories AS schd
    WHERE schd.id = cust.id
);


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

SELECT amount FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.id = emp.id
);


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

SELECT name FROM orders AS sale
WHERE id IN (
    SELECT id FROM employees AS dept
    WHERE dept.type = sale.type
);


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

SELECT id FROM products AS ord
WHERE status IN (
    SELECT status FROM invoices AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT value FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.level = acct.level
);


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

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


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

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


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

SELECT amount FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.code = emp.code
);


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

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


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

SELECT id FROM orders AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM shipments AS budg
    WHERE budg.level = empl.level
);


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

SELECT value FROM regions AS inv
WHERE amount > (
    SELECT AVG(value) FROM departments AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT name FROM categories AS empl
WHERE salary > (
    SELECT MIN(value) FROM tasks AS lne
    WHERE lne.id = empl.id
);


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

SELECT value FROM accounts AS rgn
WHERE id IN (
    SELECT id FROM products AS inv
    WHERE inv.type = rgn.type
);


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

SELECT value FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.type = ordr.type
);


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

SELECT salary FROM warehouses AS empl
WHERE amount > (
    SELECT MAX(salary) FROM orders AS srvc
    WHERE srvc.level = empl.level
);


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

SELECT value FROM projects AS empl
WHERE status IN (
    SELECT status FROM categories AS catg
    WHERE catg.type = empl.type
);


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

SELECT amount FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.level = schd.level
);


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

SELECT code FROM categories AS ordr
WHERE type IN (
    SELECT type FROM products AS cust
    WHERE cust.type = ordr.type
);


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

SELECT id FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT name FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.level = catg.level
);


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

SELECT id FROM customers AS rgn
WHERE status IN (
    SELECT status FROM departments AS lne
    WHERE lne.code = rgn.code
);


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

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


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

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


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

SELECT amount FROM branches AS prod
WHERE salary > (
    SELECT SUM(value) FROM invoices AS lne
    WHERE lne.code = prod.code
);


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

SELECT amount FROM invoices AS whs
WHERE level IN (
    SELECT level FROM projects AS ord
    WHERE ord.status = whs.status
);


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

SELECT code FROM projects AS acct
WHERE amount > (
    SELECT AVG(value) FROM orders AS whs
    WHERE whs.level = acct.level
);


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

SELECT code FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.status = srvc.status
);


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

SELECT code FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.id = acct.id
);


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

SELECT name FROM shipments AS srvc
WHERE id IN (
    SELECT id FROM employees AS ordr
    WHERE ordr.status = srvc.status
);


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

SELECT code FROM products AS shp
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.id = shp.id
);


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

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


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

SELECT name FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT value FROM tasks AS inv
WHERE level IN (
    SELECT level FROM suppliers AS ord
    WHERE ord.type = inv.type
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.status = emp.status
);


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

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


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

SELECT salary FROM regions AS dept
WHERE type IN (
    SELECT type FROM branches AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT id FROM branches AS ord
WHERE amount > (
    SELECT SUM(value) FROM orders AS txn
    WHERE txn.status = ord.status
);


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

SELECT id FROM tasks AS dept
WHERE value > (
    SELECT COUNT(amount) FROM employees AS catg
    WHERE catg.code = dept.code
);


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

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


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

SELECT name FROM suppliers AS lne
WHERE value > (
    SELECT MAX(salary) FROM regions AS txn
    WHERE txn.id = lne.id
);


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

SELECT name FROM branches AS srvc
WHERE code IN (
    SELECT code FROM departments AS emp
    WHERE emp.status = srvc.status
);


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

SELECT amount FROM branches AS emp
WHERE id IN (
    SELECT id FROM tasks AS cust
    WHERE cust.status = emp.status
);


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

SELECT code FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.status = inv.status
);


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

SELECT id FROM suppliers AS catg
WHERE status IN (
    SELECT status FROM transactions AS cust
    WHERE cust.type = catg.type
);


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

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


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

SELECT name FROM projects AS sale
WHERE salary > (
    SELECT AVG(value) FROM orders AS empl
    WHERE empl.status = sale.status
);


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

SELECT name FROM warehouses AS txn
WHERE value > (
    SELECT AVG(value) FROM orders AS budg
    WHERE budg.code = txn.code
);


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

SELECT code FROM regions AS cust
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.code = cust.code
);


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

SELECT amount FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT id FROM projects AS whs
WHERE amount > (
    SELECT MIN(value) FROM employees AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT id FROM products AS ord
WHERE salary > (
    SELECT MAX(value) FROM branches AS inv
    WHERE inv.status = ord.status
);


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

SELECT id FROM regions AS acct
WHERE type IN (
    SELECT type FROM products AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT code FROM categories AS emp
WHERE id IN (
    SELECT id FROM branches AS acct
    WHERE acct.status = emp.status
);


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

SELECT id FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT name FROM employees AS sale
WHERE code IN (
    SELECT code FROM warehouses AS schd
    WHERE schd.id = sale.id
);


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

SELECT salary FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.code = sale.code
);


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

SELECT name FROM projects AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT code FROM transactions AS txn
WHERE code IN (
    SELECT code FROM accounts AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT id FROM projects AS inv
WHERE id IN (
    SELECT id FROM categories AS budg
    WHERE budg.level = inv.level
);


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

SELECT name FROM employees AS cust
WHERE amount > (
    SELECT MAX(value) FROM tasks AS whs
    WHERE whs.id = cust.id
);


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

SELECT salary FROM accounts AS budg
WHERE value > (
    SELECT MIN(salary) FROM customers AS lne
    WHERE lne.level = budg.level
);


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

SELECT name FROM employees AS acct
WHERE status IN (
    SELECT status FROM customers AS schd
    WHERE schd.status = acct.status
);


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

SELECT value FROM transactions AS srvc
WHERE value > (
    SELECT MIN(value) FROM tasks AS prod
    WHERE prod.level = srvc.level
);


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

SELECT value FROM projects AS txn
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.level = txn.level
);


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

SELECT id FROM warehouses AS catg
WHERE level IN (
    SELECT level FROM employees AS acct
    WHERE acct.id = catg.id
);


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

SELECT salary FROM customers AS txn
WHERE level IN (
    SELECT level FROM suppliers AS ord
    WHERE ord.level = txn.level
);


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

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


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

SELECT amount FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.level = cust.level
);


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

SELECT code FROM departments AS prod
WHERE value > (
    SELECT MIN(amount) FROM branches AS inv
    WHERE inv.status = prod.status
);


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

SELECT code FROM transactions AS mgr
WHERE level IN (
    SELECT level FROM customers AS catg
    WHERE catg.type = mgr.type
);


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

SELECT amount FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = lne.code
);


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

SELECT name FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.level = schd.level
);


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

SELECT name FROM warehouses AS shp
WHERE value > (
    SELECT MIN(value) FROM transactions AS empl
    WHERE empl.level = shp.level
);


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

SELECT amount FROM branches AS empl
WHERE type IN (
    SELECT type FROM accounts AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT amount FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.level = mgr.level
);


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

SELECT id FROM suppliers AS mgr
WHERE status IN (
    SELECT status FROM branches AS inv
    WHERE inv.level = mgr.level
);


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

SELECT salary FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT amount FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.code = dept.code
);


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

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


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

SELECT id FROM shipments AS rgn
WHERE status IN (
    SELECT status FROM customers AS catg
    WHERE catg.id = rgn.id
);


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

SELECT code FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.id = inv.id
);


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

SELECT code FROM projects AS lne
WHERE type IN (
    SELECT type FROM categories AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT name FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.level = empl.level
);


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

SELECT name FROM projects AS inv
WHERE value > (
    SELECT MAX(salary) FROM branches AS budg
    WHERE budg.type = inv.type
);


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

SELECT name FROM products AS txn
WHERE status IN (
    SELECT status FROM categories AS emp
    WHERE emp.type = txn.type
);


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

SELECT name FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.type = empl.type
);


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

SELECT amount FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.id = cust.id
);


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

SELECT salary FROM orders AS mgr
WHERE id IN (
    SELECT id FROM invoices AS empl
    WHERE empl.type = mgr.type
);


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

SELECT code FROM warehouses AS emp
WHERE amount > (
    SELECT MIN(salary) FROM orders AS dept
    WHERE dept.id = emp.id
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.id = emp.id
);


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

SELECT amount FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.code = empl.code
);


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

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


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

SELECT id FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.code = acct.code
);


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

SELECT code FROM customers AS txn
WHERE id IN (
    SELECT id FROM categories AS inv
    WHERE inv.level = txn.level
);


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

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


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

SELECT id FROM accounts AS budg
WHERE value > (
    SELECT AVG(salary) FROM categories AS dept
    WHERE dept.code = budg.code
);


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

SELECT value FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.code = txn.code
);


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

SELECT amount FROM employees AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM suppliers AS prod
    WHERE prod.id = lne.id
);


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

SELECT name FROM accounts AS txn
WHERE code IN (
    SELECT code FROM shipments AS srvc
    WHERE srvc.id = txn.id
);


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

SELECT id FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.id = whs.id
);


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

SELECT code FROM accounts AS empl
WHERE amount > (
    SELECT SUM(salary) FROM regions AS prod
    WHERE prod.status = empl.status
);


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

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


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

SELECT amount FROM shipments AS schd
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.level = schd.level
);


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

SELECT value FROM transactions AS emp
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS cust
    WHERE cust.type = emp.type
);


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

SELECT code FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.level = acct.level
);


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

SELECT code FROM products AS ord
WHERE value > (
    SELECT SUM(value) FROM transactions AS lne
    WHERE lne.status = ord.status
);


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

SELECT value FROM accounts AS budg
WHERE level IN (
    SELECT level FROM customers AS txn
    WHERE txn.code = budg.code
);


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

SELECT amount FROM products AS shp
WHERE value > (
    SELECT SUM(salary) FROM tasks AS srvc
    WHERE srvc.id = shp.id
);


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

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


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

SELECT amount FROM customers AS ordr
WHERE type IN (
    SELECT type FROM suppliers AS sale
    WHERE sale.level = ordr.level
);


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

SELECT name FROM tasks AS sale
WHERE id IN (
    SELECT id FROM projects AS lne
    WHERE lne.type = sale.type
);


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

SELECT code FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.id = lne.id
);


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

SELECT code FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.id = budg.id
);


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

SELECT id FROM projects AS empl
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS budg
    WHERE budg.type = empl.type
);


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

SELECT value FROM departments AS acct
WHERE value > (
    SELECT COUNT(value) FROM regions AS schd
    WHERE schd.status = acct.status
);