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

SELECT value FROM invoices AS empl
WHERE id IN (
    SELECT id FROM tasks AS shp
    WHERE shp.code = empl.code
);


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

SELECT salary FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.level = budg.level
);


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

SELECT code FROM products AS prod
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.code = prod.code
);


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

SELECT amount FROM accounts AS prod
WHERE salary > (
    SELECT MAX(value) FROM products AS empl
    WHERE empl.type = prod.type
);


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

SELECT amount FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT value FROM invoices AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM products AS sale
    WHERE sale.type = ord.type
);


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

SELECT salary FROM tasks AS ordr
WHERE code IN (
    SELECT code FROM suppliers AS ord
    WHERE ord.status = ordr.status
);


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

SELECT value FROM branches AS mgr
WHERE code IN (
    SELECT code FROM employees AS dept
    WHERE dept.type = mgr.type
);


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

SELECT amount FROM employees AS ord
WHERE id IN (
    SELECT id FROM suppliers AS acct
    WHERE acct.code = ord.code
);


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

SELECT salary FROM suppliers AS emp
WHERE salary > (
    SELECT COUNT(amount) FROM warehouses AS dept
    WHERE dept.code = emp.code
);


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

SELECT code FROM regions AS shp
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS prod
    WHERE prod.type = shp.type
);


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

SELECT id FROM warehouses AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM tasks AS sale
    WHERE sale.level = catg.level
);


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

SELECT salary FROM tasks AS empl
WHERE status IN (
    SELECT status FROM products AS prod
    WHERE prod.id = empl.id
);


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

SELECT salary FROM departments AS lne
WHERE level IN (
    SELECT level FROM invoices AS catg
    WHERE catg.id = lne.id
);


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

SELECT amount FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT id FROM accounts AS rgn
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS txn
    WHERE txn.level = rgn.level
);


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

SELECT amount FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.id = whs.id
);


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

SELECT amount FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT value FROM tasks AS catg
WHERE code IN (
    SELECT code FROM shipments AS cust
    WHERE cust.type = catg.type
);


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

SELECT salary FROM warehouses AS srvc
WHERE id IN (
    SELECT id FROM projects AS lne
    WHERE lne.code = srvc.code
);


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

SELECT name FROM transactions AS whs
WHERE id IN (
    SELECT id FROM products AS empl
    WHERE empl.id = whs.id
);


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

SELECT amount FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.id = schd.id
);


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

SELECT value FROM customers AS ordr
WHERE type IN (
    SELECT type FROM transactions AS prod
    WHERE prod.status = ordr.status
);


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

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


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

SELECT salary FROM tasks AS ord
WHERE id IN (
    SELECT id FROM accounts AS shp
    WHERE shp.id = ord.id
);


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

SELECT code FROM employees AS inv
WHERE value > (
    SELECT SUM(value) FROM customers AS ordr
    WHERE ordr.code = inv.code
);


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

SELECT amount FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.code = dept.code
);


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

SELECT value FROM suppliers AS cust
WHERE code IN (
    SELECT code FROM branches AS txn
    WHERE txn.id = cust.id
);


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

SELECT value FROM projects AS srvc
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS empl
    WHERE empl.code = srvc.code
);


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

SELECT salary FROM departments AS schd
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS ord
    WHERE ord.status = schd.status
);


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

SELECT name FROM categories AS catg
WHERE value > (
    SELECT MIN(amount) FROM departments AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT salary FROM orders AS dept
WHERE status IN (
    SELECT status FROM warehouses AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT value FROM projects AS inv
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.level = inv.level
);


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

SELECT name FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.type = catg.type
);


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

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


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

SELECT id FROM suppliers AS shp
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.id = shp.id
);


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

SELECT id FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.code = shp.code
);


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

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


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

SELECT salary FROM projects AS prod
WHERE code IN (
    SELECT code FROM accounts AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT amount FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.status = shp.status
);


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

SELECT id FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.code = txn.code
);


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

SELECT id FROM warehouses AS empl
WHERE status IN (
    SELECT status FROM orders AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT code FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.type = lne.type
);


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

SELECT salary FROM warehouses AS rgn
WHERE value > (
    SELECT AVG(value) FROM regions AS prod
    WHERE prod.type = rgn.type
);


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

SELECT name FROM shipments AS schd
WHERE code IN (
    SELECT code FROM invoices AS sale
    WHERE sale.id = schd.id
);


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

SELECT salary FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.status = acct.status
);


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

SELECT id FROM orders AS mgr
WHERE status IN (
    SELECT status FROM branches AS budg
    WHERE budg.level = mgr.level
);


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

SELECT value FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = ordr.level
);


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

SELECT amount FROM invoices AS txn
WHERE id IN (
    SELECT id FROM customers AS emp
    WHERE emp.type = txn.type
);


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

SELECT id FROM transactions AS ordr
WHERE id IN (
    SELECT id FROM tasks AS mgr
    WHERE mgr.id = ordr.id
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = ord.type
);


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

SELECT amount FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.code = schd.code
);


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

SELECT value FROM departments AS emp
WHERE amount > (
    SELECT MIN(amount) FROM branches AS mgr
    WHERE mgr.status = emp.status
);


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

SELECT amount FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.id = txn.id
);


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

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


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

SELECT amount FROM branches AS lne
WHERE code IN (
    SELECT code FROM employees AS ord
    WHERE ord.code = lne.code
);


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

SELECT value FROM employees AS lne
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS prod
    WHERE prod.status = lne.status
);


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

SELECT name FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.code = txn.code
);


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

SELECT salary FROM employees AS whs
WHERE value > (
    SELECT COUNT(salary) FROM orders AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT amount FROM projects AS emp
WHERE id IN (
    SELECT id FROM categories AS prod
    WHERE prod.level = emp.level
);


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

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


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

SELECT name FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.level = schd.level
);


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

SELECT id FROM departments AS ord
WHERE status IN (
    SELECT status FROM suppliers AS acct
    WHERE acct.id = ord.id
);


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

SELECT name FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.level = lne.level
);


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

SELECT name FROM suppliers AS ordr
WHERE id IN (
    SELECT id FROM shipments AS ord
    WHERE ord.status = ordr.status
);


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

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.level = inv.level
);


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

SELECT code FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT id FROM invoices AS schd
WHERE id IN (
    SELECT id FROM regions AS ord
    WHERE ord.status = schd.status
);


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

SELECT name FROM shipments AS acct
WHERE id IN (
    SELECT id FROM orders AS catg
    WHERE catg.code = acct.code
);


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

SELECT name FROM regions AS dept
WHERE amount > (
    SELECT MAX(salary) FROM projects AS schd
    WHERE schd.type = dept.type
);


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

SELECT code FROM shipments AS dept
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT value FROM branches AS whs
WHERE level IN (
    SELECT level FROM invoices AS inv
    WHERE inv.level = whs.level
);


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

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


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

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


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

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


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

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


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

SELECT amount FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.level = inv.level
);


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

SELECT salary FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.id = schd.id
);


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

SELECT id FROM invoices AS whs
WHERE amount > (
    SELECT AVG(value) FROM regions AS dept
    WHERE dept.code = whs.code
);


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

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


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

SELECT value FROM tasks AS srvc
WHERE code IN (
    SELECT code FROM transactions AS mgr
    WHERE mgr.level = srvc.level
);


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

SELECT id FROM products AS emp
WHERE amount > (
    SELECT MIN(value) FROM branches AS acct
    WHERE acct.code = emp.code
);


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

SELECT amount FROM transactions AS catg
WHERE level IN (
    SELECT level FROM tasks AS inv
    WHERE inv.level = catg.level
);


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

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


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

SELECT name FROM suppliers AS empl
WHERE value > (
    SELECT MIN(value) FROM projects AS prod
    WHERE prod.level = empl.level
);


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

SELECT id FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.type = srvc.type
);


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

SELECT id FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.status = ord.status
);


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

SELECT value FROM suppliers AS shp
WHERE code IN (
    SELECT code FROM shipments AS dept
    WHERE dept.id = shp.id
);


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT amount FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.level = sale.level
);


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

SELECT amount FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.level = catg.level
);


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

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


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

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


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

SELECT salary FROM projects AS srvc
WHERE level IN (
    SELECT level FROM customers AS ordr
    WHERE ordr.code = srvc.code
);


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

SELECT code FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.type = emp.type
);


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

SELECT value FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.status = budg.status
);


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

SELECT amount FROM transactions AS emp
WHERE amount > (
    SELECT COUNT(value) FROM departments AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT code FROM invoices AS txn
WHERE type IN (
    SELECT type FROM accounts AS shp
    WHERE shp.code = txn.code
);


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

SELECT id FROM suppliers AS rgn
WHERE code IN (
    SELECT code FROM warehouses AS txn
    WHERE txn.status = rgn.status
);


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

SELECT name FROM suppliers AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM employees AS dept
    WHERE dept.code = srvc.code
);


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

SELECT salary FROM orders AS cust
WHERE id IN (
    SELECT id FROM branches AS emp
    WHERE emp.id = cust.id
);


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

SELECT code FROM customers AS lne
WHERE status IN (
    SELECT status FROM transactions AS whs
    WHERE whs.level = lne.level
);


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

SELECT salary FROM categories AS txn
WHERE amount > (
    SELECT AVG(amount) FROM branches AS emp
    WHERE emp.level = txn.level
);


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

SELECT name FROM products AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS shp
    WHERE shp.code = schd.code
);


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

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


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

SELECT value FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.type = shp.type
);


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

SELECT code FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.status = lne.status
);


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

SELECT code FROM invoices AS whs
WHERE type IN (
    SELECT type FROM transactions AS emp
    WHERE emp.status = whs.status
);


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

SELECT id FROM shipments AS ordr
WHERE status IN (
    SELECT status FROM projects AS acct
    WHERE acct.status = ordr.status
);


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

SELECT id FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.code = whs.code
);


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

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


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

SELECT value FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.status = shp.status
);


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

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


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

SELECT value FROM accounts AS emp
WHERE type IN (
    SELECT type FROM categories AS shp
    WHERE shp.level = emp.level
);


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

SELECT value FROM warehouses AS txn
WHERE amount > (
    SELECT SUM(amount) FROM categories AS budg
    WHERE budg.type = txn.type
);


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

SELECT salary FROM invoices AS dept
WHERE code IN (
    SELECT code FROM warehouses AS prod
    WHERE prod.level = dept.level
);


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

SELECT salary FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT id FROM suppliers AS inv
WHERE value > (
    SELECT MAX(salary) FROM regions AS ord
    WHERE ord.type = inv.type
);


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

SELECT value FROM suppliers AS srvc
WHERE value > (
    SELECT MIN(salary) FROM accounts AS ord
    WHERE ord.level = srvc.level
);


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

SELECT name FROM invoices AS prod
WHERE salary > (
    SELECT SUM(value) FROM projects AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT name FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.level = srvc.level
);


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

SELECT id FROM employees AS emp
WHERE id IN (
    SELECT id FROM branches AS sale
    WHERE sale.code = emp.code
);


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

SELECT code FROM departments AS rgn
WHERE level IN (
    SELECT level FROM employees AS cust
    WHERE cust.level = rgn.level
);


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

SELECT value FROM products AS sale
WHERE type IN (
    SELECT type FROM categories AS empl
    WHERE empl.code = sale.code
);


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

SELECT name FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.id = txn.id
);


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

SELECT amount FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.id = ord.id
);


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

SELECT id FROM employees AS acct
WHERE salary > (
    SELECT COUNT(value) FROM categories AS prod
    WHERE prod.level = acct.level
);


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

SELECT value FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.type = sale.type
);


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

SELECT name FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.status = srvc.status
);


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

SELECT value FROM tasks AS txn
WHERE id IN (
    SELECT id FROM projects AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT code FROM tasks AS srvc
WHERE status IN (
    SELECT status FROM invoices AS lne
    WHERE lne.code = srvc.code
);


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

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


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

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


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

SELECT amount FROM tasks AS txn
WHERE salary > (
    SELECT MIN(value) FROM accounts AS ord
    WHERE ord.status = txn.status
);


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

SELECT amount FROM products AS cust
WHERE id IN (
    SELECT id FROM suppliers AS inv
    WHERE inv.code = cust.code
);


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

SELECT name FROM transactions AS schd
WHERE status IN (
    SELECT status FROM departments AS acct
    WHERE acct.code = schd.code
);


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

SELECT name FROM shipments AS ord
WHERE value > (
    SELECT MIN(amount) FROM warehouses AS budg
    WHERE budg.type = ord.type
);


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

SELECT value FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.type = catg.type
);


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

SELECT value FROM tasks AS shp
WHERE amount > (
    SELECT SUM(salary) FROM regions AS schd
    WHERE schd.status = shp.status
);


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

SELECT code FROM products AS emp
WHERE level IN (
    SELECT level FROM transactions AS whs
    WHERE whs.type = emp.type
);


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

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


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

SELECT id FROM employees AS srvc
WHERE type IN (
    SELECT type FROM categories AS lne
    WHERE lne.code = srvc.code
);


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

SELECT name FROM products AS acct
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.type = acct.type
);


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

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


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

SELECT amount FROM categories AS shp
WHERE type IN (
    SELECT type FROM invoices AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT salary FROM transactions AS ord
WHERE salary > (
    SELECT MIN(value) FROM projects AS shp
    WHERE shp.code = ord.code
);


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

SELECT amount FROM products AS srvc
WHERE salary > (
    SELECT MAX(value) FROM accounts AS inv
    WHERE inv.code = srvc.code
);


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

SELECT salary FROM accounts AS sale
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT amount FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = budg.type
);


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

SELECT id FROM customers AS schd
WHERE amount > (
    SELECT MIN(value) FROM regions AS ord
    WHERE ord.status = schd.status
);


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

SELECT id FROM shipments AS lne
WHERE status IN (
    SELECT status FROM tasks AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT salary FROM projects AS whs
WHERE value > (
    SELECT MAX(salary) FROM shipments AS catg
    WHERE catg.level = whs.level
);


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

SELECT amount FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.code = srvc.code
);


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

SELECT code FROM projects AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM customers AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT amount FROM branches AS acct
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS schd
    WHERE schd.code = acct.code
);


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

SELECT code FROM accounts AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS acct
    WHERE acct.id = catg.id
);


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

SELECT name FROM branches AS srvc
WHERE value > (
    SELECT SUM(amount) FROM shipments AS shp
    WHERE shp.type = srvc.type
);


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

SELECT salary FROM warehouses AS txn
WHERE value > (
    SELECT MIN(value) FROM categories AS ord
    WHERE ord.id = txn.id
);


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

SELECT code FROM accounts AS schd
WHERE amount > (
    SELECT AVG(value) FROM regions AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT value FROM orders AS shp
WHERE type IN (
    SELECT type FROM products AS sale
    WHERE sale.code = shp.code
);


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

SELECT id FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.status = srvc.status
);


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

SELECT code FROM transactions AS sale
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS schd
    WHERE schd.id = sale.id
);


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

SELECT amount FROM suppliers AS mgr
WHERE id IN (
    SELECT id FROM invoices AS sale
    WHERE sale.status = mgr.status
);


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

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


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

SELECT salary FROM suppliers AS ord
WHERE type IN (
    SELECT type FROM tasks AS inv
    WHERE inv.status = ord.status
);


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

SELECT amount FROM employees AS schd
WHERE salary > (
    SELECT SUM(value) FROM categories AS srvc
    WHERE srvc.code = schd.code
);


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

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


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

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


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

SELECT salary FROM transactions AS ord
WHERE value > (
    SELECT MAX(amount) FROM shipments AS lne
    WHERE lne.id = ord.id
);


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

SELECT salary FROM invoices AS srvc
WHERE salary > (
    SELECT MIN(salary) FROM orders AS sale
    WHERE sale.code = srvc.code
);


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

SELECT code FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = mgr.id
);


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

SELECT name FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.level = prod.level
);


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

SELECT amount FROM branches AS ordr
WHERE status IN (
    SELECT status FROM orders AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT salary FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.type = empl.type
);


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

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


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

SELECT name FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.id = emp.id
);


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

SELECT name FROM invoices AS prod
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS empl
    WHERE empl.level = prod.level
);


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

SELECT value FROM projects AS srvc
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS rgn
    WHERE rgn.code = srvc.code
);


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

SELECT name FROM invoices AS budg
WHERE level IN (
    SELECT level FROM customers AS dept
    WHERE dept.level = budg.level
);


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

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


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

SELECT amount FROM customers AS inv
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.level = inv.level
);


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

SELECT salary FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.status = lne.status
);


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

SELECT value FROM products AS ord
WHERE value > (
    SELECT SUM(value) FROM regions AS shp
    WHERE shp.status = ord.status
);


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

SELECT salary FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.level = acct.level
);


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

SELECT name FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.id = lne.id
);


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

SELECT salary FROM departments AS budg
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.level = budg.level
);


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

SELECT id FROM employees AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM projects AS budg
    WHERE budg.level = mgr.level
);


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

SELECT value FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT salary FROM customers AS emp
WHERE value > (
    SELECT AVG(amount) FROM accounts AS dept
    WHERE dept.code = emp.code
);


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

SELECT id FROM accounts AS sale
WHERE amount > (
    SELECT MIN(amount) FROM customers AS dept
    WHERE dept.status = sale.status
);


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

SELECT code FROM employees AS acct
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS schd
    WHERE schd.type = acct.type
);


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

SELECT value FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.level = cust.level
);


Prompt:
Schema:
  tasks (alias: schd)(status, level, date, id)
  regions(date, name, code, 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 lne
    WHERE lne.type = schd.type
);


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

SELECT salary FROM employees AS ord
WHERE amount > (
    SELECT SUM(salary) FROM customers AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT salary FROM accounts AS srvc
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS prod
    WHERE prod.code = srvc.code
);


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

SELECT value FROM accounts AS empl
WHERE level IN (
    SELECT level FROM regions AS inv
    WHERE inv.level = empl.level
);


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

SELECT id FROM shipments AS prod
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS emp
    WHERE emp.level = prod.level
);


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

SELECT id FROM shipments AS srvc
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS shp
    WHERE shp.type = srvc.type
);


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

SELECT name FROM projects AS dept
WHERE code IN (
    SELECT code FROM suppliers AS txn
    WHERE txn.level = dept.level
);


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

SELECT name FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.id = cust.id
);


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

SELECT value FROM categories AS cust
WHERE salary > (
    SELECT COUNT(salary) FROM branches AS budg
    WHERE budg.status = cust.status
);


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

SELECT code FROM tasks AS txn
WHERE value > (
    SELECT COUNT(salary) FROM suppliers AS ord
    WHERE ord.status = txn.status
);


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

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


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

SELECT amount FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT id FROM categories AS sale
WHERE value > (
    SELECT MAX(salary) FROM branches AS schd
    WHERE schd.status = sale.status
);


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

SELECT salary FROM transactions AS rgn
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS shp
    WHERE shp.code = rgn.code
);


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

SELECT value FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.code = inv.code
);


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

SELECT code FROM products AS dept
WHERE salary > (
    SELECT MIN(value) FROM warehouses AS whs
    WHERE whs.type = dept.type
);


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

SELECT amount FROM tasks AS srvc
WHERE value > (
    SELECT MIN(amount) FROM regions AS rgn
    WHERE rgn.code = srvc.code
);


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

SELECT salary FROM products AS budg
WHERE salary > (
    SELECT MAX(amount) FROM regions AS empl
    WHERE empl.id = budg.id
);


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

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


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

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


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

SELECT amount FROM employees AS ord
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS acct
    WHERE acct.level = ord.level
);


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

SELECT code FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT value FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.code = ordr.code
);


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

SELECT code FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.type = ordr.type
);


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

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


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

SELECT salary FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.code = sale.code
);


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

SELECT amount FROM warehouses AS lne
WHERE status IN (
    SELECT status FROM products AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT salary FROM transactions AS lne
WHERE status IN (
    SELECT status FROM employees AS schd
    WHERE schd.level = lne.level
);


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

SELECT name FROM employees AS sale
WHERE amount > (
    SELECT MIN(amount) FROM warehouses AS rgn
    WHERE rgn.level = sale.level
);


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

SELECT code FROM tasks AS srvc
WHERE amount > (
    SELECT MIN(salary) FROM employees AS mgr
    WHERE mgr.status = srvc.status
);


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

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


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

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


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

SELECT id FROM employees AS catg
WHERE level IN (
    SELECT level FROM suppliers AS sale
    WHERE sale.type = catg.type
);


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

SELECT amount FROM invoices AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS shp
    WHERE shp.id = ordr.id
);


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

SELECT id FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.type = empl.type
);


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

SELECT amount FROM suppliers AS schd
WHERE value > (
    SELECT AVG(amount) FROM invoices AS catg
    WHERE catg.status = schd.status
);


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

SELECT value FROM departments AS budg
WHERE amount > (
    SELECT AVG(value) FROM employees AS txn
    WHERE txn.status = budg.status
);


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

SELECT amount FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.code = txn.code
);


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

SELECT code FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.id = inv.id
);


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

SELECT amount FROM warehouses AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM products AS inv
    WHERE inv.status = catg.status
);


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

SELECT code FROM departments AS whs
WHERE id IN (
    SELECT id FROM orders AS rgn
    WHERE rgn.level = whs.level
);


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

SELECT id FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = lne.status
);


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

SELECT value FROM departments AS budg
WHERE salary > (
    SELECT SUM(value) FROM tasks AS dept
    WHERE dept.id = budg.id
);


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

SELECT value FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = budg.id
);


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

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


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

SELECT code FROM projects AS ord
WHERE level IN (
    SELECT level FROM branches AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT value FROM branches AS rgn
WHERE id IN (
    SELECT id FROM customers AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.id = dept.id
);


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

SELECT amount FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.level = budg.level
);


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

SELECT amount FROM accounts AS prod
WHERE status IN (
    SELECT status FROM categories AS shp
    WHERE shp.status = prod.status
);


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

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


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

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


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

SELECT value FROM transactions AS ord
WHERE salary > (
    SELECT SUM(amount) FROM regions AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT id FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.status = whs.status
);


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

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


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

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


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

SELECT value FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.level = empl.level
);


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

SELECT id FROM projects AS shp
WHERE salary > (
    SELECT AVG(amount) FROM orders AS emp
    WHERE emp.status = shp.status
);


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

SELECT name FROM projects AS whs
WHERE amount > (
    SELECT SUM(salary) FROM products AS shp
    WHERE shp.id = whs.id
);


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

SELECT id FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.code = ord.code
);


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

SELECT salary FROM transactions AS schd
WHERE status IN (
    SELECT status FROM employees AS ord
    WHERE ord.type = schd.type
);


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

SELECT id FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.status = rgn.status
);


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

SELECT id FROM warehouses AS inv
WHERE id IN (
    SELECT id FROM customers AS txn
    WHERE txn.type = inv.type
);


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

SELECT code FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.status = catg.status
);


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

SELECT code FROM regions AS ordr
WHERE level IN (
    SELECT level FROM accounts AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT code FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.level = txn.level
);


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

SELECT name FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.code = mgr.code
);


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

SELECT salary FROM invoices AS rgn
WHERE level IN (
    SELECT level FROM tasks AS dept
    WHERE dept.status = rgn.status
);


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

SELECT amount FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = prod.code
);


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

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


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

SELECT amount FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.id = emp.id
);


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

SELECT id FROM orders AS txn
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.level = txn.level
);


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

SELECT amount FROM customers AS dept
WHERE id IN (
    SELECT id FROM employees AS ord
    WHERE ord.code = dept.code
);


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

SELECT value FROM invoices AS txn
WHERE id IN (
    SELECT id FROM regions AS acct
    WHERE acct.code = txn.code
);


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

SELECT name FROM suppliers AS shp
WHERE status IN (
    SELECT status FROM transactions AS prod
    WHERE prod.code = shp.code
);


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

SELECT code FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = schd.level
);


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

SELECT name FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT salary FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.code = budg.code
);


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

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


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

SELECT id FROM employees AS inv
WHERE value > (
    SELECT AVG(value) FROM orders AS emp
    WHERE emp.level = inv.level
);


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

SELECT value FROM warehouses AS emp
WHERE type IN (
    SELECT type FROM invoices AS empl
    WHERE empl.level = emp.level
);


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

SELECT amount FROM suppliers AS schd
WHERE status IN (
    SELECT status FROM regions AS srvc
    WHERE srvc.id = schd.id
);


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

SELECT name FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.status = empl.status
);


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

SELECT name FROM orders AS schd
WHERE value > (
    SELECT COUNT(value) FROM branches AS lne
    WHERE lne.id = schd.id
);


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

SELECT value FROM tasks AS empl
WHERE value > (
    SELECT COUNT(salary) FROM categories AS budg
    WHERE budg.code = empl.code
);


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

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


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

SELECT value FROM regions AS cust
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS shp
    WHERE shp.code = cust.code
);


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

SELECT code FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.id = rgn.id
);


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

SELECT amount FROM orders AS srvc
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS shp
    WHERE shp.id = srvc.id
);


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

SELECT name FROM invoices AS emp
WHERE value > (
    SELECT MIN(value) FROM customers AS txn
    WHERE txn.type = emp.type
);


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

SELECT code FROM suppliers AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM employees AS lne
    WHERE lne.type = ord.type
);


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

SELECT value FROM customers AS schd
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS srvc
    WHERE srvc.id = schd.id
);


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

SELECT code FROM tasks AS acct
WHERE code IN (
    SELECT code FROM products AS catg
    WHERE catg.level = acct.level
);


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

SELECT salary FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.level = inv.level
);


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

SELECT code FROM projects AS empl
WHERE id IN (
    SELECT id FROM departments AS budg
    WHERE budg.id = empl.id
);


Prompt:
Schema:
  departments (alias: shp)(date, id, status, level)
  tasks(id, date, status, code)
Task: Retrieve name from departments with salary above the COUNT(salary) of tasks rows sharing the same status.
SQL:

SELECT name FROM departments AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS acct
    WHERE acct.status = shp.status
);


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

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


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

SELECT name FROM accounts AS srvc
WHERE type IN (
    SELECT type FROM projects AS empl
    WHERE empl.id = srvc.id
);


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

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


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

SELECT value FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.type = budg.type
);