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

SELECT code FROM customers AS inv
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS schd
    WHERE schd.id = inv.id
);


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

SELECT value FROM orders AS whs
WHERE type IN (
    SELECT type FROM projects AS schd
    WHERE schd.code = whs.code
);


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

SELECT salary FROM accounts AS catg
WHERE id IN (
    SELECT id FROM categories AS ord
    WHERE ord.code = catg.code
);


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

SELECT value FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.status = dept.status
);


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

SELECT amount FROM transactions AS ordr
WHERE level IN (
    SELECT level FROM orders AS mgr
    WHERE mgr.id = ordr.id
);


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

SELECT code FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.type = empl.type
);


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

SELECT amount FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.level = ordr.level
);


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

SELECT code FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.id = srvc.id
);


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

SELECT code FROM transactions AS rgn
WHERE level IN (
    SELECT level FROM suppliers AS ord
    WHERE ord.id = rgn.id
);


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

SELECT amount FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.status = catg.status
);


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

SELECT code FROM accounts AS srvc
WHERE value > (
    SELECT SUM(value) FROM invoices AS acct
    WHERE acct.code = srvc.code
);


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

SELECT id FROM departments AS inv
WHERE type IN (
    SELECT type FROM suppliers AS catg
    WHERE catg.code = inv.code
);


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

SELECT value FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT code FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.type = acct.type
);


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

SELECT code FROM customers AS schd
WHERE level IN (
    SELECT level FROM regions AS emp
    WHERE emp.code = schd.code
);


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

SELECT amount FROM shipments AS rgn
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.code = rgn.code
);


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

SELECT amount FROM transactions AS schd
WHERE salary > (
    SELECT MAX(value) FROM departments AS ord
    WHERE ord.level = schd.level
);


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

SELECT salary FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.id = catg.id
);


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

SELECT code FROM branches AS ord
WHERE salary > (
    SELECT AVG(amount) FROM orders AS schd
    WHERE schd.code = ord.code
);


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

SELECT amount FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.code = dept.code
);


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

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


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

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


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

SELECT code FROM regions AS shp
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS dept
    WHERE dept.status = shp.status
);


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

SELECT id FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.type = schd.type
);


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

SELECT name FROM branches AS whs
WHERE status IN (
    SELECT status FROM suppliers AS txn
    WHERE txn.id = whs.id
);


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

SELECT salary FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT value FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.id = srvc.id
);


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

SELECT code FROM departments AS rgn
WHERE value > (
    SELECT AVG(salary) FROM shipments AS sale
    WHERE sale.level = rgn.level
);


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

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


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

SELECT name FROM regions AS shp
WHERE type IN (
    SELECT type FROM warehouses AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT id FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.level = ord.level
);


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

SELECT id FROM warehouses AS inv
WHERE value > (
    SELECT AVG(salary) FROM accounts AS mgr
    WHERE mgr.status = inv.status
);


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

SELECT name FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = acct.type
);


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

SELECT amount FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.id = schd.id
);


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

SELECT id FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.type = mgr.type
);


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

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


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

SELECT name FROM warehouses AS empl
WHERE type IN (
    SELECT type FROM products AS acct
    WHERE acct.status = empl.status
);


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

SELECT id FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.type = empl.type
);


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

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


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

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


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

SELECT amount FROM regions AS dept
WHERE code IN (
    SELECT code FROM orders AS schd
    WHERE schd.level = dept.level
);


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

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


Prompt:
Schema:
  tasks (alias: srvc)(code, level, value, amount)
  warehouses(status, id, level, date)
Task: Retrieve amount from tasks with value above the SUM(value) of warehouses rows sharing the same id.
SQL:

SELECT amount FROM tasks AS srvc
WHERE value > (
    SELECT SUM(value) FROM warehouses AS rgn
    WHERE rgn.id = srvc.id
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.type = catg.type
);


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

SELECT name FROM departments AS catg
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS ord
    WHERE ord.type = catg.type
);


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

SELECT amount FROM warehouses AS srvc
WHERE value > (
    SELECT AVG(value) FROM transactions AS ord
    WHERE ord.status = srvc.status
);


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

SELECT salary FROM accounts AS txn
WHERE status IN (
    SELECT status FROM employees AS acct
    WHERE acct.status = txn.status
);


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

SELECT value FROM orders AS lne
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS budg
    WHERE budg.code = lne.code
);


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

SELECT value FROM categories AS rgn
WHERE salary > (
    SELECT MAX(amount) FROM suppliers AS whs
    WHERE whs.code = rgn.code
);


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

SELECT id FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT amount FROM products AS lne
WHERE amount > (
    SELECT MAX(value) FROM invoices AS budg
    WHERE budg.level = lne.level
);


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

SELECT code FROM invoices AS lne
WHERE amount > (
    SELECT COUNT(value) FROM categories AS rgn
    WHERE rgn.status = lne.status
);


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

SELECT id FROM transactions AS schd
WHERE value > (
    SELECT COUNT(salary) FROM products AS srvc
    WHERE srvc.code = schd.code
);


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

SELECT amount FROM categories AS cust
WHERE type IN (
    SELECT type FROM transactions AS ord
    WHERE ord.type = cust.type
);


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

SELECT value FROM orders AS ordr
WHERE id IN (
    SELECT id FROM regions AS emp
    WHERE emp.code = ordr.code
);


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

SELECT name FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = srvc.status
);


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

SELECT amount FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.status = shp.status
);


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

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


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

SELECT amount FROM customers AS srvc
WHERE type IN (
    SELECT type FROM branches AS ord
    WHERE ord.id = srvc.id
);


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

SELECT value FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.level = whs.level
);


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

SELECT name FROM warehouses AS txn
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS shp
    WHERE shp.level = txn.level
);


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

SELECT value FROM shipments AS schd
WHERE code IN (
    SELECT code FROM customers AS rgn
    WHERE rgn.level = schd.level
);


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

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


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

SELECT id FROM accounts AS acct
WHERE id IN (
    SELECT id FROM customers AS empl
    WHERE empl.level = acct.level
);


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

SELECT code FROM tasks AS shp
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS acct
    WHERE acct.id = shp.id
);


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

SELECT name FROM suppliers AS lne
WHERE amount > (
    SELECT MIN(salary) FROM products AS sale
    WHERE sale.type = lne.type
);


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

SELECT amount FROM customers AS catg
WHERE value > (
    SELECT COUNT(salary) FROM projects AS ord
    WHERE ord.level = catg.level
);


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

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


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

SELECT code FROM regions AS shp
WHERE code IN (
    SELECT code FROM warehouses AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT code FROM orders AS ord
WHERE amount > (
    SELECT SUM(salary) FROM products AS prod
    WHERE prod.level = ord.level
);


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

SELECT salary FROM categories AS inv
WHERE code IN (
    SELECT code FROM customers AS emp
    WHERE emp.status = inv.status
);


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

SELECT amount FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.id = whs.id
);


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

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


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

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


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

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


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

SELECT amount FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.code = catg.code
);


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

SELECT value FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.id = sale.id
);


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

SELECT salary FROM branches AS cust
WHERE id IN (
    SELECT id FROM transactions AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT code FROM departments AS prod
WHERE value > (
    SELECT MAX(salary) FROM suppliers AS shp
    WHERE shp.status = prod.status
);


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

SELECT value FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.id = mgr.id
);


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

SELECT name FROM departments AS budg
WHERE salary > (
    SELECT SUM(salary) FROM projects AS empl
    WHERE empl.id = budg.id
);


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

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


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

SELECT salary FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.level = prod.level
);


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

SELECT name FROM categories AS lne
WHERE value > (
    SELECT COUNT(value) FROM shipments AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT value FROM orders AS srvc
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS cust
    WHERE cust.status = srvc.status
);


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

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


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

SELECT name FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = lne.status
);


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

SELECT value FROM employees AS catg
WHERE id IN (
    SELECT id FROM branches AS emp
    WHERE emp.id = catg.id
);


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

SELECT code FROM orders AS budg
WHERE value > (
    SELECT MIN(salary) FROM shipments AS empl
    WHERE empl.id = budg.id
);


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

SELECT amount FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.status = rgn.status
);


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

SELECT id FROM categories AS ord
WHERE amount > (
    SELECT MIN(value) FROM branches AS acct
    WHERE acct.id = ord.id
);


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

SELECT value FROM orders AS lne
WHERE value > (
    SELECT SUM(salary) FROM departments AS schd
    WHERE schd.status = lne.status
);


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

SELECT salary FROM customers AS srvc
WHERE code IN (
    SELECT code FROM orders AS ord
    WHERE ord.id = srvc.id
);


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

SELECT value FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.id = cust.id
);


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

SELECT id FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.level = emp.level
);


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

SELECT id FROM invoices AS catg
WHERE level IN (
    SELECT level FROM branches AS inv
    WHERE inv.type = catg.type
);


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

SELECT code FROM regions AS dept
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.type = dept.type
);


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

SELECT amount FROM tasks AS budg
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT amount FROM categories AS prod
WHERE code IN (
    SELECT code FROM suppliers AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT value FROM products AS rgn
WHERE id IN (
    SELECT id FROM suppliers AS sale
    WHERE sale.status = rgn.status
);


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

SELECT value FROM transactions AS cust
WHERE level IN (
    SELECT level FROM products AS budg
    WHERE budg.type = cust.type
);


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

SELECT salary FROM projects AS ord
WHERE id IN (
    SELECT id FROM orders AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT name FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.type = txn.type
);


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

SELECT code FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.code = ordr.code
);


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

SELECT code FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = shp.level
);


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

SELECT code FROM departments AS shp
WHERE amount > (
    SELECT AVG(amount) FROM customers AS dept
    WHERE dept.type = shp.type
);


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

SELECT id FROM customers AS schd
WHERE code IN (
    SELECT code FROM orders AS emp
    WHERE emp.type = schd.type
);


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

SELECT salary FROM warehouses AS inv
WHERE status IN (
    SELECT status FROM projects AS rgn
    WHERE rgn.id = inv.id
);


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

SELECT name FROM invoices AS mgr
WHERE type IN (
    SELECT type FROM employees AS cust
    WHERE cust.id = mgr.id
);


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

SELECT salary FROM shipments AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM branches AS dept
    WHERE dept.status = rgn.status
);


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

SELECT code FROM projects AS sale
WHERE value > (
    SELECT AVG(value) FROM regions AS shp
    WHERE shp.level = sale.level
);


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

SELECT salary FROM branches AS sale
WHERE id IN (
    SELECT id FROM suppliers AS ord
    WHERE ord.type = sale.type
);


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

SELECT code FROM categories AS txn
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS budg
    WHERE budg.type = txn.type
);


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

SELECT code FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.status = mgr.status
);


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

SELECT name FROM customers AS srvc
WHERE id IN (
    SELECT id FROM invoices AS lne
    WHERE lne.id = srvc.id
);


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

SELECT name FROM categories AS budg
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT amount FROM shipments AS sale
WHERE type IN (
    SELECT type FROM warehouses AS emp
    WHERE emp.type = sale.type
);


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

SELECT amount FROM branches AS budg
WHERE salary > (
    SELECT AVG(value) FROM departments AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT id FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.status = catg.status
);


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

SELECT amount FROM customers AS budg
WHERE status IN (
    SELECT status FROM branches AS lne
    WHERE lne.status = budg.status
);


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

SELECT code FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = srvc.type
);


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

SELECT value FROM shipments AS ord
WHERE status IN (
    SELECT status FROM projects AS lne
    WHERE lne.level = ord.level
);


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

SELECT name FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.level = ord.level
);


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

SELECT name FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = empl.status
);


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

SELECT name FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.type = acct.type
);


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

SELECT value FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT value FROM projects AS mgr
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS lne
    WHERE lne.level = mgr.level
);


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

SELECT salary FROM customers AS txn
WHERE id IN (
    SELECT id FROM transactions AS ord
    WHERE ord.id = txn.id
);


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

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


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

SELECT salary FROM accounts AS lne
WHERE code IN (
    SELECT code FROM categories AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT amount FROM products AS inv
WHERE value > (
    SELECT MIN(value) FROM categories AS emp
    WHERE emp.level = inv.level
);


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

SELECT amount FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = catg.type
);


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

SELECT amount FROM orders AS budg
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS lne
    WHERE lne.status = budg.status
);


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

SELECT id FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.type = lne.type
);


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

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


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

SELECT value FROM warehouses AS sale
WHERE status IN (
    SELECT status FROM departments AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.level = prod.level
);


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

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


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

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


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

SELECT id FROM warehouses AS srvc
WHERE code IN (
    SELECT code FROM products AS schd
    WHERE schd.type = srvc.type
);


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

SELECT name FROM shipments AS sale
WHERE id IN (
    SELECT id FROM suppliers AS ord
    WHERE ord.code = sale.code
);


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

SELECT salary FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.status = budg.status
);


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

SELECT salary FROM categories AS emp
WHERE id IN (
    SELECT id FROM branches AS txn
    WHERE txn.id = emp.id
);


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

SELECT id FROM orders AS srvc
WHERE amount > (
    SELECT MAX(amount) FROM projects AS lne
    WHERE lne.level = srvc.level
);


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

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


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

SELECT value FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.type = budg.type
);


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

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


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

SELECT code FROM orders AS shp
WHERE amount > (
    SELECT MIN(amount) FROM regions AS budg
    WHERE budg.status = shp.status
);


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

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


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

SELECT salary FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.id = inv.id
);


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

SELECT salary FROM tasks AS srvc
WHERE amount > (
    SELECT AVG(amount) FROM branches AS ord
    WHERE ord.level = srvc.level
);


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

SELECT salary FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = sale.status
);


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

SELECT amount FROM customers AS catg
WHERE value > (
    SELECT MIN(amount) FROM tasks AS sale
    WHERE sale.type = catg.type
);


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

SELECT id FROM regions AS txn
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.status = txn.status
);


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

SELECT id FROM departments AS inv
WHERE type IN (
    SELECT type FROM warehouses AS ord
    WHERE ord.type = inv.type
);


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

SELECT code FROM transactions AS sale
WHERE value > (
    SELECT SUM(salary) FROM products AS budg
    WHERE budg.code = sale.code
);


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

SELECT code FROM customers AS srvc
WHERE id IN (
    SELECT id FROM orders AS inv
    WHERE inv.status = srvc.status
);


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

SELECT amount FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.code = whs.code
);


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

SELECT code FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT id FROM suppliers AS emp
WHERE salary > (
    SELECT COUNT(value) FROM products AS mgr
    WHERE mgr.type = emp.type
);


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

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


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

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


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

SELECT salary FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.level = inv.level
);


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

SELECT amount FROM regions AS acct
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.status = acct.status
);


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

SELECT code FROM tasks AS inv
WHERE type IN (
    SELECT type FROM departments AS catg
    WHERE catg.status = inv.status
);


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

SELECT salary FROM departments AS prod
WHERE value > (
    SELECT AVG(value) FROM products AS schd
    WHERE schd.code = prod.code
);


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

SELECT salary FROM suppliers AS inv
WHERE type IN (
    SELECT type FROM projects AS txn
    WHERE txn.code = inv.code
);


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

SELECT code FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = rgn.code
);


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

SELECT value FROM shipments AS cust
WHERE level IN (
    SELECT level FROM customers AS budg
    WHERE budg.code = cust.code
);


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

SELECT id FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.type = srvc.type
);


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

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


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

SELECT salary FROM departments AS acct
WHERE code IN (
    SELECT code FROM projects AS ord
    WHERE ord.type = acct.type
);


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

SELECT name FROM products AS ord
WHERE value > (
    SELECT AVG(amount) FROM tasks AS lne
    WHERE lne.level = ord.level
);


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

SELECT code FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.id = rgn.id
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.level = emp.level
);


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

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


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

SELECT amount FROM branches AS mgr
WHERE code IN (
    SELECT code FROM tasks AS sale
    WHERE sale.code = mgr.code
);


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

SELECT code FROM shipments AS budg
WHERE id IN (
    SELECT id FROM departments AS catg
    WHERE catg.level = budg.level
);


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

SELECT name FROM orders AS txn
WHERE type IN (
    SELECT type FROM regions AS schd
    WHERE schd.code = txn.code
);


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

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


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

SELECT value FROM products AS empl
WHERE amount > (
    SELECT AVG(salary) FROM orders AS schd
    WHERE schd.level = empl.level
);


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

SELECT value FROM warehouses AS schd
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS catg
    WHERE catg.level = schd.level
);


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

SELECT salary FROM departments AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS catg
    WHERE catg.id = whs.id
);


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

SELECT id FROM orders AS empl
WHERE amount > (
    SELECT SUM(value) FROM suppliers AS ord
    WHERE ord.level = empl.level
);


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

SELECT name FROM categories AS cust
WHERE salary > (
    SELECT MAX(salary) FROM branches AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT salary FROM orders AS mgr
WHERE type IN (
    SELECT type FROM categories AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT code FROM invoices AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT code FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT amount FROM regions AS txn
WHERE status IN (
    SELECT status FROM accounts AS ordr
    WHERE ordr.code = txn.code
);


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

SELECT name FROM transactions AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS emp
    WHERE emp.code = lne.code
);


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

SELECT value FROM employees AS catg
WHERE status IN (
    SELECT status FROM accounts AS srvc
    WHERE srvc.id = catg.id
);


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

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


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

SELECT amount FROM tasks AS inv
WHERE type IN (
    SELECT type FROM suppliers AS sale
    WHERE sale.type = inv.type
);


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

SELECT id FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.level = empl.level
);


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

SELECT code FROM shipments AS dept
WHERE salary > (
    SELECT SUM(value) FROM branches AS ordr
    WHERE ordr.level = dept.level
);


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

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


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

SELECT name FROM projects AS ordr
WHERE type IN (
    SELECT type FROM products AS sale
    WHERE sale.code = ordr.code
);


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

SELECT code FROM suppliers AS ordr
WHERE amount > (
    SELECT AVG(value) FROM accounts AS whs
    WHERE whs.code = ordr.code
);


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

SELECT id FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.id = cust.id
);


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

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


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

SELECT amount FROM products AS empl
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.level = empl.level
);


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

SELECT amount FROM employees AS empl
WHERE level IN (
    SELECT level FROM products AS catg
    WHERE catg.status = empl.status
);


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

SELECT id FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.status = empl.status
);


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

SELECT salary FROM transactions AS whs
WHERE status IN (
    SELECT status FROM departments AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT value FROM shipments AS schd
WHERE status IN (
    SELECT status FROM accounts AS whs
    WHERE whs.level = schd.level
);


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

SELECT name FROM accounts AS txn
WHERE salary > (
    SELECT MIN(amount) FROM employees AS schd
    WHERE schd.type = txn.type
);


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

SELECT value FROM transactions AS sale
WHERE code IN (
    SELECT code FROM invoices AS inv
    WHERE inv.level = sale.level
);


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

SELECT value FROM departments AS empl
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS catg
    WHERE catg.status = empl.status
);


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

SELECT id FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.type = ordr.type
);


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

SELECT salary FROM accounts AS ordr
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.type = ordr.type
);


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

SELECT amount FROM accounts AS dept
WHERE value > (
    SELECT MAX(salary) FROM employees AS whs
    WHERE whs.status = dept.status
);


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

SELECT value FROM shipments AS catg
WHERE amount > (
    SELECT SUM(value) FROM products AS acct
    WHERE acct.id = catg.id
);


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

SELECT amount FROM invoices AS empl
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.type = empl.type
);


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

SELECT salary FROM warehouses AS catg
WHERE code IN (
    SELECT code FROM categories AS schd
    WHERE schd.code = catg.code
);


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

SELECT value FROM shipments AS mgr
WHERE status IN (
    SELECT status FROM departments AS empl
    WHERE empl.id = mgr.id
);


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

SELECT code FROM regions AS dept
WHERE value > (
    SELECT MIN(salary) FROM projects AS prod
    WHERE prod.type = dept.type
);


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

SELECT value FROM accounts AS whs
WHERE id IN (
    SELECT id FROM orders AS lne
    WHERE lne.id = whs.id
);


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

SELECT amount FROM accounts AS srvc
WHERE status IN (
    SELECT status FROM projects AS prod
    WHERE prod.type = srvc.type
);


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

SELECT name FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.status = ordr.status
);


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

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


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

SELECT salary FROM suppliers AS empl
WHERE salary > (
    SELECT AVG(amount) FROM regions AS ordr
    WHERE ordr.type = empl.type
);


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

SELECT value FROM projects AS emp
WHERE type IN (
    SELECT type FROM warehouses AS inv
    WHERE inv.type = emp.type
);


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

SELECT value FROM branches AS acct
WHERE code IN (
    SELECT code FROM warehouses AS emp
    WHERE emp.id = acct.id
);


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

SELECT code FROM orders AS mgr
WHERE salary > (
    SELECT MIN(value) FROM branches AS sale
    WHERE sale.level = mgr.level
);


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

SELECT salary FROM customers AS ordr
WHERE level IN (
    SELECT level FROM warehouses AS txn
    WHERE txn.status = ordr.status
);


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

SELECT salary FROM shipments AS inv
WHERE value > (
    SELECT AVG(amount) FROM accounts AS whs
    WHERE whs.status = inv.status
);


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

SELECT code FROM employees AS catg
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS schd
    WHERE schd.type = catg.type
);


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

SELECT value FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.id = mgr.id
);


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

SELECT id FROM suppliers AS txn
WHERE level IN (
    SELECT level FROM tasks AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT salary FROM suppliers AS mgr
WHERE code IN (
    SELECT code FROM projects AS catg
    WHERE catg.type = mgr.type
);


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

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


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

SELECT name FROM shipments AS schd
WHERE code IN (
    SELECT code FROM invoices AS lne
    WHERE lne.type = schd.type
);


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

SELECT amount FROM employees AS whs
WHERE salary > (
    SELECT SUM(salary) FROM projects AS empl
    WHERE empl.level = whs.level
);


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

SELECT name FROM orders AS schd
WHERE code IN (
    SELECT code FROM branches AS txn
    WHERE txn.status = schd.status
);


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

SELECT id FROM suppliers AS whs
WHERE salary > (
    SELECT MAX(amount) FROM branches AS prod
    WHERE prod.type = whs.type
);


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

SELECT value FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT salary FROM accounts AS budg
WHERE type IN (
    SELECT type FROM transactions AS prod
    WHERE prod.id = budg.id
);


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

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


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

SELECT id FROM departments AS ordr
WHERE type IN (
    SELECT type FROM regions AS prod
    WHERE prod.status = ordr.status
);


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

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


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

SELECT salary FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT code FROM warehouses AS sale
WHERE code IN (
    SELECT code FROM accounts AS lne
    WHERE lne.status = sale.status
);


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

SELECT value FROM orders AS emp
WHERE amount > (
    SELECT SUM(value) FROM regions AS cust
    WHERE cust.id = emp.id
);


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

SELECT code FROM branches AS sale
WHERE value > (
    SELECT SUM(value) FROM shipments AS emp
    WHERE emp.status = sale.status
);


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

SELECT name FROM branches AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM employees AS cust
    WHERE cust.level = srvc.level
);


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

SELECT amount FROM projects AS srvc
WHERE status IN (
    SELECT status FROM employees AS txn
    WHERE txn.id = srvc.id
);


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

SELECT name FROM suppliers AS cust
WHERE salary > (
    SELECT SUM(value) FROM tasks AS srvc
    WHERE srvc.id = cust.id
);


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

SELECT value FROM invoices AS ordr
WHERE amount > (
    SELECT MIN(value) FROM branches AS lne
    WHERE lne.code = ordr.code
);


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

SELECT code FROM shipments AS catg
WHERE value > (
    SELECT AVG(salary) FROM branches AS budg
    WHERE budg.type = catg.type
);


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

SELECT amount FROM transactions AS budg
WHERE level IN (
    SELECT level FROM shipments AS empl
    WHERE empl.status = budg.status
);


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

SELECT id FROM categories AS emp
WHERE level IN (
    SELECT level FROM branches AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT salary FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT amount FROM projects AS srvc
WHERE type IN (
    SELECT type FROM suppliers AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT id FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.level = sale.level
);


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

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


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

SELECT code FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.code = ord.code
);


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

SELECT id FROM invoices AS emp
WHERE salary > (
    SELECT SUM(salary) FROM employees AS inv
    WHERE inv.code = emp.code
);


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

SELECT name FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.id = budg.id
);


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

SELECT amount FROM tasks AS txn
WHERE amount > (
    SELECT AVG(salary) FROM warehouses AS empl
    WHERE empl.id = txn.id
);


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

SELECT salary FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.level = budg.level
);


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

SELECT salary FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.status = whs.status
);


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

SELECT id FROM categories AS schd
WHERE type IN (
    SELECT type FROM orders AS cust
    WHERE cust.status = schd.status
);


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

SELECT amount FROM invoices AS lne
WHERE id IN (
    SELECT id FROM shipments AS schd
    WHERE schd.type = lne.type
);


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

SELECT amount FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.type = dept.type
);


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

SELECT id FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.type = ord.type
);


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

SELECT value FROM departments AS txn
WHERE type IN (
    SELECT type FROM suppliers AS inv
    WHERE inv.id = txn.id
);


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

SELECT name FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.id = emp.id
);


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

SELECT name FROM customers AS whs
WHERE amount > (
    SELECT AVG(salary) FROM departments AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT id FROM regions AS empl
WHERE value > (
    SELECT AVG(value) FROM tasks AS catg
    WHERE catg.id = empl.id
);


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

SELECT name FROM orders AS inv
WHERE id IN (
    SELECT id FROM warehouses AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT value FROM categories AS lne
WHERE salary > (
    SELECT SUM(value) FROM departments AS ordr
    WHERE ordr.level = lne.level
);


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

SELECT value FROM departments AS inv
WHERE value > (
    SELECT MIN(salary) FROM customers AS shp
    WHERE shp.type = inv.type
);


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

SELECT id FROM transactions AS acct
WHERE level IN (
    SELECT level FROM warehouses AS ordr
    WHERE ordr.status = acct.status
);


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

SELECT name FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.code = srvc.code
);


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

SELECT value FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.code = budg.code
);


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

SELECT value FROM categories AS acct
WHERE id IN (
    SELECT id FROM branches AS budg
    WHERE budg.status = acct.status
);


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

SELECT amount FROM categories AS prod
WHERE status IN (
    SELECT status FROM transactions AS sale
    WHERE sale.level = prod.level
);


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

SELECT value FROM employees AS schd
WHERE salary > (
    SELECT MIN(amount) FROM branches AS ord
    WHERE ord.type = schd.type
);


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

SELECT name FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.type = cust.type
);


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

SELECT name FROM orders AS lne
WHERE code IN (
    SELECT code FROM employees AS mgr
    WHERE mgr.code = lne.code
);


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

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


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

SELECT amount FROM shipments AS budg
WHERE type IN (
    SELECT type FROM customers AS prod
    WHERE prod.type = budg.type
);


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

SELECT amount FROM invoices AS emp
WHERE level IN (
    SELECT level FROM regions AS acct
    WHERE acct.code = emp.code
);


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

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


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

SELECT salary FROM suppliers AS whs
WHERE type IN (
    SELECT type FROM branches AS sale
    WHERE sale.status = whs.status
);


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

SELECT amount FROM suppliers AS lne
WHERE value > (
    SELECT SUM(amount) FROM tasks AS ord
    WHERE ord.id = lne.id
);


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

SELECT id FROM warehouses AS whs
WHERE level IN (
    SELECT level FROM accounts AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT value FROM shipments AS cust
WHERE status IN (
    SELECT status FROM projects AS empl
    WHERE empl.level = cust.level
);


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

SELECT name FROM tasks AS emp
WHERE level IN (
    SELECT level FROM categories AS budg
    WHERE budg.type = emp.type
);


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

SELECT code FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.level = ordr.level
);


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

SELECT id FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT code FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.level = acct.level
);


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

SELECT name FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.status = srvc.status
);