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

SELECT amount FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.id = ord.id
);


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

SELECT amount FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.type = catg.type
);


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

SELECT value FROM employees AS empl
WHERE status IN (
    SELECT status FROM orders AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT amount FROM customers AS empl
WHERE type IN (
    SELECT type FROM tasks AS ord
    WHERE ord.code = empl.code
);


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

SELECT code FROM categories AS whs
WHERE salary > (
    SELECT COUNT(value) FROM warehouses AS prod
    WHERE prod.level = whs.level
);


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

SELECT id FROM warehouses AS schd
WHERE id IN (
    SELECT id FROM categories AS ord
    WHERE ord.id = schd.id
);


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

SELECT salary FROM employees AS cust
WHERE value > (
    SELECT AVG(value) FROM shipments AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT value FROM departments AS inv
WHERE code IN (
    SELECT code FROM customers AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT amount FROM branches AS ord
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS cust
    WHERE cust.status = ord.status
);


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

SELECT amount FROM regions AS lne
WHERE salary > (
    SELECT SUM(value) FROM products AS budg
    WHERE budg.id = lne.id
);


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

SELECT code FROM categories AS txn
WHERE status IN (
    SELECT status FROM orders AS catg
    WHERE catg.id = txn.id
);


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

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


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

SELECT amount FROM orders AS txn
WHERE amount > (
    SELECT SUM(value) FROM suppliers AS acct
    WHERE acct.status = txn.status
);


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

SELECT salary FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT code FROM categories AS inv
WHERE salary > (
    SELECT MAX(salary) FROM orders AS empl
    WHERE empl.status = inv.status
);


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

SELECT id FROM warehouses AS schd
WHERE amount > (
    SELECT MIN(amount) FROM categories AS sale
    WHERE sale.type = schd.type
);


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

SELECT value FROM employees AS lne
WHERE amount > (
    SELECT COUNT(value) FROM customers AS prod
    WHERE prod.code = lne.code
);


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

SELECT amount FROM tasks AS rgn
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT id FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.code = catg.code
);


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

SELECT code FROM categories AS acct
WHERE value > (
    SELECT AVG(amount) FROM shipments AS dept
    WHERE dept.level = acct.level
);


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

SELECT name FROM employees AS prod
WHERE status IN (
    SELECT status FROM tasks AS budg
    WHERE budg.type = prod.type
);


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

SELECT amount FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.type = ordr.type
);


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

SELECT code FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM products AS dept
    WHERE dept.status = rgn.status
);


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

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


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

SELECT name FROM orders AS ordr
WHERE type IN (
    SELECT type FROM regions AS prod
    WHERE prod.level = ordr.level
);


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

SELECT id FROM suppliers AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM tasks AS whs
    WHERE whs.status = ordr.status
);


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

SELECT id FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.type = rgn.type
);


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

SELECT name FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT amount FROM accounts AS lne
WHERE value > (
    SELECT MAX(value) FROM invoices AS emp
    WHERE emp.type = lne.type
);


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

SELECT name FROM warehouses AS catg
WHERE status IN (
    SELECT status FROM tasks AS empl
    WHERE empl.type = catg.type
);


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

SELECT value FROM shipments AS catg
WHERE salary > (
    SELECT MAX(salary) FROM orders AS schd
    WHERE schd.id = catg.id
);


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

SELECT value FROM branches AS budg
WHERE amount > (
    SELECT AVG(value) FROM accounts AS schd
    WHERE schd.id = budg.id
);


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

SELECT amount FROM products AS txn
WHERE status IN (
    SELECT status FROM projects AS budg
    WHERE budg.status = txn.status
);


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

SELECT salary FROM regions AS dept
WHERE salary > (
    SELECT SUM(value) FROM suppliers AS txn
    WHERE txn.code = dept.code
);


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

SELECT name FROM transactions AS shp
WHERE code IN (
    SELECT code FROM suppliers AS ord
    WHERE ord.level = shp.level
);


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

SELECT salary FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.type = inv.type
);


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

SELECT value FROM projects AS inv
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.id = inv.id
);


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

SELECT name FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.code = rgn.code
);


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

SELECT amount FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.code = rgn.code
);


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

SELECT id FROM departments AS srvc
WHERE type IN (
    SELECT type FROM accounts AS mgr
    WHERE mgr.id = srvc.id
);


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

SELECT id FROM departments AS txn
WHERE code IN (
    SELECT code FROM warehouses AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT name FROM invoices AS lne
WHERE value > (
    SELECT MAX(value) FROM transactions AS inv
    WHERE inv.level = lne.level
);


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

SELECT value FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.id = sale.id
);


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

SELECT salary FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.type = inv.type
);


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

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


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

SELECT name FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.level = dept.level
);


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

SELECT code FROM customers AS acct
WHERE status IN (
    SELECT status FROM warehouses AS empl
    WHERE empl.code = acct.code
);


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

SELECT value FROM shipments AS schd
WHERE level IN (
    SELECT level FROM transactions AS inv
    WHERE inv.type = schd.type
);


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

SELECT id FROM accounts AS rgn
WHERE amount > (
    SELECT AVG(salary) FROM regions AS acct
    WHERE acct.status = rgn.status
);


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

SELECT value FROM employees AS inv
WHERE salary > (
    SELECT AVG(value) FROM shipments AS ord
    WHERE ord.code = inv.code
);


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

SELECT salary FROM shipments AS rgn
WHERE type IN (
    SELECT type FROM warehouses AS prod
    WHERE prod.code = rgn.code
);


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

SELECT value FROM branches AS ord
WHERE level IN (
    SELECT level FROM shipments AS empl
    WHERE empl.type = ord.type
);


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

SELECT value FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = acct.status
);


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

SELECT code FROM invoices AS schd
WHERE value > (
    SELECT COUNT(value) FROM orders AS rgn
    WHERE rgn.status = schd.status
);


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

SELECT id FROM warehouses AS acct
WHERE salary > (
    SELECT MIN(salary) FROM projects AS lne
    WHERE lne.status = acct.status
);


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

SELECT value FROM warehouses AS budg
WHERE id IN (
    SELECT id FROM customers AS empl
    WHERE empl.level = budg.level
);


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

SELECT name FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.type = ordr.type
);


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

SELECT value FROM accounts AS rgn
WHERE level IN (
    SELECT level FROM transactions AS schd
    WHERE schd.level = rgn.level
);


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

SELECT id FROM invoices AS ordr
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT amount FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.level = ordr.level
);


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

SELECT id FROM products AS rgn
WHERE amount > (
    SELECT SUM(value) FROM accounts AS inv
    WHERE inv.type = rgn.type
);


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

SELECT value FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.status = lne.status
);


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

SELECT id FROM projects AS budg
WHERE code IN (
    SELECT code FROM suppliers AS schd
    WHERE schd.id = budg.id
);


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

SELECT name FROM tasks AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS whs
    WHERE whs.status = ord.status
);


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

SELECT id FROM branches AS txn
WHERE type IN (
    SELECT type FROM categories AS sale
    WHERE sale.level = txn.level
);


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

SELECT code FROM suppliers AS srvc
WHERE value > (
    SELECT AVG(value) FROM warehouses AS whs
    WHERE whs.id = srvc.id
);


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

SELECT code FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.code = catg.code
);


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

SELECT salary FROM customers AS ord
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS cust
    WHERE cust.id = ord.id
);


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

SELECT name FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.code = prod.code
);


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

SELECT id FROM warehouses AS cust
WHERE value > (
    SELECT MAX(salary) FROM branches AS inv
    WHERE inv.code = cust.code
);


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

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


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

SELECT salary FROM categories AS srvc
WHERE status IN (
    SELECT status FROM departments AS ord
    WHERE ord.level = srvc.level
);


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

SELECT salary FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.code = cust.code
);


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

SELECT code FROM categories AS ord
WHERE id IN (
    SELECT id FROM regions AS cust
    WHERE cust.code = ord.code
);


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

SELECT id FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.id = sale.id
);


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

SELECT value FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.code = sale.code
);


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

SELECT amount FROM orders AS prod
WHERE code IN (
    SELECT code FROM employees AS ordr
    WHERE ordr.code = prod.code
);


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

SELECT amount FROM employees AS lne
WHERE value > (
    SELECT AVG(value) FROM projects AS budg
    WHERE budg.id = lne.id
);


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

SELECT value FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.status = empl.status
);


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

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


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

SELECT value FROM categories AS lne
WHERE salary > (
    SELECT SUM(value) FROM invoices AS empl
    WHERE empl.code = lne.code
);


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

SELECT value FROM suppliers AS txn
WHERE code IN (
    SELECT code FROM tasks AS prod
    WHERE prod.level = txn.level
);


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

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


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

SELECT name FROM tasks AS sale
WHERE level IN (
    SELECT level FROM regions AS dept
    WHERE dept.status = sale.status
);


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

SELECT value FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.id = schd.id
);


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

SELECT name FROM regions AS sale
WHERE level IN (
    SELECT level FROM tasks AS empl
    WHERE empl.type = sale.type
);


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

SELECT id FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.status = acct.status
);


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

SELECT id FROM regions AS budg
WHERE value > (
    SELECT SUM(salary) FROM categories AS ord
    WHERE ord.code = budg.code
);


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

SELECT amount FROM tasks AS txn
WHERE level IN (
    SELECT level FROM categories AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT code FROM branches AS empl
WHERE code IN (
    SELECT code FROM warehouses AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT id FROM warehouses AS shp
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS txn
    WHERE txn.status = shp.status
);


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

SELECT salary FROM suppliers AS catg
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.id = catg.id
);


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

SELECT value FROM products AS whs
WHERE value > (
    SELECT SUM(salary) FROM regions AS mgr
    WHERE mgr.status = whs.status
);


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

SELECT id FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.id = schd.id
);


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

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


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

SELECT code FROM transactions AS whs
WHERE amount > (
    SELECT AVG(value) FROM tasks AS txn
    WHERE txn.type = whs.type
);


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

SELECT value FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = txn.type
);


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

SELECT name FROM invoices AS sale
WHERE amount > (
    SELECT SUM(value) FROM categories AS budg
    WHERE budg.level = sale.level
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.level = rgn.level
);


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

SELECT value FROM regions AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT salary FROM accounts AS ord
WHERE value > (
    SELECT MAX(salary) FROM departments AS acct
    WHERE acct.level = ord.level
);


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

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


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

SELECT amount FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.code = emp.code
);


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

SELECT id FROM customers AS whs
WHERE level IN (
    SELECT level FROM employees AS budg
    WHERE budg.code = whs.code
);


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

SELECT value FROM customers AS mgr
WHERE code IN (
    SELECT code FROM invoices AS cust
    WHERE cust.type = mgr.type
);


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

SELECT value FROM employees AS dept
WHERE value > (
    SELECT SUM(salary) FROM products AS catg
    WHERE catg.type = dept.type
);


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

SELECT id FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = whs.id
);


Prompt:
Schema:
  warehouses (alias: whs)(date, level, status, id)
  products(date, id, level, type)
Task: Select salary from warehouses where type exists in products for the same type.
SQL:

SELECT salary FROM warehouses AS whs
WHERE type IN (
    SELECT type FROM products AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT id FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.type = ordr.type
);


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

SELECT code FROM shipments AS whs
WHERE value > (
    SELECT MAX(salary) FROM branches AS ord
    WHERE ord.id = whs.id
);


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

SELECT name FROM suppliers AS schd
WHERE amount > (
    SELECT SUM(amount) FROM products AS srvc
    WHERE srvc.type = schd.type
);


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

SELECT code FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.status = acct.status
);


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

SELECT amount FROM tasks AS txn
WHERE level IN (
    SELECT level FROM suppliers AS ordr
    WHERE ordr.level = txn.level
);


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

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


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

SELECT salary FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.level = emp.level
);


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

SELECT value FROM customers AS whs
WHERE value > (
    SELECT SUM(value) FROM categories AS inv
    WHERE inv.type = whs.type
);


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

SELECT id FROM shipments AS inv
WHERE id IN (
    SELECT id FROM branches AS cust
    WHERE cust.level = inv.level
);


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

SELECT salary FROM tasks AS shp
WHERE salary > (
    SELECT MAX(amount) FROM employees AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT amount FROM transactions AS inv
WHERE value > (
    SELECT AVG(value) FROM categories AS schd
    WHERE schd.level = inv.level
);


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

SELECT value FROM branches AS sale
WHERE amount > (
    SELECT SUM(amount) FROM products AS mgr
    WHERE mgr.type = sale.type
);


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

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


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

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


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

SELECT name FROM orders AS budg
WHERE salary > (
    SELECT MIN(amount) FROM departments AS catg
    WHERE catg.level = budg.level
);


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

SELECT salary FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.id = empl.id
);


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

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


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

SELECT salary FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.code = mgr.code
);


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

SELECT id FROM branches AS ord
WHERE salary > (
    SELECT AVG(amount) FROM projects AS inv
    WHERE inv.type = ord.type
);


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

SELECT salary FROM projects AS whs
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS budg
    WHERE budg.level = whs.level
);


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

SELECT name FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.type = lne.type
);


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

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


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

SELECT id FROM customers AS mgr
WHERE code IN (
    SELECT code FROM departments AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT id FROM branches AS acct
WHERE amount > (
    SELECT MIN(salary) FROM transactions AS txn
    WHERE txn.status = acct.status
);


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

SELECT value FROM employees AS dept
WHERE salary > (
    SELECT SUM(value) FROM categories AS txn
    WHERE txn.level = dept.level
);


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

SELECT amount FROM transactions AS cust
WHERE salary > (
    SELECT AVG(amount) FROM categories AS txn
    WHERE txn.status = cust.status
);


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

SELECT amount FROM suppliers AS mgr
WHERE salary > (
    SELECT MAX(amount) FROM employees AS whs
    WHERE whs.status = mgr.status
);


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

SELECT amount FROM tasks AS prod
WHERE amount > (
    SELECT AVG(salary) FROM orders AS acct
    WHERE acct.id = prod.id
);


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

SELECT name FROM accounts AS acct
WHERE type IN (
    SELECT type FROM products AS ord
    WHERE ord.status = acct.status
);


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

SELECT id FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.type = prod.type
);


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

SELECT value FROM departments AS emp
WHERE code IN (
    SELECT code FROM accounts AS whs
    WHERE whs.code = emp.code
);


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

SELECT name FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.code = catg.code
);


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

SELECT name FROM branches AS shp
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS budg
    WHERE budg.code = shp.code
);


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

SELECT salary FROM branches AS cust
WHERE id IN (
    SELECT id FROM employees AS budg
    WHERE budg.type = cust.type
);


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

SELECT id FROM shipments AS inv
WHERE id IN (
    SELECT id FROM accounts AS ord
    WHERE ord.id = inv.id
);


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

SELECT id FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.id = acct.id
);


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

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


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

SELECT amount FROM invoices AS lne
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.id = lne.id
);


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

SELECT salary FROM branches AS catg
WHERE type IN (
    SELECT type FROM departments AS rgn
    WHERE rgn.status = catg.status
);


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

SELECT name FROM branches AS dept
WHERE amount > (
    SELECT MIN(salary) FROM customers AS txn
    WHERE txn.level = dept.level
);


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

SELECT id FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM customers AS lne
    WHERE lne.level = mgr.level
);


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

SELECT id FROM projects AS srvc
WHERE code IN (
    SELECT code FROM accounts AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT id FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.id = sale.id
);


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

SELECT salary FROM categories AS mgr
WHERE status IN (
    SELECT status FROM regions AS budg
    WHERE budg.level = mgr.level
);


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

SELECT value FROM employees AS lne
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS acct
    WHERE acct.code = lne.code
);


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

SELECT amount FROM employees AS prod
WHERE value > (
    SELECT SUM(value) FROM regions AS txn
    WHERE txn.level = prod.level
);


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

SELECT value FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.level = dept.level
);


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

SELECT name FROM departments AS whs
WHERE code IN (
    SELECT code FROM invoices AS dept
    WHERE dept.status = whs.status
);


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

SELECT id FROM departments AS schd
WHERE code IN (
    SELECT code FROM invoices AS cust
    WHERE cust.type = schd.type
);


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

SELECT amount FROM invoices AS srvc
WHERE value > (
    SELECT COUNT(value) FROM projects AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT id FROM shipments AS lne
WHERE code IN (
    SELECT code FROM invoices AS emp
    WHERE emp.id = lne.id
);


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

SELECT id FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.code = whs.code
);


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

SELECT code FROM invoices AS rgn
WHERE code IN (
    SELECT code FROM suppliers AS srvc
    WHERE srvc.level = rgn.level
);


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

SELECT id FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.type = dept.type
);


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

SELECT name FROM regions AS txn
WHERE type IN (
    SELECT type FROM projects AS whs
    WHERE whs.id = txn.id
);


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

SELECT salary FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.code = inv.code
);


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

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


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

SELECT name FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.status = srvc.status
);


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

SELECT salary FROM transactions AS ord
WHERE code IN (
    SELECT code FROM employees AS sale
    WHERE sale.id = ord.id
);


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

SELECT salary FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT value FROM tasks AS txn
WHERE level IN (
    SELECT level FROM suppliers AS mgr
    WHERE mgr.status = txn.status
);


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

SELECT id FROM suppliers AS catg
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.level = catg.level
);


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

SELECT code FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.status = ordr.status
);


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

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


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

SELECT code FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.id = acct.id
);


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

SELECT salary FROM departments AS shp
WHERE level IN (
    SELECT level FROM accounts AS budg
    WHERE budg.id = shp.id
);


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

SELECT salary FROM warehouses AS ord
WHERE level IN (
    SELECT level FROM employees AS acct
    WHERE acct.level = ord.level
);


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

SELECT id FROM projects AS sale
WHERE type IN (
    SELECT type FROM shipments AS whs
    WHERE whs.type = sale.type
);


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

SELECT salary FROM accounts AS budg
WHERE value > (
    SELECT SUM(amount) FROM departments AS catg
    WHERE catg.status = budg.status
);


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

SELECT id FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.id = whs.id
);


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

SELECT salary FROM departments AS shp
WHERE code IN (
    SELECT code FROM orders AS acct
    WHERE acct.id = shp.id
);


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

SELECT name FROM branches AS prod
WHERE value > (
    SELECT MIN(value) FROM regions AS catg
    WHERE catg.code = prod.code
);


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

SELECT value FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.status = empl.status
);


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

SELECT id FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.type = txn.type
);


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

SELECT amount FROM regions AS emp
WHERE salary > (
    SELECT SUM(value) FROM customers AS budg
    WHERE budg.status = emp.status
);


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

SELECT code FROM tasks AS budg
WHERE level IN (
    SELECT level FROM orders AS schd
    WHERE schd.code = budg.code
);


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

SELECT code FROM categories AS mgr
WHERE amount > (
    SELECT AVG(salary) FROM projects AS shp
    WHERE shp.id = mgr.id
);


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

SELECT value FROM regions AS inv
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS emp
    WHERE emp.status = inv.status
);


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

SELECT name FROM regions AS shp
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS mgr
    WHERE mgr.code = shp.code
);


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

SELECT name FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.code = ordr.code
);


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

SELECT amount FROM suppliers AS mgr
WHERE value > (
    SELECT MIN(salary) FROM categories AS shp
    WHERE shp.level = mgr.level
);


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

SELECT code FROM regions AS ord
WHERE value > (
    SELECT COUNT(value) FROM accounts AS txn
    WHERE txn.type = ord.type
);


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

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


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

SELECT name FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.type = sale.type
);


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

SELECT name FROM regions AS sale
WHERE level IN (
    SELECT level FROM transactions AS shp
    WHERE shp.code = sale.code
);


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

SELECT value FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.status = acct.status
);


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

SELECT code FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.type = dept.type
);


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

SELECT value FROM departments AS ord
WHERE value > (
    SELECT SUM(salary) FROM invoices AS txn
    WHERE txn.id = ord.id
);


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

SELECT amount FROM warehouses AS schd
WHERE level IN (
    SELECT level FROM products AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT name FROM shipments AS dept
WHERE type IN (
    SELECT type FROM departments AS whs
    WHERE whs.code = dept.code
);


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

SELECT salary FROM transactions AS srvc
WHERE salary > (
    SELECT MAX(value) FROM projects AS inv
    WHERE inv.code = srvc.code
);


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

SELECT salary FROM shipments AS emp
WHERE salary > (
    SELECT COUNT(salary) FROM products AS shp
    WHERE shp.code = emp.code
);


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

SELECT amount FROM projects AS ordr
WHERE status IN (
    SELECT status FROM accounts AS lne
    WHERE lne.id = ordr.id
);


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

SELECT salary FROM orders AS catg
WHERE value > (
    SELECT AVG(value) FROM suppliers AS ord
    WHERE ord.code = catg.code
);


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

SELECT amount FROM shipments AS catg
WHERE salary > (
    SELECT AVG(amount) FROM employees AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT id FROM categories AS ordr
WHERE type IN (
    SELECT type FROM customers AS budg
    WHERE budg.code = ordr.code
);


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

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


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

SELECT value FROM tasks AS cust
WHERE code IN (
    SELECT code FROM categories AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT salary FROM invoices AS ordr
WHERE salary > (
    SELECT AVG(value) FROM employees AS shp
    WHERE shp.status = ordr.status
);


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

SELECT name FROM regions AS srvc
WHERE level IN (
    SELECT level FROM employees AS whs
    WHERE whs.type = srvc.type
);


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

SELECT value FROM suppliers AS mgr
WHERE id IN (
    SELECT id FROM branches AS cust
    WHERE cust.level = mgr.level
);


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

SELECT salary FROM projects AS shp
WHERE status IN (
    SELECT status FROM transactions AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT code FROM employees AS ordr
WHERE code IN (
    SELECT code FROM categories AS txn
    WHERE txn.id = ordr.id
);


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

SELECT amount FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.type = sale.type
);


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

SELECT salary FROM invoices AS txn
WHERE amount > (
    SELECT MAX(value) FROM categories AS srvc
    WHERE srvc.id = txn.id
);


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

SELECT code FROM warehouses AS cust
WHERE id IN (
    SELECT id FROM branches AS empl
    WHERE empl.level = cust.level
);


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

SELECT code FROM branches AS lne
WHERE status IN (
    SELECT status FROM employees AS srvc
    WHERE srvc.status = lne.status
);


Prompt:
Schema:
  regions (alias: ord)(name, level, id, date)
  tasks(status, name, id, level)
Task: Select name from regions where status exists in tasks for the same level.
SQL:

SELECT name FROM regions AS ord
WHERE status IN (
    SELECT status FROM tasks AS dept
    WHERE dept.level = ord.level
);


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

SELECT amount FROM products AS prod
WHERE amount > (
    SELECT SUM(amount) FROM branches AS acct
    WHERE acct.status = prod.status
);


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

SELECT value FROM regions AS lne
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS cust
    WHERE cust.id = lne.id
);


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

SELECT code FROM transactions AS ordr
WHERE value > (
    SELECT COUNT(value) FROM orders AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT value FROM shipments AS srvc
WHERE status IN (
    SELECT status FROM products AS emp
    WHERE emp.code = srvc.code
);


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

SELECT salary FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.type = sale.type
);


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

SELECT name FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.status = acct.status
);


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

SELECT amount FROM tasks AS schd
WHERE salary > (
    SELECT MIN(salary) FROM products AS budg
    WHERE budg.status = schd.status
);


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

SELECT amount FROM customers AS budg
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS ord
    WHERE ord.code = budg.code
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.id = inv.id
);


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

SELECT salary FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.status = whs.status
);


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

SELECT salary FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.level = sale.level
);


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

SELECT value FROM projects AS schd
WHERE code IN (
    SELECT code FROM shipments AS srvc
    WHERE srvc.id = schd.id
);


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

SELECT salary FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = mgr.status
);


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

SELECT amount FROM customers AS sale
WHERE status IN (
    SELECT status FROM warehouses AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT value FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.level = ordr.level
);


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

SELECT value FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = ordr.id
);


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

SELECT amount FROM transactions AS catg
WHERE status IN (
    SELECT status FROM departments AS mgr
    WHERE mgr.id = catg.id
);


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

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


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

SELECT value FROM suppliers AS ordr
WHERE code IN (
    SELECT code FROM projects AS schd
    WHERE schd.type = ordr.type
);


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

SELECT amount FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.type = mgr.type
);


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

SELECT value FROM products AS shp
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.status = shp.status
);


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

SELECT code FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT name FROM projects AS whs
WHERE salary > (
    SELECT AVG(amount) FROM orders AS prod
    WHERE prod.code = whs.code
);


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

SELECT id FROM transactions AS schd
WHERE code IN (
    SELECT code FROM departments AS whs
    WHERE whs.status = schd.status
);


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

SELECT code FROM orders AS txn
WHERE status IN (
    SELECT status FROM customers AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT value FROM categories AS schd
WHERE id IN (
    SELECT id FROM warehouses AS rgn
    WHERE rgn.level = schd.level
);


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

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


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

SELECT salary FROM tasks AS rgn
WHERE amount > (
    SELECT MIN(value) FROM transactions AS ord
    WHERE ord.type = rgn.type
);


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

SELECT code FROM warehouses AS ord
WHERE level IN (
    SELECT level FROM transactions AS lne
    WHERE lne.type = ord.type
);


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

SELECT salary FROM customers AS shp
WHERE code IN (
    SELECT code FROM categories AS emp
    WHERE emp.id = shp.id
);


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

SELECT id FROM warehouses AS cust
WHERE value > (
    SELECT MIN(salary) FROM products AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT salary FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.status = budg.status
);


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

SELECT salary FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.id = whs.id
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.level = acct.level
);


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

SELECT value FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.status = txn.status
);


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

SELECT value FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.id = whs.id
);


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

SELECT amount FROM orders AS shp
WHERE value > (
    SELECT AVG(value) FROM departments AS prod
    WHERE prod.id = shp.id
);


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

SELECT name FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.code = rgn.code
);


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

SELECT id FROM transactions AS sale
WHERE level IN (
    SELECT level FROM branches AS inv
    WHERE inv.code = sale.code
);


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

SELECT id FROM departments AS whs
WHERE level IN (
    SELECT level FROM warehouses AS dept
    WHERE dept.status = whs.status
);


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

SELECT name FROM branches AS cust
WHERE status IN (
    SELECT status FROM products AS sale
    WHERE sale.level = cust.level
);


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

SELECT id FROM warehouses AS rgn
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.level = rgn.level
);


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

SELECT code FROM accounts AS whs
WHERE value > (
    SELECT AVG(value) FROM shipments AS emp
    WHERE emp.id = whs.id
);


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

SELECT value FROM projects AS prod
WHERE value > (
    SELECT MIN(value) FROM branches AS budg
    WHERE budg.id = prod.id
);


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

SELECT id FROM invoices AS ordr
WHERE type IN (
    SELECT type FROM categories AS acct
    WHERE acct.level = ordr.level
);


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

SELECT id FROM invoices AS schd
WHERE salary > (
    SELECT SUM(amount) FROM warehouses AS srvc
    WHERE srvc.code = schd.code
);


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

SELECT code FROM employees AS txn
WHERE value > (
    SELECT SUM(value) FROM orders AS prod
    WHERE prod.status = txn.status
);


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

SELECT name FROM departments AS whs
WHERE value > (
    SELECT MIN(salary) FROM tasks AS prod
    WHERE prod.type = whs.type
);


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

SELECT value FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.type = catg.type
);


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

SELECT name FROM invoices AS lne
WHERE amount > (
    SELECT COUNT(salary) FROM warehouses AS empl
    WHERE empl.status = lne.status
);


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

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


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

SELECT id FROM branches AS acct
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.type = acct.type
);


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

SELECT id FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.status = empl.status
);


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

SELECT value FROM transactions AS catg
WHERE level IN (
    SELECT level FROM branches AS schd
    WHERE schd.level = catg.level
);


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

SELECT code FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT salary FROM branches AS acct
WHERE amount > (
    SELECT COUNT(salary) FROM shipments AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT salary FROM employees AS empl
WHERE value > (
    SELECT MIN(amount) FROM warehouses AS catg
    WHERE catg.level = empl.level
);


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

SELECT value FROM tasks AS schd
WHERE level IN (
    SELECT level FROM categories AS sale
    WHERE sale.status = schd.status
);


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

SELECT id FROM invoices AS budg
WHERE code IN (
    SELECT code FROM customers AS dept
    WHERE dept.id = budg.id
);


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

SELECT code FROM transactions AS budg
WHERE code IN (
    SELECT code FROM suppliers AS mgr
    WHERE mgr.status = budg.status
);


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

SELECT name FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.status = dept.status
);


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

SELECT code FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT name FROM accounts AS inv
WHERE salary > (
    SELECT COUNT(value) FROM orders AS acct
    WHERE acct.level = inv.level
);


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

SELECT name FROM departments AS ord
WHERE code IN (
    SELECT code FROM projects AS shp
    WHERE shp.id = ord.id
);


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

SELECT value FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.level = catg.level
);


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

SELECT salary FROM shipments AS acct
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS txn
    WHERE txn.id = acct.id
);


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

SELECT salary FROM categories AS txn
WHERE code IN (
    SELECT code FROM suppliers AS dept
    WHERE dept.type = txn.type
);


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

SELECT amount FROM categories AS txn
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.type = txn.type
);


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

SELECT amount FROM categories AS rgn
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.id = rgn.id
);


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

SELECT salary FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT salary FROM warehouses AS txn
WHERE value > (
    SELECT MIN(amount) FROM shipments AS emp
    WHERE emp.status = txn.status
);


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

SELECT id FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.type = whs.type
);


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

SELECT code FROM branches AS shp
WHERE value > (
    SELECT MAX(salary) FROM products AS sale
    WHERE sale.type = shp.type
);


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

SELECT salary FROM orders AS lne
WHERE id IN (
    SELECT id FROM departments AS rgn
    WHERE rgn.status = lne.status
);


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

SELECT name FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.code = inv.code
);


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

SELECT salary FROM invoices AS emp
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS catg
    WHERE catg.status = emp.status
);