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

SELECT value FROM products AS catg
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS srvc
    WHERE srvc.code = catg.code
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT code FROM orders AS acct
WHERE id IN (
    SELECT id FROM accounts AS sale
    WHERE sale.id = acct.id
);


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

SELECT value FROM orders AS inv
WHERE status IN (
    SELECT status FROM products AS dept
    WHERE dept.status = inv.status
);


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

SELECT value FROM tasks AS prod
WHERE salary > (
    SELECT MIN(amount) FROM products AS txn
    WHERE txn.code = prod.code
);


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

SELECT amount FROM suppliers AS ordr
WHERE code IN (
    SELECT code FROM warehouses AS empl
    WHERE empl.level = ordr.level
);


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

SELECT id FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.code = schd.code
);


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

SELECT amount FROM customers AS lne
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS shp
    WHERE shp.id = lne.id
);


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

SELECT amount FROM regions AS ordr
WHERE type IN (
    SELECT type FROM tasks AS prod
    WHERE prod.status = ordr.status
);


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

SELECT amount FROM branches AS whs
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS empl
    WHERE empl.level = whs.level
);


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

SELECT id FROM regions AS empl
WHERE type IN (
    SELECT type FROM departments AS emp
    WHERE emp.status = empl.status
);


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

SELECT id FROM branches AS prod
WHERE value > (
    SELECT AVG(salary) FROM shipments AS empl
    WHERE empl.type = prod.type
);


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

SELECT id FROM branches AS whs
WHERE type IN (
    SELECT type FROM orders AS emp
    WHERE emp.level = whs.level
);


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

SELECT amount FROM branches AS inv
WHERE type IN (
    SELECT type FROM shipments AS shp
    WHERE shp.code = inv.code
);


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

SELECT value FROM customers AS srvc
WHERE id IN (
    SELECT id FROM projects AS dept
    WHERE dept.status = srvc.status
);


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

SELECT code FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.type = ord.type
);


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

SELECT id FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.id = dept.id
);


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

SELECT id FROM employees AS ord
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.type = ord.type
);


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

SELECT name FROM shipments AS sale
WHERE salary > (
    SELECT SUM(salary) FROM projects AS catg
    WHERE catg.id = sale.id
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = ord.id
);


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

SELECT value FROM products AS whs
WHERE id IN (
    SELECT id FROM projects AS dept
    WHERE dept.status = whs.status
);


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

SELECT code FROM customers AS rgn
WHERE id IN (
    SELECT id FROM regions AS sale
    WHERE sale.status = rgn.status
);


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

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


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

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


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

SELECT name FROM employees AS inv
WHERE salary > (
    SELECT MIN(amount) FROM products AS lne
    WHERE lne.level = inv.level
);


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

SELECT name FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.code = shp.code
);


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

SELECT amount FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.type = prod.type
);


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

SELECT amount FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.level = ordr.level
);


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

SELECT name FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.code = ord.code
);


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

SELECT name FROM products AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS catg
    WHERE catg.type = lne.type
);


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

SELECT amount FROM transactions AS txn
WHERE id IN (
    SELECT id FROM accounts AS inv
    WHERE inv.id = txn.id
);


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

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


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

SELECT value FROM tasks AS txn
WHERE type IN (
    SELECT type FROM products AS whs
    WHERE whs.status = txn.status
);


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

SELECT amount FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT name FROM regions AS catg
WHERE id IN (
    SELECT id FROM categories AS budg
    WHERE budg.status = catg.status
);


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

SELECT id FROM suppliers AS emp
WHERE value > (
    SELECT COUNT(value) FROM transactions AS txn
    WHERE txn.type = emp.type
);


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

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


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

SELECT name FROM projects AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM customers AS schd
    WHERE schd.id = ordr.id
);


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

SELECT value FROM categories AS schd
WHERE level IN (
    SELECT level FROM departments AS lne
    WHERE lne.code = schd.code
);


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

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


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

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


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

SELECT name FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.code = emp.code
);


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

SELECT salary FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.type = prod.type
);


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

SELECT amount FROM orders AS ordr
WHERE id IN (
    SELECT id FROM projects AS acct
    WHERE acct.id = ordr.id
);


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

SELECT amount FROM branches AS whs
WHERE code IN (
    SELECT code FROM projects AS mgr
    WHERE mgr.code = whs.code
);


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

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


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

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


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

SELECT amount FROM warehouses AS empl
WHERE level IN (
    SELECT level FROM branches AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT name FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = srvc.level
);


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

SELECT name FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.status = catg.status
);


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

SELECT salary FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.code = whs.code
);


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

SELECT name FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.code = shp.code
);


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

SELECT name FROM branches AS dept
WHERE amount > (
    SELECT SUM(salary) FROM warehouses AS sale
    WHERE sale.id = dept.id
);


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

SELECT name FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT amount FROM warehouses AS rgn
WHERE type IN (
    SELECT type FROM employees AS catg
    WHERE catg.id = rgn.id
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.level = catg.level
);


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

SELECT salary FROM shipments AS inv
WHERE amount > (
    SELECT MIN(value) FROM accounts AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT amount FROM projects AS inv
WHERE salary > (
    SELECT COUNT(amount) FROM shipments AS emp
    WHERE emp.type = inv.type
);


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

SELECT amount FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.id = dept.id
);


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

SELECT salary FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.id = budg.id
);


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

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


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

SELECT salary FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.type = mgr.type
);


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

SELECT id FROM departments AS acct
WHERE salary > (
    SELECT SUM(value) FROM customers AS dept
    WHERE dept.status = acct.status
);


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

SELECT amount FROM customers AS ordr
WHERE id IN (
    SELECT id FROM employees AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT id FROM suppliers AS whs
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.id = whs.id
);


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

SELECT value FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.code = whs.code
);


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

SELECT salary FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = ordr.type
);


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

SELECT salary FROM departments AS sale
WHERE amount > (
    SELECT AVG(value) FROM accounts AS emp
    WHERE emp.id = sale.id
);


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

SELECT id FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.type = sale.type
);


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

SELECT amount FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.type = budg.type
);


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

SELECT amount FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.code = ordr.code
);


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

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


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

SELECT amount FROM departments AS mgr
WHERE code IN (
    SELECT code FROM products AS catg
    WHERE catg.code = mgr.code
);


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

SELECT amount FROM shipments AS acct
WHERE value > (
    SELECT COUNT(amount) FROM departments AS srvc
    WHERE srvc.code = acct.code
);


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

SELECT amount FROM shipments AS srvc
WHERE amount > (
    SELECT SUM(value) FROM accounts AS dept
    WHERE dept.type = srvc.type
);


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

SELECT code FROM products AS dept
WHERE value > (
    SELECT MIN(salary) FROM orders AS inv
    WHERE inv.status = dept.status
);


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

SELECT id FROM shipments AS rgn
WHERE code IN (
    SELECT code FROM employees AS lne
    WHERE lne.type = rgn.type
);


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

SELECT name FROM customers AS emp
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS shp
    WHERE shp.id = emp.id
);


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

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


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

SELECT id FROM shipments AS sale
WHERE level IN (
    SELECT level FROM projects AS txn
    WHERE txn.level = sale.level
);


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

SELECT name FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = rgn.code
);


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

SELECT id FROM products AS catg
WHERE status IN (
    SELECT status FROM invoices AS srvc
    WHERE srvc.code = catg.code
);


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

SELECT code FROM accounts AS empl
WHERE status IN (
    SELECT status FROM suppliers AS dept
    WHERE dept.code = empl.code
);


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

SELECT value FROM departments AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT id FROM branches AS emp
WHERE salary > (
    SELECT MAX(value) FROM employees AS catg
    WHERE catg.code = emp.code
);


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

SELECT id FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.status = lne.status
);


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

SELECT value FROM departments AS shp
WHERE id IN (
    SELECT id FROM customers AS txn
    WHERE txn.status = shp.status
);


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

SELECT value FROM shipments AS catg
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.type = catg.type
);


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

SELECT amount FROM customers AS prod
WHERE level IN (
    SELECT level FROM products AS schd
    WHERE schd.level = prod.level
);


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

SELECT value FROM suppliers AS catg
WHERE level IN (
    SELECT level FROM regions AS mgr
    WHERE mgr.id = catg.id
);


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

SELECT id FROM orders AS empl
WHERE code IN (
    SELECT code FROM regions AS shp
    WHERE shp.level = empl.level
);


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

SELECT value FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.status = cust.status
);


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

SELECT value FROM regions AS prod
WHERE level IN (
    SELECT level FROM branches AS emp
    WHERE emp.type = prod.type
);


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

SELECT value FROM transactions AS ordr
WHERE value > (
    SELECT MAX(amount) FROM departments AS dept
    WHERE dept.code = ordr.code
);


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

SELECT id FROM suppliers AS dept
WHERE salary > (
    SELECT AVG(amount) FROM products AS ord
    WHERE ord.type = dept.type
);


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

SELECT code FROM departments AS sale
WHERE amount > (
    SELECT AVG(amount) FROM categories AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT code FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT amount FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.id = mgr.id
);


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

SELECT id FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.code = srvc.code
);


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

SELECT code FROM orders AS emp
WHERE code IN (
    SELECT code FROM categories AS sale
    WHERE sale.type = emp.type
);


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

SELECT code FROM orders AS catg
WHERE value > (
    SELECT SUM(value) FROM employees AS whs
    WHERE whs.id = catg.id
);


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

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


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

SELECT amount FROM suppliers AS mgr
WHERE value > (
    SELECT COUNT(value) FROM orders AS whs
    WHERE whs.level = mgr.level
);


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

SELECT code FROM transactions AS shp
WHERE level IN (
    SELECT level FROM accounts AS budg
    WHERE budg.status = shp.status
);


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

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


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

SELECT name FROM invoices AS rgn
WHERE value > (
    SELECT MAX(amount) FROM customers AS lne
    WHERE lne.status = rgn.status
);


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

SELECT code FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.code = srvc.code
);


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

SELECT name FROM accounts AS mgr
WHERE level IN (
    SELECT level FROM products AS ord
    WHERE ord.status = mgr.status
);


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

SELECT id FROM warehouses AS ord
WHERE value > (
    SELECT AVG(amount) FROM orders AS schd
    WHERE schd.level = ord.level
);


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

SELECT name FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.type = shp.type
);


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

SELECT code FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.code = sale.code
);


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

SELECT id FROM accounts AS empl
WHERE status IN (
    SELECT status FROM tasks AS sale
    WHERE sale.level = empl.level
);


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

SELECT id FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT id FROM customers AS mgr
WHERE value > (
    SELECT SUM(amount) FROM transactions AS emp
    WHERE emp.type = mgr.type
);


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

SELECT name FROM categories AS lne
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS inv
    WHERE inv.id = lne.id
);


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

SELECT salary FROM customers AS inv
WHERE level IN (
    SELECT level FROM regions AS txn
    WHERE txn.code = inv.code
);


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

SELECT salary FROM customers AS acct
WHERE status IN (
    SELECT status FROM projects AS whs
    WHERE whs.code = acct.code
);


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

SELECT amount FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.status = txn.status
);


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

SELECT salary FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.status = catg.status
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.type = emp.type
);


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

SELECT salary FROM branches AS sale
WHERE amount > (
    SELECT AVG(value) FROM regions AS txn
    WHERE txn.id = sale.id
);


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

SELECT value FROM employees AS cust
WHERE level IN (
    SELECT level FROM transactions AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT amount FROM categories AS emp
WHERE amount > (
    SELECT AVG(amount) FROM employees AS ord
    WHERE ord.status = emp.status
);


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

SELECT value FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.code = shp.code
);


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

SELECT code FROM transactions AS shp
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS emp
    WHERE emp.level = shp.level
);


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

SELECT name FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.id = emp.id
);


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

SELECT salary FROM categories AS inv
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.id = inv.id
);


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

SELECT code FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.status = acct.status
);


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

SELECT name FROM employees AS srvc
WHERE level IN (
    SELECT level FROM tasks AS cust
    WHERE cust.status = srvc.status
);


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

SELECT salary FROM departments AS srvc
WHERE status IN (
    SELECT status FROM orders AS mgr
    WHERE mgr.type = srvc.type
);


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

SELECT salary FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.level = cust.level
);


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

SELECT value FROM regions AS emp
WHERE value > (
    SELECT SUM(salary) FROM customers AS txn
    WHERE txn.id = emp.id
);


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

SELECT amount FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT id FROM products AS budg
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS acct
    WHERE acct.code = budg.code
);


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

SELECT code FROM employees AS txn
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT id FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT name FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.type = empl.type
);


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

SELECT salary FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = sale.id
);


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

SELECT name FROM shipments AS whs
WHERE value > (
    SELECT MIN(value) FROM branches AS emp
    WHERE emp.code = whs.code
);


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

SELECT amount FROM shipments AS emp
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS cust
    WHERE cust.level = emp.level
);


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

SELECT amount FROM customers AS emp
WHERE value > (
    SELECT MAX(amount) FROM departments AS whs
    WHERE whs.id = emp.id
);


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

SELECT id FROM warehouses AS lne
WHERE id IN (
    SELECT id FROM projects AS catg
    WHERE catg.level = lne.level
);


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

SELECT id FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = prod.type
);


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

SELECT value FROM suppliers AS txn
WHERE value > (
    SELECT COUNT(amount) FROM categories AS acct
    WHERE acct.level = txn.level
);


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

SELECT name FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.type = lne.type
);


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

SELECT salary FROM categories AS whs
WHERE code IN (
    SELECT code FROM products AS cust
    WHERE cust.status = whs.status
);


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

SELECT amount FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.type = schd.type
);


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

SELECT code FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.status = cust.status
);


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

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


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

SELECT name FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.id = catg.id
);


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

SELECT salary FROM orders AS mgr
WHERE id IN (
    SELECT id FROM categories AS ordr
    WHERE ordr.code = mgr.code
);


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

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


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

SELECT name FROM transactions AS srvc
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS schd
    WHERE schd.level = srvc.level
);


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

SELECT value FROM projects AS catg
WHERE level IN (
    SELECT level FROM accounts AS mgr
    WHERE mgr.status = catg.status
);


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

SELECT amount FROM orders AS whs
WHERE type IN (
    SELECT type FROM employees AS schd
    WHERE schd.level = whs.level
);


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

SELECT salary FROM transactions AS acct
WHERE amount > (
    SELECT SUM(value) FROM tasks AS ordr
    WHERE ordr.id = acct.id
);


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

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


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

SELECT name FROM accounts AS acct
WHERE level IN (
    SELECT level FROM suppliers AS shp
    WHERE shp.level = acct.level
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = ord.level
);


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

SELECT value FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.id = acct.id
);


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

SELECT name FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.level = schd.level
);


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

SELECT amount FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.level = srvc.level
);


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

SELECT amount FROM customers AS empl
WHERE id IN (
    SELECT id FROM invoices AS schd
    WHERE schd.type = empl.type
);


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

SELECT value FROM regions AS txn
WHERE amount > (
    SELECT AVG(salary) FROM orders AS inv
    WHERE inv.id = txn.id
);


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

SELECT id FROM customers AS shp
WHERE amount > (
    SELECT MAX(salary) FROM employees AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT value FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.level = whs.level
);


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

SELECT salary FROM transactions AS rgn
WHERE status IN (
    SELECT status FROM categories AS lne
    WHERE lne.level = rgn.level
);


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

SELECT salary FROM projects AS whs
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS inv
    WHERE inv.status = whs.status
);


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

SELECT amount FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.id = acct.id
);


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

SELECT amount FROM projects AS inv
WHERE salary > (
    SELECT AVG(salary) FROM orders AS whs
    WHERE whs.status = inv.status
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = emp.status
);


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

SELECT value FROM products AS schd
WHERE value > (
    SELECT MAX(salary) FROM suppliers AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT id FROM regions AS ordr
WHERE value > (
    SELECT MIN(amount) FROM employees AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT amount FROM products AS empl
WHERE value > (
    SELECT AVG(value) FROM accounts AS schd
    WHERE schd.type = empl.type
);


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

SELECT code FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT id FROM accounts AS shp
WHERE code IN (
    SELECT code FROM shipments AS cust
    WHERE cust.id = shp.id
);


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

SELECT amount FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.level = empl.level
);


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

SELECT id FROM customers AS ordr
WHERE value > (
    SELECT MAX(amount) FROM shipments AS lne
    WHERE lne.code = ordr.code
);


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

SELECT salary FROM departments AS srvc
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS inv
    WHERE inv.code = srvc.code
);


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

SELECT name FROM employees AS mgr
WHERE value > (
    SELECT MIN(amount) FROM regions AS emp
    WHERE emp.status = mgr.status
);


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

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


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

SELECT name FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT id FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.id = emp.id
);


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

SELECT id FROM employees AS budg
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.type = budg.type
);


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

SELECT name FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.code = ord.code
);


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

SELECT salary FROM invoices AS empl
WHERE type IN (
    SELECT type FROM warehouses AS acct
    WHERE acct.type = empl.type
);


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

SELECT code FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.level = catg.level
);


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

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


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

SELECT name FROM tasks AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM transactions AS prod
    WHERE prod.level = inv.level
);


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

SELECT amount FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.type = mgr.type
);


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

SELECT amount FROM shipments AS inv
WHERE id IN (
    SELECT id FROM departments AS whs
    WHERE whs.status = inv.status
);


Prompt:
Schema:
  accounts (alias: shp)(id, status, date, value)
  branches(id, status, amount, date)
Task: Retrieve code from accounts with value above the COUNT(amount) of branches rows sharing the same status.
SQL:

SELECT code FROM accounts AS shp
WHERE value > (
    SELECT COUNT(amount) FROM branches AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT name FROM orders AS prod
WHERE salary > (
    SELECT MIN(amount) FROM regions AS schd
    WHERE schd.code = prod.code
);


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

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


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

SELECT id FROM orders AS prod
WHERE level IN (
    SELECT level FROM products AS inv
    WHERE inv.type = prod.type
);


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

SELECT code FROM regions AS prod
WHERE amount > (
    SELECT SUM(salary) FROM orders AS cust
    WHERE cust.type = prod.type
);


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

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


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

SELECT name FROM invoices AS sale
WHERE code IN (
    SELECT code FROM products AS empl
    WHERE empl.level = sale.level
);


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

SELECT name FROM branches AS emp
WHERE level IN (
    SELECT level FROM employees AS txn
    WHERE txn.level = emp.level
);


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

SELECT name FROM projects AS txn
WHERE value > (
    SELECT MIN(salary) FROM employees AS catg
    WHERE catg.status = txn.status
);


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

SELECT code FROM suppliers AS txn
WHERE value > (
    SELECT MAX(salary) FROM transactions AS inv
    WHERE inv.type = txn.type
);


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

SELECT amount FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.level = ordr.level
);


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

SELECT id FROM employees AS lne
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.status = lne.status
);


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

SELECT salary FROM employees AS prod
WHERE type IN (
    SELECT type FROM shipments AS acct
    WHERE acct.status = prod.status
);


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

SELECT salary FROM projects AS emp
WHERE code IN (
    SELECT code FROM accounts AS prod
    WHERE prod.type = emp.type
);


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

SELECT amount FROM products AS mgr
WHERE id IN (
    SELECT id FROM branches AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT code FROM warehouses AS catg
WHERE type IN (
    SELECT type FROM departments AS shp
    WHERE shp.id = catg.id
);


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

SELECT id FROM categories AS budg
WHERE amount > (
    SELECT MAX(salary) FROM regions AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT code FROM customers AS schd
WHERE amount > (
    SELECT AVG(amount) FROM accounts AS lne
    WHERE lne.status = schd.status
);


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

SELECT amount FROM departments AS acct
WHERE id IN (
    SELECT id FROM accounts AS empl
    WHERE empl.status = acct.status
);


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

SELECT name FROM projects AS emp
WHERE level IN (
    SELECT level FROM accounts AS empl
    WHERE empl.id = emp.id
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.level = txn.level
);


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

SELECT name FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.type = empl.type
);


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

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


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

SELECT name FROM suppliers AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM branches AS acct
    WHERE acct.type = mgr.type
);


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

SELECT id FROM products AS cust
WHERE amount > (
    SELECT AVG(salary) FROM transactions AS lne
    WHERE lne.type = cust.type
);


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

SELECT amount FROM regions AS empl
WHERE value > (
    SELECT MIN(salary) FROM projects AS cust
    WHERE cust.type = empl.type
);


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

SELECT value FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.status = emp.status
);


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

SELECT value FROM orders AS emp
WHERE code IN (
    SELECT code FROM accounts AS shp
    WHERE shp.code = emp.code
);


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

SELECT value FROM employees AS srvc
WHERE code IN (
    SELECT code FROM customers AS emp
    WHERE emp.level = srvc.level
);


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

SELECT id FROM departments AS inv
WHERE salary > (
    SELECT AVG(salary) FROM employees AS shp
    WHERE shp.status = inv.status
);


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

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


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

SELECT salary FROM employees AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM tasks AS whs
    WHERE whs.status = rgn.status
);


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

SELECT code FROM invoices AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT name FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.type = emp.type
);


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

SELECT name FROM accounts AS emp
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.level = emp.level
);


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

SELECT name FROM customers AS mgr
WHERE status IN (
    SELECT status FROM products AS txn
    WHERE txn.id = mgr.id
);


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

SELECT salary FROM products AS lne
WHERE level IN (
    SELECT level FROM invoices AS cust
    WHERE cust.type = lne.type
);


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

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


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS emp
    WHERE emp.status = catg.status
);


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

SELECT value FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.code = emp.code
);


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

SELECT id FROM departments AS emp
WHERE id IN (
    SELECT id FROM suppliers AS lne
    WHERE lne.level = emp.level
);


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

SELECT id FROM departments AS emp
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS txn
    WHERE txn.code = emp.code
);


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

SELECT value FROM projects AS prod
WHERE id IN (
    SELECT id FROM employees AS inv
    WHERE inv.id = prod.id
);


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

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


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

SELECT code FROM transactions AS empl
WHERE amount > (
    SELECT AVG(value) FROM categories AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT amount FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.id = prod.id
);


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

SELECT name FROM branches AS lne
WHERE type IN (
    SELECT type FROM departments AS txn
    WHERE txn.code = lne.code
);


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

SELECT name FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = dept.status
);


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

SELECT salary FROM employees AS cust
WHERE code IN (
    SELECT code FROM departments AS empl
    WHERE empl.code = cust.code
);


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

SELECT salary FROM products AS lne
WHERE status IN (
    SELECT status FROM projects AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT value FROM regions AS srvc
WHERE value > (
    SELECT SUM(value) FROM departments AS acct
    WHERE acct.level = srvc.level
);


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

SELECT value FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.id = schd.id
);


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

SELECT code FROM employees AS sale
WHERE status IN (
    SELECT status FROM products AS srvc
    WHERE srvc.id = sale.id
);


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

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


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

SELECT value FROM invoices AS mgr
WHERE level IN (
    SELECT level FROM orders AS empl
    WHERE empl.id = mgr.id
);


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

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


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

SELECT salary FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT name FROM products AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM departments AS cust
    WHERE cust.code = mgr.code
);


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

SELECT name FROM departments AS mgr
WHERE status IN (
    SELECT status FROM tasks AS whs
    WHERE whs.level = mgr.level
);


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

SELECT code FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.level = sale.level
);


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

SELECT value FROM transactions AS acct
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS sale
    WHERE sale.type = acct.type
);


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

SELECT id FROM tasks AS lne
WHERE value > (
    SELECT AVG(amount) FROM branches AS catg
    WHERE catg.status = lne.status
);


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

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


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

SELECT amount FROM shipments AS mgr
WHERE value > (
    SELECT MAX(salary) FROM invoices AS schd
    WHERE schd.type = mgr.type
);


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

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


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

SELECT amount FROM warehouses AS dept
WHERE level IN (
    SELECT level FROM customers AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT salary FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.type = cust.type
);


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

SELECT amount FROM projects AS mgr
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.id = mgr.id
);


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

SELECT value FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.type = txn.type
);


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

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


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

SELECT salary FROM tasks AS srvc
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.status = srvc.status
);


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

SELECT id FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.level = inv.level
);


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

SELECT amount FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.id = emp.id
);


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

SELECT code FROM departments AS lne
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS txn
    WHERE txn.status = lne.status
);


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

SELECT amount FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.status = cust.status
);


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

SELECT salary FROM invoices AS inv
WHERE amount > (
    SELECT MAX(amount) FROM suppliers AS empl
    WHERE empl.type = inv.type
);


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

SELECT salary FROM projects AS rgn
WHERE amount > (
    SELECT MIN(salary) FROM employees AS acct
    WHERE acct.id = rgn.id
);


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

SELECT name FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.id = lne.id
);


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

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


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

SELECT salary FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.type = emp.type
);


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

SELECT id FROM orders AS srvc
WHERE id IN (
    SELECT id FROM departments AS prod
    WHERE prod.code = srvc.code
);


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

SELECT id FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.code = sale.code
);


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

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


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

SELECT name FROM shipments AS schd
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.id = schd.id
);


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

SELECT code FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.status = dept.status
);


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

SELECT id FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT value FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.id = acct.id
);


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

SELECT code FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.type = acct.type
);


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

SELECT id FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.code = sale.code
);


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

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


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

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


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

SELECT value FROM tasks AS acct
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS cust
    WHERE cust.id = acct.id
);


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

SELECT code FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.code = srvc.code
);


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

SELECT amount FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.status = srvc.status
);


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

SELECT amount FROM warehouses AS emp
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS ord
    WHERE ord.type = emp.type
);


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

SELECT amount FROM accounts AS empl
WHERE value > (
    SELECT SUM(amount) FROM departments AS schd
    WHERE schd.status = empl.status
);


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

SELECT amount FROM regions AS acct
WHERE status IN (
    SELECT status FROM invoices AS schd
    WHERE schd.level = acct.level
);


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

SELECT id FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.status = whs.status
);


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

SELECT amount FROM transactions AS emp
WHERE id IN (
    SELECT id FROM accounts AS whs
    WHERE whs.status = emp.status
);


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

SELECT value FROM regions AS dept
WHERE level IN (
    SELECT level FROM invoices AS whs
    WHERE whs.status = dept.status
);


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

SELECT id FROM departments AS prod
WHERE code IN (
    SELECT code FROM invoices AS sale
    WHERE sale.id = prod.id
);


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

SELECT value FROM branches AS acct
WHERE type IN (
    SELECT type FROM shipments AS dept
    WHERE dept.level = acct.level
);


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

SELECT value FROM employees AS catg
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.type = catg.type
);