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

SELECT salary FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.id = dept.id
);


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

SELECT id FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.type = shp.type
);


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

SELECT value FROM projects AS txn
WHERE code IN (
    SELECT code FROM accounts AS cust
    WHERE cust.level = txn.level
);


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

SELECT name FROM customers AS inv
WHERE id IN (
    SELECT id FROM employees AS shp
    WHERE shp.status = inv.status
);


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

SELECT amount FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.type = catg.type
);


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

SELECT code FROM categories AS whs
WHERE value > (
    SELECT AVG(salary) FROM regions AS ord
    WHERE ord.type = whs.type
);


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

SELECT id FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.level = ord.level
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.type = txn.type
);


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

SELECT name FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.status = lne.status
);


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

SELECT name FROM transactions AS srvc
WHERE id IN (
    SELECT id FROM suppliers AS dept
    WHERE dept.level = srvc.level
);


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

SELECT name FROM branches AS lne
WHERE amount > (
    SELECT AVG(amount) FROM products AS shp
    WHERE shp.id = lne.id
);


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

SELECT value FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = cust.type
);


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

SELECT code FROM categories AS whs
WHERE amount > (
    SELECT MIN(salary) FROM branches AS catg
    WHERE catg.type = whs.type
);


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

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


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

SELECT name FROM branches AS catg
WHERE code IN (
    SELECT code FROM suppliers AS empl
    WHERE empl.code = catg.code
);


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

SELECT amount FROM regions AS dept
WHERE id IN (
    SELECT id FROM employees AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT code FROM shipments AS prod
WHERE id IN (
    SELECT id FROM projects AS budg
    WHERE budg.level = prod.level
);


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

SELECT name FROM customers AS budg
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT id FROM customers AS whs
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.code = whs.code
);


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

SELECT name FROM invoices AS dept
WHERE id IN (
    SELECT id FROM suppliers AS catg
    WHERE catg.code = dept.code
);


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

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


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

SELECT name FROM customers AS empl
WHERE salary > (
    SELECT COUNT(value) FROM warehouses AS budg
    WHERE budg.code = empl.code
);


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

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


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

SELECT id FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.code = schd.code
);


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

SELECT code FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.code = mgr.code
);


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

SELECT salary FROM customers AS prod
WHERE id IN (
    SELECT id FROM branches AS schd
    WHERE schd.type = prod.type
);


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

SELECT salary FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.level = inv.level
);


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

SELECT value FROM invoices AS shp
WHERE value > (
    SELECT AVG(value) FROM shipments AS budg
    WHERE budg.type = shp.type
);


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

SELECT code FROM shipments AS prod
WHERE status IN (
    SELECT status FROM regions AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT amount FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT name FROM branches AS sale
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.level = sale.level
);


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

SELECT name FROM categories AS lne
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS txn
    WHERE txn.type = lne.type
);


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

SELECT code FROM projects AS mgr
WHERE status IN (
    SELECT status FROM employees AS acct
    WHERE acct.status = mgr.status
);


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

SELECT id FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.type = acct.type
);


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

SELECT salary FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.type = acct.type
);


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

SELECT salary FROM branches AS acct
WHERE salary > (
    SELECT MAX(amount) FROM departments AS catg
    WHERE catg.type = acct.type
);


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

SELECT name FROM categories AS lne
WHERE status IN (
    SELECT status FROM projects AS shp
    WHERE shp.code = lne.code
);


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

SELECT name FROM tasks AS cust
WHERE type IN (
    SELECT type FROM products AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT name FROM shipments AS ord
WHERE salary > (
    SELECT SUM(value) FROM tasks AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT id FROM orders AS sale
WHERE type IN (
    SELECT type FROM products AS emp
    WHERE emp.id = sale.id
);


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

SELECT code FROM products AS catg
WHERE amount > (
    SELECT MAX(salary) FROM suppliers AS lne
    WHERE lne.status = catg.status
);


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

SELECT salary FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.code = schd.code
);


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

SELECT code FROM branches AS acct
WHERE salary > (
    SELECT MAX(salary) FROM regions AS txn
    WHERE txn.type = acct.type
);


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

SELECT amount FROM regions AS ordr
WHERE id IN (
    SELECT id FROM invoices AS emp
    WHERE emp.type = ordr.type
);


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

SELECT code FROM projects AS whs
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.level = whs.level
);


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

SELECT id FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.level = dept.level
);


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

SELECT name FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = cust.type
);


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

SELECT id FROM products AS budg
WHERE type IN (
    SELECT type FROM orders AS acct
    WHERE acct.type = budg.type
);


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

SELECT value FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.type = rgn.type
);


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

SELECT value FROM customers AS shp
WHERE type IN (
    SELECT type FROM branches AS mgr
    WHERE mgr.code = shp.code
);


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

SELECT value FROM shipments AS catg
WHERE id IN (
    SELECT id FROM accounts AS whs
    WHERE whs.level = catg.level
);


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

SELECT id FROM transactions AS ord
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.type = ord.type
);


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

SELECT name FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.code = budg.code
);


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

SELECT code FROM departments AS budg
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.id = budg.id
);


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

SELECT salary FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.status = schd.status
);


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

SELECT amount FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.status = rgn.status
);


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

SELECT value FROM tasks AS budg
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS txn
    WHERE txn.status = budg.status
);


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

SELECT value FROM warehouses AS mgr
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.type = mgr.type
);


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

SELECT value FROM regions AS ord
WHERE salary > (
    SELECT SUM(salary) FROM employees AS whs
    WHERE whs.type = ord.type
);


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

SELECT salary FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.status = rgn.status
);


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

SELECT name FROM tasks AS empl
WHERE value > (
    SELECT SUM(salary) FROM regions AS sale
    WHERE sale.level = empl.level
);


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

SELECT amount FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.status = dept.status
);


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

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


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

SELECT code FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.type = rgn.type
);


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

SELECT code FROM shipments AS cust
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS budg
    WHERE budg.id = cust.id
);


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

SELECT id FROM invoices AS shp
WHERE salary > (
    SELECT AVG(salary) FROM employees AS catg
    WHERE catg.code = shp.code
);


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

SELECT amount FROM warehouses AS emp
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS whs
    WHERE whs.level = emp.level
);


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

SELECT value FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.id = catg.id
);


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

SELECT value FROM products AS empl
WHERE id IN (
    SELECT id FROM orders AS srvc
    WHERE srvc.status = empl.status
);


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

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


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

SELECT code FROM categories AS srvc
WHERE value > (
    SELECT AVG(salary) FROM departments AS mgr
    WHERE mgr.type = srvc.type
);


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

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


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

SELECT code FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT amount FROM products AS shp
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS inv
    WHERE inv.level = shp.level
);


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

SELECT code FROM categories AS emp
WHERE value > (
    SELECT COUNT(amount) FROM customers AS ord
    WHERE ord.code = emp.code
);


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

SELECT name FROM branches AS ord
WHERE salary > (
    SELECT MIN(value) FROM transactions AS emp
    WHERE emp.code = ord.code
);


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

SELECT salary FROM branches AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM shipments AS sale
    WHERE sale.code = srvc.code
);


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

SELECT salary FROM warehouses AS dept
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS catg
    WHERE catg.id = dept.id
);


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

SELECT salary FROM transactions AS shp
WHERE amount > (
    SELECT AVG(amount) FROM regions AS acct
    WHERE acct.level = shp.level
);


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

SELECT amount FROM shipments AS cust
WHERE salary > (
    SELECT MAX(salary) FROM invoices AS budg
    WHERE budg.level = cust.level
);


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

SELECT value FROM employees AS ord
WHERE level IN (
    SELECT level FROM invoices AS acct
    WHERE acct.level = ord.level
);


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

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


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

SELECT value FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.status = whs.status
);


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

SELECT salary FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.code = acct.code
);


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

SELECT value FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.id = catg.id
);


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

SELECT code FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.type = empl.type
);


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

SELECT amount FROM customers AS emp
WHERE value > (
    SELECT MAX(amount) FROM products AS budg
    WHERE budg.status = emp.status
);


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

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


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

SELECT code FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT amount FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.level = catg.level
);


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

SELECT salary FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = emp.level
);


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

SELECT name FROM accounts AS txn
WHERE code IN (
    SELECT code FROM products AS inv
    WHERE inv.code = txn.code
);


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

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


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

SELECT value FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.id = cust.id
);


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

SELECT value FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.id = ord.id
);


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

SELECT code FROM departments AS budg
WHERE salary > (
    SELECT MAX(value) FROM projects AS empl
    WHERE empl.id = budg.id
);


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

SELECT salary FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.id = mgr.id
);


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

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


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

SELECT code FROM orders AS dept
WHERE value > (
    SELECT SUM(amount) FROM employees AS catg
    WHERE catg.status = dept.status
);


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

SELECT salary FROM branches AS rgn
WHERE id IN (
    SELECT id FROM regions AS catg
    WHERE catg.type = rgn.type
);


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

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


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

SELECT salary FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT value FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT id FROM departments AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM employees AS empl
    WHERE empl.status = srvc.status
);


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

SELECT code FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.code = srvc.code
);


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

SELECT code FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = emp.id
);


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

SELECT value FROM branches AS empl
WHERE value > (
    SELECT MIN(amount) FROM accounts AS shp
    WHERE shp.type = empl.type
);


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

SELECT salary FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.type = schd.type
);


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

SELECT amount FROM products AS dept
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.code = dept.code
);


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

SELECT id FROM regions AS ordr
WHERE amount > (
    SELECT MAX(amount) FROM orders AS dept
    WHERE dept.type = ordr.type
);


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

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


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

SELECT salary FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.status = ordr.status
);


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

SELECT value FROM shipments AS inv
WHERE id IN (
    SELECT id FROM departments AS txn
    WHERE txn.code = inv.code
);


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

SELECT amount FROM employees AS sale
WHERE status IN (
    SELECT status FROM departments AS catg
    WHERE catg.id = sale.id
);


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

SELECT name FROM products AS lne
WHERE salary > (
    SELECT MIN(value) FROM regions AS dept
    WHERE dept.id = lne.id
);


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

SELECT amount FROM departments AS cust
WHERE id IN (
    SELECT id FROM customers AS acct
    WHERE acct.type = cust.type
);


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

SELECT amount FROM products AS rgn
WHERE status IN (
    SELECT status FROM departments AS sale
    WHERE sale.type = rgn.type
);


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

SELECT code FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.type = txn.type
);


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

SELECT value FROM shipments AS sale
WHERE salary > (
    SELECT COUNT(value) FROM accounts AS mgr
    WHERE mgr.code = sale.code
);


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

SELECT code FROM accounts AS lne
WHERE amount > (
    SELECT MIN(salary) FROM products AS prod
    WHERE prod.level = lne.level
);


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

SELECT salary FROM projects AS txn
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS emp
    WHERE emp.id = txn.id
);


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

SELECT amount FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.type = empl.type
);


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

SELECT code FROM orders AS srvc
WHERE level IN (
    SELECT level FROM regions AS ord
    WHERE ord.code = srvc.code
);


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

SELECT id FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.level = budg.level
);


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

SELECT amount FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT salary FROM transactions AS shp
WHERE type IN (
    SELECT type FROM orders AS ord
    WHERE ord.status = shp.status
);


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

SELECT id FROM tasks AS catg
WHERE level IN (
    SELECT level FROM categories AS txn
    WHERE txn.code = catg.code
);


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

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


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

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


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

SELECT name FROM products AS srvc
WHERE salary > (
    SELECT AVG(value) FROM accounts AS mgr
    WHERE mgr.id = srvc.id
);


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

SELECT name FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.type = acct.type
);


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

SELECT code FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.id = empl.id
);


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

SELECT value FROM departments AS whs
WHERE status IN (
    SELECT status FROM branches AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT amount FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.id = lne.id
);


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

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


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

SELECT amount FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.code = budg.code
);


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

SELECT name FROM invoices AS catg
WHERE salary > (
    SELECT COUNT(value) FROM categories AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT code FROM regions AS whs
WHERE salary > (
    SELECT SUM(value) FROM employees AS inv
    WHERE inv.level = whs.level
);


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

SELECT amount FROM projects AS budg
WHERE type IN (
    SELECT type FROM transactions AS inv
    WHERE inv.type = budg.type
);


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

SELECT amount FROM orders AS txn
WHERE salary > (
    SELECT SUM(amount) FROM branches AS schd
    WHERE schd.status = txn.status
);


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

SELECT salary FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.level = mgr.level
);


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

SELECT value FROM accounts AS budg
WHERE value > (
    SELECT MAX(value) FROM shipments AS cust
    WHERE cust.status = budg.status
);


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

SELECT value FROM shipments AS srvc
WHERE value > (
    SELECT MAX(salary) FROM customers AS budg
    WHERE budg.code = srvc.code
);


Prompt:
Schema:
  suppliers (alias: ordr)(id, name, code, salary)
  departments(code, name, id, salary)
Task: Find amount from suppliers where code appears in departments entries with matching code.
SQL:

SELECT amount FROM suppliers AS ordr
WHERE code IN (
    SELECT code FROM departments AS schd
    WHERE schd.code = ordr.code
);


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

SELECT name FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT value FROM departments AS budg
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS cust
    WHERE cust.code = budg.code
);


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

SELECT id FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.status = sale.status
);


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

SELECT code FROM products AS lne
WHERE code IN (
    SELECT code FROM customers AS srvc
    WHERE srvc.type = lne.type
);


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

SELECT name FROM orders AS prod
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS catg
    WHERE catg.status = prod.status
);


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

SELECT name FROM shipments AS prod
WHERE id IN (
    SELECT id FROM branches AS empl
    WHERE empl.status = prod.status
);


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

SELECT name FROM suppliers AS catg
WHERE level IN (
    SELECT level FROM categories AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.type = emp.type
);


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

SELECT amount FROM accounts AS ordr
WHERE code IN (
    SELECT code FROM categories AS dept
    WHERE dept.code = ordr.code
);


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

SELECT id FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.code = sale.code
);


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

SELECT code FROM suppliers AS mgr
WHERE salary > (
    SELECT MAX(amount) FROM departments AS sale
    WHERE sale.status = mgr.status
);


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

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


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

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


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

SELECT value FROM shipments AS shp
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS empl
    WHERE empl.level = shp.level
);


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

SELECT salary FROM accounts AS rgn
WHERE status IN (
    SELECT status FROM warehouses AS prod
    WHERE prod.id = rgn.id
);


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

SELECT value FROM tasks AS cust
WHERE value > (
    SELECT MIN(value) FROM orders AS inv
    WHERE inv.code = cust.code
);


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

SELECT value FROM warehouses AS schd
WHERE status IN (
    SELECT status FROM customers AS emp
    WHERE emp.status = schd.status
);


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

SELECT name FROM accounts AS schd
WHERE salary > (
    SELECT MIN(salary) FROM branches AS srvc
    WHERE srvc.id = schd.id
);


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

SELECT id FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.status = dept.status
);


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

SELECT salary FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.status = rgn.status
);


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

SELECT amount FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.level = schd.level
);


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

SELECT salary FROM suppliers AS rgn
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS empl
    WHERE empl.code = rgn.code
);


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

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


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

SELECT salary FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.id = srvc.id
);


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

SELECT id FROM transactions AS shp
WHERE level IN (
    SELECT level FROM accounts AS ord
    WHERE ord.code = shp.code
);


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

SELECT salary FROM suppliers AS empl
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS inv
    WHERE inv.code = empl.code
);


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

SELECT salary FROM branches AS schd
WHERE id IN (
    SELECT id FROM regions AS txn
    WHERE txn.status = schd.status
);


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

SELECT amount FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.type = acct.type
);


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

SELECT name FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT amount FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT code FROM shipments AS whs
WHERE code IN (
    SELECT code FROM departments AS sale
    WHERE sale.id = whs.id
);


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

SELECT name FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.id = empl.id
);


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

SELECT id FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.level = emp.level
);


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

SELECT id FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.code = dept.code
);


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

SELECT name FROM accounts AS catg
WHERE type IN (
    SELECT type FROM categories AS dept
    WHERE dept.status = catg.status
);


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

SELECT salary FROM projects AS txn
WHERE amount > (
    SELECT SUM(amount) FROM suppliers AS sale
    WHERE sale.type = txn.type
);


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

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


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

SELECT id FROM transactions AS shp
WHERE value > (
    SELECT AVG(amount) FROM projects AS acct
    WHERE acct.status = shp.status
);


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

SELECT id FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.type = sale.type
);


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

SELECT name FROM warehouses AS schd
WHERE value > (
    SELECT MIN(value) FROM products AS lne
    WHERE lne.type = schd.type
);


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

SELECT id FROM warehouses AS lne
WHERE id IN (
    SELECT id FROM suppliers AS txn
    WHERE txn.id = lne.id
);


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

SELECT value FROM categories AS inv
WHERE amount > (
    SELECT MIN(value) FROM suppliers AS empl
    WHERE empl.status = inv.status
);


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

SELECT amount FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.type = mgr.type
);


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

SELECT name FROM projects AS budg
WHERE status IN (
    SELECT status FROM invoices AS dept
    WHERE dept.type = budg.type
);


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

SELECT salary FROM customers AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM categories AS whs
    WHERE whs.status = ordr.status
);


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

SELECT name FROM departments AS txn
WHERE status IN (
    SELECT status FROM transactions AS empl
    WHERE empl.id = txn.id
);


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

SELECT name FROM categories AS shp
WHERE salary > (
    SELECT MIN(amount) FROM branches AS sale
    WHERE sale.status = shp.status
);


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

SELECT code FROM projects AS shp
WHERE id IN (
    SELECT id FROM invoices AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT salary FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.type = schd.type
);


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

SELECT code FROM accounts AS txn
WHERE value > (
    SELECT COUNT(value) FROM employees AS dept
    WHERE dept.id = txn.id
);


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

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


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

SELECT code FROM categories AS sale
WHERE code IN (
    SELECT code FROM shipments AS cust
    WHERE cust.code = sale.code
);


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

SELECT salary FROM warehouses AS srvc
WHERE amount > (
    SELECT MIN(salary) FROM orders AS rgn
    WHERE rgn.id = srvc.id
);


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

SELECT salary FROM suppliers AS inv
WHERE amount > (
    SELECT MIN(value) FROM invoices AS lne
    WHERE lne.type = inv.type
);


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

SELECT value FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.code = srvc.code
);


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

SELECT amount FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.type = empl.type
);


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT AVG(value) FROM accounts AS whs
    WHERE whs.level = catg.level
);


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

SELECT code FROM employees AS dept
WHERE code IN (
    SELECT code FROM invoices AS empl
    WHERE empl.level = dept.level
);


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

SELECT value FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.id = catg.id
);


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

SELECT salary FROM products AS lne
WHERE level IN (
    SELECT level FROM invoices AS ord
    WHERE ord.code = lne.code
);


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

SELECT id FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.code = budg.code
);


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

SELECT value FROM tasks AS ordr
WHERE value > (
    SELECT MAX(salary) FROM orders AS catg
    WHERE catg.type = ordr.type
);


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

SELECT salary FROM orders AS whs
WHERE value > (
    SELECT SUM(salary) FROM categories AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT id FROM shipments AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS lne
    WHERE lne.code = mgr.code
);


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

SELECT code FROM accounts AS dept
WHERE type IN (
    SELECT type FROM categories AS sale
    WHERE sale.code = dept.code
);


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

SELECT amount FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = whs.level
);


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

SELECT salary FROM regions AS catg
WHERE value > (
    SELECT SUM(salary) FROM categories AS budg
    WHERE budg.type = catg.type
);


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

SELECT amount FROM customers AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM warehouses AS lne
    WHERE lne.type = ordr.type
);


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

SELECT id FROM products AS prod
WHERE value > (
    SELECT MIN(value) FROM branches AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT name FROM products AS sale
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT code FROM products AS sale
WHERE id IN (
    SELECT id FROM categories AS dept
    WHERE dept.code = sale.code
);


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

SELECT amount FROM transactions AS dept
WHERE salary > (
    SELECT MAX(salary) FROM invoices AS emp
    WHERE emp.id = dept.id
);


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

SELECT code FROM projects AS dept
WHERE salary > (
    SELECT SUM(value) FROM transactions AS schd
    WHERE schd.type = dept.type
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.level = cust.level
);


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

SELECT value FROM warehouses AS lne
WHERE type IN (
    SELECT type FROM orders AS catg
    WHERE catg.id = lne.id
);


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

SELECT id FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.level = srvc.level
);


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

SELECT salary FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.level = schd.level
);


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

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


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

SELECT amount FROM suppliers AS rgn
WHERE code IN (
    SELECT code FROM orders AS lne
    WHERE lne.id = rgn.id
);


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

SELECT code FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.level = ord.level
);


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

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


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

SELECT code FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.type = sale.type
);


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

SELECT amount FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.type = empl.type
);


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

SELECT id FROM categories AS cust
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS shp
    WHERE shp.id = cust.id
);


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

SELECT id FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.id = txn.id
);


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

SELECT amount FROM transactions AS catg
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.type = catg.type
);


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

SELECT value FROM accounts AS sale
WHERE salary > (
    SELECT COUNT(value) FROM suppliers AS empl
    WHERE empl.code = sale.code
);


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

SELECT name FROM categories AS inv
WHERE amount > (
    SELECT SUM(amount) FROM employees AS txn
    WHERE txn.code = inv.code
);


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

SELECT id FROM departments AS sale
WHERE id IN (
    SELECT id FROM warehouses AS acct
    WHERE acct.type = sale.type
);


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

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


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

SELECT value FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.type = sale.type
);


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

SELECT amount FROM regions AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM employees AS ord
    WHERE ord.type = rgn.type
);


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

SELECT code FROM departments AS sale
WHERE value > (
    SELECT SUM(amount) FROM accounts AS ord
    WHERE ord.code = sale.code
);


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

SELECT amount FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.status = acct.status
);


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

SELECT id FROM orders AS txn
WHERE amount > (
    SELECT MAX(amount) FROM departments AS empl
    WHERE empl.status = txn.status
);


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

SELECT name FROM products AS txn
WHERE value > (
    SELECT MIN(amount) FROM transactions AS whs
    WHERE whs.status = txn.status
);


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

SELECT amount FROM categories AS txn
WHERE salary > (
    SELECT MAX(salary) FROM products AS shp
    WHERE shp.type = txn.type
);


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

SELECT salary FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.type = acct.type
);


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

SELECT code FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT amount FROM transactions AS shp
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.code = shp.code
);


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

SELECT amount FROM tasks AS sale
WHERE salary > (
    SELECT AVG(value) FROM employees AS dept
    WHERE dept.id = sale.id
);


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

SELECT salary FROM customers AS ord
WHERE code IN (
    SELECT code FROM invoices AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT name FROM invoices AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM warehouses AS srvc
    WHERE srvc.id = whs.id
);


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

SELECT value FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.status = dept.status
);


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

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


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

SELECT salary FROM accounts AS schd
WHERE value > (
    SELECT MIN(salary) FROM suppliers AS whs
    WHERE whs.status = schd.status
);


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

SELECT value FROM departments AS ord
WHERE level IN (
    SELECT level FROM accounts AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT code FROM transactions AS cust
WHERE value > (
    SELECT MAX(value) FROM accounts AS sale
    WHERE sale.code = cust.code
);


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

SELECT value FROM products AS shp
WHERE type IN (
    SELECT type FROM projects AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT value FROM accounts AS rgn
WHERE status IN (
    SELECT status FROM customers AS empl
    WHERE empl.level = rgn.level
);


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

SELECT name FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.code = sale.code
);


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

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


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

SELECT amount FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.id = prod.id
);


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

SELECT salary FROM departments AS inv
WHERE salary > (
    SELECT AVG(amount) FROM customers AS whs
    WHERE whs.code = inv.code
);


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

SELECT id FROM invoices AS inv
WHERE amount > (
    SELECT AVG(salary) FROM projects AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT code FROM departments AS srvc
WHERE code IN (
    SELECT code FROM transactions AS sale
    WHERE sale.code = srvc.code
);


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

SELECT salary FROM warehouses AS cust
WHERE status IN (
    SELECT status FROM accounts AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT code FROM accounts AS ord
WHERE code IN (
    SELECT code FROM projects AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT code FROM customers AS ord
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT amount FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.level = prod.level
);


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

SELECT code FROM invoices AS mgr
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS lne
    WHERE lne.type = mgr.type
);


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

SELECT code FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.level = mgr.level
);


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

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


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

SELECT value FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.level = sale.level
);


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

SELECT salary FROM orders AS rgn
WHERE salary > (
    SELECT SUM(value) FROM tasks AS mgr
    WHERE mgr.level = rgn.level
);


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

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


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

SELECT id FROM regions AS prod
WHERE code IN (
    SELECT code FROM products AS txn
    WHERE txn.status = prod.status
);


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

SELECT code FROM departments AS rgn
WHERE status IN (
    SELECT status FROM employees AS sale
    WHERE sale.code = rgn.code
);


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

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


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

SELECT name FROM departments AS lne
WHERE value > (
    SELECT SUM(salary) FROM customers AS empl
    WHERE empl.status = lne.status
);


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

SELECT id FROM employees AS empl
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS acct
    WHERE acct.code = empl.code
);


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

SELECT value FROM orders AS acct
WHERE id IN (
    SELECT id FROM suppliers AS cust
    WHERE cust.type = acct.type
);


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

SELECT code FROM accounts AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS acct
    WHERE acct.type = empl.type
);


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

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


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

SELECT name FROM suppliers AS prod
WHERE level IN (
    SELECT level FROM accounts AS emp
    WHERE emp.type = prod.type
);


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

SELECT name FROM projects AS srvc
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS lne
    WHERE lne.status = srvc.status
);


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

SELECT code FROM invoices AS inv
WHERE value > (
    SELECT AVG(value) FROM products AS txn
    WHERE txn.level = inv.level
);


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

SELECT id FROM departments AS schd
WHERE value > (
    SELECT MIN(salary) FROM tasks AS sale
    WHERE sale.status = schd.status
);


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

SELECT value FROM invoices AS sale
WHERE amount > (
    SELECT MAX(salary) FROM departments AS txn
    WHERE txn.level = sale.level
);


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

SELECT salary FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.type = txn.type
);


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

SELECT name FROM shipments AS ordr
WHERE value > (
    SELECT AVG(salary) FROM invoices AS empl
    WHERE empl.type = ordr.type
);


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

SELECT name FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.code = sale.code
);


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

SELECT amount FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.level = txn.level
);


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

SELECT value FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.type = shp.type
);


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

SELECT name FROM products AS catg
WHERE code IN (
    SELECT code FROM regions AS sale
    WHERE sale.type = catg.type
);


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

SELECT id FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.type = cust.type
);


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

SELECT code FROM regions AS dept
WHERE amount > (
    SELECT MAX(value) FROM employees AS rgn
    WHERE rgn.id = dept.id
);


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

SELECT code FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.status = whs.status
);