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

SELECT salary FROM invoices AS dept
WHERE amount > (
    SELECT AVG(amount) FROM products AS shp
    WHERE shp.status = dept.status
);


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

SELECT code FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.id = lne.id
);


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

SELECT id FROM departments AS sale
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.id = sale.id
);


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

SELECT salary FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.code = inv.code
);


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

SELECT id FROM transactions AS lne
WHERE id IN (
    SELECT id FROM departments AS cust
    WHERE cust.id = lne.id
);


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

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


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

SELECT value FROM departments AS cust
WHERE value > (
    SELECT MIN(value) FROM invoices AS prod
    WHERE prod.id = cust.id
);


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

SELECT name FROM tasks AS ordr
WHERE code IN (
    SELECT code FROM accounts AS empl
    WHERE empl.type = ordr.type
);


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

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


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

SELECT salary FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.level = cust.level
);


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

SELECT id FROM orders AS mgr
WHERE value > (
    SELECT AVG(amount) FROM branches AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT name FROM transactions AS budg
WHERE amount > (
    SELECT MIN(value) FROM accounts AS catg
    WHERE catg.id = budg.id
);


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

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


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

SELECT salary FROM shipments AS mgr
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.status = mgr.status
);


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

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


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

SELECT value FROM regions AS cust
WHERE value > (
    SELECT MAX(value) FROM accounts AS emp
    WHERE emp.level = cust.level
);


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

SELECT name FROM shipments AS rgn
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.status = rgn.status
);


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

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


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

SELECT salary FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.id = schd.id
);


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

SELECT salary FROM transactions AS schd
WHERE value > (
    SELECT SUM(amount) FROM categories AS inv
    WHERE inv.id = schd.id
);


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

SELECT value FROM warehouses AS catg
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.code = catg.code
);


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

SELECT name FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.id = whs.id
);


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

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


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

SELECT amount FROM projects AS srvc
WHERE value > (
    SELECT MIN(salary) FROM tasks AS catg
    WHERE catg.status = srvc.status
);


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

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


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

SELECT value FROM invoices AS cust
WHERE status IN (
    SELECT status FROM customers AS whs
    WHERE whs.status = cust.status
);


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

SELECT code FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.type = rgn.type
);


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

SELECT amount FROM orders AS ordr
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.id = ordr.id
);


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

SELECT id FROM orders AS cust
WHERE value > (
    SELECT AVG(amount) FROM tasks AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT salary FROM invoices AS catg
WHERE id IN (
    SELECT id FROM branches AS cust
    WHERE cust.id = catg.id
);


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

SELECT salary FROM customers AS txn
WHERE status IN (
    SELECT status FROM orders AS lne
    WHERE lne.level = txn.level
);


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

SELECT amount FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.status = emp.status
);


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

SELECT amount FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.id = mgr.id
);


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

SELECT name FROM warehouses AS rgn
WHERE type IN (
    SELECT type FROM customers AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT amount FROM customers AS rgn
WHERE value > (
    SELECT AVG(value) FROM suppliers AS lne
    WHERE lne.code = rgn.code
);


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

SELECT salary FROM employees AS acct
WHERE level IN (
    SELECT level FROM products AS dept
    WHERE dept.id = acct.id
);


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

SELECT name FROM tasks AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT amount FROM branches AS prod
WHERE status IN (
    SELECT status FROM invoices AS acct
    WHERE acct.id = prod.id
);


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

SELECT salary FROM customers AS acct
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS inv
    WHERE inv.code = acct.code
);


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

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


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.id = dept.id
);


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

SELECT name FROM products AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS ord
    WHERE ord.type = mgr.type
);


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

SELECT amount FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.id = dept.id
);


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

SELECT id FROM transactions AS acct
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.level = acct.level
);


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

SELECT name FROM employees AS shp
WHERE type IN (
    SELECT type FROM transactions AS catg
    WHERE catg.level = shp.level
);


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

SELECT code FROM customers AS shp
WHERE code IN (
    SELECT code FROM invoices AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT code FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.type = schd.type
);


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

SELECT salary FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.code = budg.code
);


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

SELECT value FROM orders AS mgr
WHERE level IN (
    SELECT level FROM categories AS emp
    WHERE emp.id = mgr.id
);


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

SELECT value FROM branches AS sale
WHERE value > (
    SELECT MAX(salary) FROM projects AS empl
    WHERE empl.code = sale.code
);


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

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


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

SELECT id FROM accounts AS srvc
WHERE value > (
    SELECT SUM(amount) FROM employees AS dept
    WHERE dept.code = srvc.code
);


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.type = empl.type
);


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

SELECT amount FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.level = whs.level
);


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

SELECT code FROM branches AS acct
WHERE salary > (
    SELECT MIN(value) FROM employees AS empl
    WHERE empl.level = acct.level
);


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

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


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

SELECT code FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.level = catg.level
);


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

SELECT value FROM tasks AS catg
WHERE value > (
    SELECT MIN(value) FROM regions AS cust
    WHERE cust.id = catg.id
);


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

SELECT code FROM customers AS txn
WHERE salary > (
    SELECT SUM(value) FROM invoices AS ord
    WHERE ord.level = txn.level
);


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

SELECT amount FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT name FROM branches AS cust
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS dept
    WHERE dept.status = cust.status
);


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

SELECT amount FROM suppliers AS ordr
WHERE id IN (
    SELECT id FROM accounts AS txn
    WHERE txn.type = ordr.type
);


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

SELECT code FROM branches AS inv
WHERE code IN (
    SELECT code FROM employees AS budg
    WHERE budg.status = inv.status
);


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

SELECT value FROM tasks AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM regions AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT id FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.status = shp.status
);


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

SELECT name FROM accounts AS cust
WHERE value > (
    SELECT MIN(salary) FROM orders AS ord
    WHERE ord.id = cust.id
);


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

SELECT value FROM transactions AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM customers AS inv
    WHERE inv.id = ordr.id
);


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

SELECT code FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.level = sale.level
);


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

SELECT amount FROM departments AS txn
WHERE amount > (
    SELECT MIN(value) FROM employees AS dept
    WHERE dept.id = txn.id
);


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

SELECT code FROM accounts AS catg
WHERE status IN (
    SELECT status FROM departments AS acct
    WHERE acct.id = catg.id
);


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

SELECT code FROM suppliers AS catg
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS txn
    WHERE txn.code = catg.code
);


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

SELECT salary FROM warehouses AS cust
WHERE status IN (
    SELECT status FROM departments AS budg
    WHERE budg.code = cust.code
);


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

SELECT amount FROM regions AS inv
WHERE amount > (
    SELECT SUM(salary) FROM departments AS whs
    WHERE whs.status = inv.status
);


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

SELECT name FROM invoices AS shp
WHERE type IN (
    SELECT type FROM tasks AS prod
    WHERE prod.id = shp.id
);


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

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


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

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


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

SELECT id FROM categories AS srvc
WHERE level IN (
    SELECT level FROM customers AS budg
    WHERE budg.code = srvc.code
);


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

SELECT amount FROM products AS ord
WHERE value > (
    SELECT AVG(salary) FROM projects AS dept
    WHERE dept.status = ord.status
);


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

SELECT amount FROM products AS sale
WHERE level IN (
    SELECT level FROM categories AS ord
    WHERE ord.status = sale.status
);


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

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


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

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


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

SELECT value FROM branches AS budg
WHERE level IN (
    SELECT level FROM shipments AS schd
    WHERE schd.id = budg.id
);


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

SELECT salary FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.status = mgr.status
);


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

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


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

SELECT code FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM customers AS ord
    WHERE ord.status = rgn.status
);


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

SELECT amount FROM invoices AS schd
WHERE salary > (
    SELECT MIN(value) FROM departments AS inv
    WHERE inv.level = schd.level
);


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

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


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

SELECT value FROM transactions AS dept
WHERE status IN (
    SELECT status FROM invoices AS schd
    WHERE schd.code = dept.code
);


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

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


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

SELECT id FROM warehouses AS catg
WHERE value > (
    SELECT MAX(amount) FROM tasks AS schd
    WHERE schd.level = catg.level
);


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

SELECT amount FROM employees AS txn
WHERE salary > (
    SELECT SUM(amount) FROM products AS catg
    WHERE catg.level = txn.level
);


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

SELECT id FROM orders AS emp
WHERE code IN (
    SELECT code FROM shipments AS dept
    WHERE dept.level = emp.level
);


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

SELECT amount FROM orders AS dept
WHERE salary > (
    SELECT MIN(amount) FROM customers AS lne
    WHERE lne.id = dept.id
);


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

SELECT code FROM orders AS empl
WHERE amount > (
    SELECT MAX(amount) FROM projects AS dept
    WHERE dept.level = empl.level
);


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

SELECT code FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.type = ordr.type
);


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

SELECT salary FROM projects AS dept
WHERE code IN (
    SELECT code FROM tasks AS acct
    WHERE acct.type = dept.type
);


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

SELECT name FROM branches AS budg
WHERE status IN (
    SELECT status FROM regions AS catg
    WHERE catg.code = budg.code
);


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

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


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

SELECT name FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.type = catg.type
);


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

SELECT value FROM orders AS ordr
WHERE id IN (
    SELECT id FROM invoices AS ord
    WHERE ord.status = ordr.status
);


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

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


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

SELECT salary FROM transactions AS cust
WHERE status IN (
    SELECT status FROM products AS acct
    WHERE acct.type = cust.type
);


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

SELECT amount FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.level = rgn.level
);


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

SELECT value FROM customers AS lne
WHERE id IN (
    SELECT id FROM projects AS prod
    WHERE prod.level = lne.level
);


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

SELECT id FROM employees AS empl
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS txn
    WHERE txn.code = empl.code
);


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

SELECT salary FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.level = ord.level
);


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

SELECT value FROM products AS empl
WHERE code IN (
    SELECT code FROM warehouses AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT code FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.type = empl.type
);


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

SELECT id FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.status = schd.status
);


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

SELECT code FROM products AS ordr
WHERE status IN (
    SELECT status FROM shipments AS budg
    WHERE budg.id = ordr.id
);


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

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


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

SELECT name FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.id = dept.id
);


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

SELECT salary FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = catg.code
);


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

SELECT amount FROM products AS shp
WHERE id IN (
    SELECT id FROM branches AS lne
    WHERE lne.type = shp.type
);


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

SELECT id FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.level = sale.level
);


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

SELECT code FROM transactions AS shp
WHERE salary > (
    SELECT MAX(amount) FROM customers AS srvc
    WHERE srvc.id = shp.id
);


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

SELECT name FROM products AS rgn
WHERE type IN (
    SELECT type FROM shipments AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT id FROM transactions AS cust
WHERE id IN (
    SELECT id FROM tasks AS emp
    WHERE emp.type = cust.type
);


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

SELECT salary FROM products AS dept
WHERE amount > (
    SELECT COUNT(salary) FROM shipments AS acct
    WHERE acct.id = dept.id
);


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

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


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

SELECT salary FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.level = prod.level
);


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

SELECT id FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = txn.type
);


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

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


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

SELECT id FROM branches AS rgn
WHERE amount > (
    SELECT MAX(amount) FROM regions AS acct
    WHERE acct.id = rgn.id
);


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

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


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

SELECT name FROM orders AS whs
WHERE id IN (
    SELECT id FROM invoices AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT name FROM warehouses AS acct
WHERE type IN (
    SELECT type FROM accounts AS catg
    WHERE catg.code = acct.code
);


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

SELECT id FROM departments AS emp
WHERE amount > (
    SELECT AVG(amount) FROM products AS catg
    WHERE catg.level = emp.level
);


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

SELECT id FROM projects AS budg
WHERE amount > (
    SELECT AVG(salary) FROM products AS schd
    WHERE schd.status = budg.status
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT amount FROM transactions AS acct
WHERE type IN (
    SELECT type FROM warehouses AS rgn
    WHERE rgn.code = acct.code
);


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

SELECT value FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.code = txn.code
);


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

SELECT id FROM branches AS schd
WHERE value > (
    SELECT MAX(value) FROM regions AS prod
    WHERE prod.level = schd.level
);


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

SELECT code FROM employees AS acct
WHERE id IN (
    SELECT id FROM customers AS txn
    WHERE txn.id = acct.id
);


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

SELECT code FROM warehouses AS lne
WHERE salary > (
    SELECT MIN(value) FROM products AS empl
    WHERE empl.code = lne.code
);


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

SELECT amount FROM regions AS whs
WHERE level IN (
    SELECT level FROM departments AS inv
    WHERE inv.id = whs.id
);


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

SELECT amount FROM customers AS empl
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.status = empl.status
);


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

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


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

SELECT code FROM invoices AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM categories AS emp
    WHERE emp.level = srvc.level
);


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

SELECT value FROM projects AS lne
WHERE value > (
    SELECT AVG(amount) FROM products AS inv
    WHERE inv.type = lne.type
);


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

SELECT value FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.id = empl.id
);


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

SELECT salary FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.type = mgr.type
);


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

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


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

SELECT id FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.level = emp.level
);


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

SELECT amount FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.id = schd.id
);


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

SELECT amount FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.type = shp.type
);


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

SELECT code FROM shipments AS schd
WHERE amount > (
    SELECT AVG(amount) FROM branches AS sale
    WHERE sale.id = schd.id
);


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

SELECT code FROM tasks AS prod
WHERE level IN (
    SELECT level FROM branches AS sale
    WHERE sale.code = prod.code
);


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

SELECT salary FROM categories AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS schd
    WHERE schd.status = inv.status
);


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

SELECT code FROM employees AS mgr
WHERE salary > (
    SELECT COUNT(amount) FROM products AS ord
    WHERE ord.level = mgr.level
);


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

SELECT id FROM invoices AS emp
WHERE level IN (
    SELECT level FROM employees AS empl
    WHERE empl.status = emp.status
);


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

SELECT code FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.status = prod.status
);


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

SELECT value FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.id = cust.id
);


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

SELECT id FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.status = acct.status
);


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

SELECT salary FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.status = shp.status
);


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

SELECT amount FROM branches AS empl
WHERE id IN (
    SELECT id FROM products AS catg
    WHERE catg.code = empl.code
);


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

SELECT name FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = empl.type
);


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

SELECT salary FROM customers AS cust
WHERE type IN (
    SELECT type FROM orders AS prod
    WHERE prod.type = cust.type
);


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

SELECT id FROM tasks AS acct
WHERE type IN (
    SELECT type FROM branches AS budg
    WHERE budg.code = acct.code
);


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

SELECT name FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.code = catg.code
);


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

SELECT salary FROM suppliers AS acct
WHERE id IN (
    SELECT id FROM employees AS sale
    WHERE sale.type = acct.type
);


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

SELECT name FROM orders AS empl
WHERE amount > (
    SELECT MAX(salary) FROM categories AS txn
    WHERE txn.level = empl.level
);


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

SELECT code FROM orders AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM products AS schd
    WHERE schd.status = lne.status
);


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

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


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

SELECT name FROM warehouses AS dept
WHERE amount > (
    SELECT COUNT(value) FROM projects AS whs
    WHERE whs.code = dept.code
);


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

SELECT value FROM orders AS empl
WHERE level IN (
    SELECT level FROM branches AS sale
    WHERE sale.type = empl.type
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.type = inv.type
);


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

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


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

SELECT id FROM accounts AS rgn
WHERE status IN (
    SELECT status FROM products AS budg
    WHERE budg.level = rgn.level
);


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

SELECT value FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.id = rgn.id
);


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

SELECT name FROM transactions AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS inv
    WHERE inv.level = rgn.level
);


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

SELECT name FROM transactions AS emp
WHERE status IN (
    SELECT status FROM suppliers AS catg
    WHERE catg.id = emp.id
);


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

SELECT salary FROM employees AS catg
WHERE salary > (
    SELECT MIN(amount) FROM categories AS dept
    WHERE dept.level = catg.level
);


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

SELECT amount FROM products AS sale
WHERE code IN (
    SELECT code FROM categories AS budg
    WHERE budg.status = sale.status
);


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

SELECT id FROM customers AS whs
WHERE salary > (
    SELECT SUM(value) FROM suppliers AS shp
    WHERE shp.type = whs.type
);


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

SELECT amount FROM tasks AS whs
WHERE type IN (
    SELECT type FROM categories AS shp
    WHERE shp.type = whs.type
);


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

SELECT id FROM branches AS dept
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.level = dept.level
);


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

SELECT amount FROM warehouses AS cust
WHERE status IN (
    SELECT status FROM departments AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT amount FROM departments AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS lne
    WHERE lne.code = whs.code
);


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

SELECT id FROM shipments AS schd
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.id = schd.id
);


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

SELECT id FROM transactions AS ord
WHERE salary > (
    SELECT MAX(salary) FROM branches AS cust
    WHERE cust.status = ord.status
);


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

SELECT id FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.status = whs.status
);


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

SELECT name FROM customers AS empl
WHERE status IN (
    SELECT status FROM regions AS schd
    WHERE schd.level = empl.level
);


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

SELECT name FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.status = txn.status
);


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

SELECT name FROM suppliers AS prod
WHERE salary > (
    SELECT SUM(value) FROM departments AS empl
    WHERE empl.level = prod.level
);


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

SELECT amount FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.status = whs.status
);


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

SELECT value FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = shp.type
);


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

SELECT value FROM departments AS srvc
WHERE level IN (
    SELECT level FROM invoices AS whs
    WHERE whs.status = srvc.status
);


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

SELECT code FROM tasks AS catg
WHERE code IN (
    SELECT code FROM warehouses AS schd
    WHERE schd.level = catg.level
);


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

SELECT code FROM projects AS prod
WHERE value > (
    SELECT SUM(value) FROM tasks AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT amount FROM transactions AS txn
WHERE salary > (
    SELECT AVG(value) FROM invoices AS acct
    WHERE acct.code = txn.code
);


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

SELECT value FROM categories AS inv
WHERE value > (
    SELECT COUNT(salary) FROM employees AS rgn
    WHERE rgn.status = inv.status
);


Prompt:
Schema:
  departments (alias: schd)(value, level, salary, name)
  orders(value, type, date, salary)
Task: Select value from departments where type exists in orders for the same level.
SQL:

SELECT value FROM departments AS schd
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.level = schd.level
);


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

SELECT amount FROM transactions AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM departments AS emp
    WHERE emp.status = schd.status
);


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

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


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

SELECT salary FROM warehouses AS whs
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS ord
    WHERE ord.type = whs.type
);


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

SELECT salary FROM categories AS emp
WHERE type IN (
    SELECT type FROM warehouses AS dept
    WHERE dept.id = emp.id
);


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

SELECT code FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT amount FROM transactions AS prod
WHERE id IN (
    SELECT id FROM suppliers AS dept
    WHERE dept.status = prod.status
);


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

SELECT salary FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.id = catg.id
);


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

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


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

SELECT salary FROM regions AS dept
WHERE value > (
    SELECT COUNT(value) FROM tasks AS inv
    WHERE inv.code = dept.code
);


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

SELECT value FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.code = rgn.code
);


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

SELECT name FROM regions AS emp
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS dept
    WHERE dept.status = emp.status
);


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

SELECT salary FROM branches AS empl
WHERE salary > (
    SELECT MIN(amount) FROM employees AS lne
    WHERE lne.level = empl.level
);


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

SELECT value FROM branches AS dept
WHERE amount > (
    SELECT MAX(value) FROM customers AS acct
    WHERE acct.code = dept.code
);


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

SELECT value FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT code FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT value FROM shipments AS sale
WHERE salary > (
    SELECT SUM(amount) FROM orders AS emp
    WHERE emp.id = sale.id
);


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

SELECT amount FROM shipments AS empl
WHERE salary > (
    SELECT MAX(value) FROM projects AS ordr
    WHERE ordr.id = empl.id
);


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

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


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

SELECT value FROM suppliers AS ordr
WHERE level IN (
    SELECT level FROM categories AS txn
    WHERE txn.id = ordr.id
);


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

SELECT value FROM warehouses AS emp
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS budg
    WHERE budg.type = emp.type
);


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

SELECT code FROM regions AS cust
WHERE status IN (
    SELECT status FROM departments AS ord
    WHERE ord.status = cust.status
);


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

SELECT name FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT name FROM warehouses AS cust
WHERE value > (
    SELECT MIN(value) FROM suppliers AS ord
    WHERE ord.type = cust.type
);


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

SELECT id FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.level = acct.level
);


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

SELECT amount FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.type = budg.type
);


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

SELECT value FROM warehouses AS inv
WHERE id IN (
    SELECT id FROM customers AS empl
    WHERE empl.status = inv.status
);


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

SELECT amount FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.status = whs.status
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.level = prod.level
);


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

SELECT id FROM suppliers AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM customers AS emp
    WHERE emp.code = ordr.code
);


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

SELECT salary FROM regions AS dept
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS lne
    WHERE lne.id = dept.id
);


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

SELECT amount FROM customers AS mgr
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.level = mgr.level
);


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

SELECT value FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.level = srvc.level
);


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

SELECT amount FROM categories AS prod
WHERE value > (
    SELECT COUNT(value) FROM tasks AS whs
    WHERE whs.status = prod.status
);


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

SELECT salary FROM invoices AS srvc
WHERE id IN (
    SELECT id FROM transactions AS txn
    WHERE txn.type = srvc.type
);


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

SELECT id FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.type = shp.type
);


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

SELECT value FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.id = emp.id
);


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

SELECT salary FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = mgr.type
);


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

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


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

SELECT name FROM accounts AS mgr
WHERE level IN (
    SELECT level FROM tasks AS budg
    WHERE budg.id = mgr.id
);


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

SELECT code FROM employees AS schd
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.level = schd.level
);


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

SELECT name FROM categories AS sale
WHERE value > (
    SELECT MAX(amount) FROM accounts AS catg
    WHERE catg.id = sale.id
);


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

SELECT name FROM invoices AS lne
WHERE id IN (
    SELECT id FROM branches AS schd
    WHERE schd.type = lne.type
);


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

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


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

SELECT amount FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.level = cust.level
);


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

SELECT name FROM tasks AS lne
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS inv
    WHERE inv.status = lne.status
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT salary FROM departments AS prod
WHERE type IN (
    SELECT type FROM employees AS acct
    WHERE acct.code = prod.code
);


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

SELECT amount FROM branches AS dept
WHERE id IN (
    SELECT id FROM projects AS budg
    WHERE budg.id = dept.id
);


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

SELECT amount FROM accounts AS budg
WHERE salary > (
    SELECT MAX(salary) FROM invoices AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT name FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.id = whs.id
);


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

SELECT name FROM warehouses AS catg
WHERE status IN (
    SELECT status FROM regions AS lne
    WHERE lne.level = catg.level
);


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

SELECT id FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT id FROM customers AS mgr
WHERE amount > (
    SELECT MIN(value) FROM shipments AS txn
    WHERE txn.id = mgr.id
);


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

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


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

SELECT salary FROM branches AS dept
WHERE value > (
    SELECT MIN(amount) FROM tasks AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT value FROM shipments AS budg
WHERE salary > (
    SELECT MAX(salary) FROM employees AS sale
    WHERE sale.level = budg.level
);


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

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


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

SELECT salary FROM branches AS ord
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS cust
    WHERE cust.id = ord.id
);


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

SELECT salary FROM tasks AS sale
WHERE salary > (
    SELECT MAX(salary) FROM orders AS empl
    WHERE empl.type = sale.type
);


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

SELECT code FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.type = ord.type
);


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

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


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

SELECT value FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.status = ord.status
);


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

SELECT name FROM regions AS acct
WHERE value > (
    SELECT MIN(salary) FROM orders AS budg
    WHERE budg.type = acct.type
);


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

SELECT code FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.level = schd.level
);


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

SELECT name FROM regions AS srvc
WHERE level IN (
    SELECT level FROM warehouses AS ordr
    WHERE ordr.type = srvc.type
);


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

SELECT amount FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.level = srvc.level
);


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

SELECT code FROM invoices AS emp
WHERE status IN (
    SELECT status FROM regions AS acct
    WHERE acct.type = emp.type
);


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

SELECT amount FROM products AS emp
WHERE amount > (
    SELECT COUNT(value) FROM employees AS sale
    WHERE sale.id = emp.id
);


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

SELECT code FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.status = catg.status
);


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

SELECT value FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.id = mgr.id
);


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

SELECT name FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.type = whs.type
);


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

SELECT value FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.id = txn.id
);


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

SELECT amount FROM accounts AS prod
WHERE value > (
    SELECT MIN(value) FROM invoices AS cust
    WHERE cust.level = prod.level
);


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

SELECT id FROM categories AS schd
WHERE level IN (
    SELECT level FROM employees AS acct
    WHERE acct.code = schd.code
);


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

SELECT value FROM employees AS rgn
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.code = rgn.code
);


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

SELECT code FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT salary FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.type = ord.type
);


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

SELECT value FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.code = cust.code
);


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

SELECT amount FROM accounts AS txn
WHERE level IN (
    SELECT level FROM shipments AS dept
    WHERE dept.status = txn.status
);


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

SELECT name FROM orders AS lne
WHERE status IN (
    SELECT status FROM branches AS rgn
    WHERE rgn.level = lne.level
);


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

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


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

SELECT name FROM suppliers AS shp
WHERE amount > (
    SELECT AVG(value) FROM invoices AS acct
    WHERE acct.code = shp.code
);


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

SELECT salary FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.id = txn.id
);


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

SELECT amount FROM categories AS whs
WHERE status IN (
    SELECT status FROM shipments AS inv
    WHERE inv.type = whs.type
);


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

SELECT amount FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.code = whs.code
);


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

SELECT amount FROM warehouses AS txn
WHERE code IN (
    SELECT code FROM suppliers AS lne
    WHERE lne.type = txn.type
);


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

SELECT code FROM customers AS emp
WHERE code IN (
    SELECT code FROM products AS txn
    WHERE txn.level = emp.level
);


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

SELECT code FROM products AS catg
WHERE type IN (
    SELECT type FROM regions AS empl
    WHERE empl.id = catg.id
);


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

SELECT salary FROM products AS lne
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS catg
    WHERE catg.code = lne.code
);


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

SELECT name FROM invoices AS shp
WHERE value > (
    SELECT SUM(value) FROM warehouses AS schd
    WHERE schd.code = shp.code
);


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

SELECT salary FROM accounts AS ord
WHERE id IN (
    SELECT id FROM products AS inv
    WHERE inv.status = ord.status
);


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

SELECT id FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.level = prod.level
);


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

SELECT name FROM accounts AS budg
WHERE value > (
    SELECT MAX(value) FROM warehouses AS cust
    WHERE cust.type = budg.type
);


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

SELECT name FROM categories AS empl
WHERE amount > (
    SELECT COUNT(value) FROM branches AS ord
    WHERE ord.id = empl.id
);


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

SELECT name FROM accounts AS mgr
WHERE level IN (
    SELECT level FROM branches AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT value FROM accounts AS shp
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS acct
    WHERE acct.level = shp.level
);


Prompt:
Schema:
  projects (alias: ordr)(name, status, value, code)
  accounts(type, id, name, status)
Task: Retrieve code from projects with value above the AVG(value) of accounts rows sharing the same status.
SQL:

SELECT code FROM projects AS ordr
WHERE value > (
    SELECT AVG(value) FROM accounts AS ord
    WHERE ord.status = ordr.status
);


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

SELECT value FROM tasks AS empl
WHERE type IN (
    SELECT type FROM projects AS ordr
    WHERE ordr.type = empl.type
);


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

SELECT code FROM orders AS mgr
WHERE id IN (
    SELECT id FROM shipments AS dept
    WHERE dept.id = mgr.id
);


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

SELECT amount FROM tasks AS dept
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS emp
    WHERE emp.id = dept.id
);


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

SELECT salary FROM departments AS prod
WHERE level IN (
    SELECT level FROM projects AS inv
    WHERE inv.level = prod.level
);