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

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


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

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


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

SELECT code FROM warehouses AS srvc
WHERE status IN (
    SELECT status FROM departments AS acct
    WHERE acct.type = srvc.type
);


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

SELECT id FROM shipments AS mgr
WHERE value > (
    SELECT COUNT(value) FROM tasks AS acct
    WHERE acct.code = mgr.code
);


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

SELECT id FROM warehouses AS dept
WHERE id IN (
    SELECT id FROM customers AS acct
    WHERE acct.level = dept.level
);


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

SELECT salary FROM products AS schd
WHERE status IN (
    SELECT status FROM invoices AS prod
    WHERE prod.level = schd.level
);


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

SELECT code FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.id = acct.id
);


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

SELECT name FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.type = prod.type
);


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

SELECT name FROM invoices AS prod
WHERE level IN (
    SELECT level FROM transactions AS inv
    WHERE inv.id = prod.id
);


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

SELECT id FROM projects AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS budg
    WHERE budg.type = sale.type
);


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

SELECT value FROM invoices AS rgn
WHERE value > (
    SELECT MIN(amount) FROM departments AS budg
    WHERE budg.level = rgn.level
);


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

SELECT code FROM customers AS lne
WHERE id IN (
    SELECT id FROM shipments AS budg
    WHERE budg.type = lne.type
);


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

SELECT name FROM departments AS inv
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.code = inv.code
);


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

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


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

SELECT id FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.level = budg.level
);


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

SELECT value FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.code = mgr.code
);


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

SELECT amount FROM branches AS emp
WHERE value > (
    SELECT MIN(value) FROM orders AS prod
    WHERE prod.level = emp.level
);


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

SELECT salary FROM employees AS srvc
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.status = srvc.status
);


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

SELECT code FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.type = srvc.type
);


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

SELECT amount FROM regions AS acct
WHERE id IN (
    SELECT id FROM products AS emp
    WHERE emp.type = acct.type
);


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

SELECT id FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.type = cust.type
);


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

SELECT value FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.level = budg.level
);


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

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


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

SELECT value FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.status = schd.status
);


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

SELECT id FROM warehouses AS acct
WHERE value > (
    SELECT SUM(amount) FROM categories AS txn
    WHERE txn.level = acct.level
);


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

SELECT salary FROM shipments AS prod
WHERE status IN (
    SELECT status FROM orders AS empl
    WHERE empl.code = prod.code
);


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

SELECT code FROM projects AS txn
WHERE level IN (
    SELECT level FROM products AS whs
    WHERE whs.level = txn.level
);


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

SELECT id FROM suppliers AS emp
WHERE amount > (
    SELECT SUM(amount) FROM customers AS ordr
    WHERE ordr.type = emp.type
);


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

SELECT amount FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = sale.status
);


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

SELECT value FROM shipments AS budg
WHERE status IN (
    SELECT status FROM accounts AS ord
    WHERE ord.type = budg.type
);


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

SELECT salary FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.level = sale.level
);


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

SELECT name FROM suppliers AS lne
WHERE salary > (
    SELECT AVG(amount) FROM customers AS cust
    WHERE cust.id = lne.id
);


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

SELECT salary FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.code = dept.code
);


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

SELECT amount FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT value FROM orders AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM regions AS rgn
    WHERE rgn.level = ordr.level
);


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

SELECT code FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = prod.level
);


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

SELECT id FROM employees AS rgn
WHERE id IN (
    SELECT id FROM products AS catg
    WHERE catg.level = rgn.level
);


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

SELECT id FROM branches AS txn
WHERE amount > (
    SELECT MAX(amount) FROM categories AS prod
    WHERE prod.id = txn.id
);


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

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


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

SELECT salary FROM warehouses AS txn
WHERE type IN (
    SELECT type FROM projects AS lne
    WHERE lne.id = txn.id
);


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

SELECT name FROM products AS srvc
WHERE level IN (
    SELECT level FROM departments AS empl
    WHERE empl.status = srvc.status
);


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

SELECT code FROM employees AS lne
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS prod
    WHERE prod.level = lne.level
);


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

SELECT value FROM projects AS cust
WHERE code IN (
    SELECT code FROM invoices AS inv
    WHERE inv.level = cust.level
);


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

SELECT code FROM warehouses AS whs
WHERE id IN (
    SELECT id FROM projects AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT value FROM warehouses AS rgn
WHERE status IN (
    SELECT status FROM departments AS inv
    WHERE inv.code = rgn.code
);


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

SELECT salary FROM regions AS lne
WHERE salary > (
    SELECT MAX(value) FROM categories AS ordr
    WHERE ordr.code = lne.code
);


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

SELECT id FROM regions AS ordr
WHERE salary > (
    SELECT SUM(value) FROM categories AS prod
    WHERE prod.type = ordr.type
);


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

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


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

SELECT id FROM shipments AS shp
WHERE level IN (
    SELECT level FROM orders AS budg
    WHERE budg.level = shp.level
);


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

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


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

SELECT salary FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = sale.level
);


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

SELECT id FROM suppliers AS ordr
WHERE value > (
    SELECT AVG(salary) FROM employees AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT salary FROM branches AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM products AS lne
    WHERE lne.type = rgn.type
);


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

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


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

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


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

SELECT id FROM departments AS schd
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.code = schd.code
);


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

SELECT amount FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT name FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = dept.status
);


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

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


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

SELECT amount FROM projects AS prod
WHERE id IN (
    SELECT id FROM departments AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT name FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.id = txn.id
);


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

SELECT name FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.status = cust.status
);


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

SELECT name FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.type = dept.type
);


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

SELECT amount FROM tasks AS shp
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS dept
    WHERE dept.code = shp.code
);


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

SELECT salary FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.level = dept.level
);


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

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


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

SELECT value FROM products AS txn
WHERE salary > (
    SELECT COUNT(value) FROM suppliers AS inv
    WHERE inv.code = txn.code
);


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

SELECT salary FROM warehouses AS ordr
WHERE salary > (
    SELECT AVG(value) FROM departments AS acct
    WHERE acct.id = ordr.id
);


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

SELECT code FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.level = prod.level
);


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

SELECT id FROM categories AS sale
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.type = sale.type
);


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

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


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

SELECT name FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.level = acct.level
);


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

SELECT amount FROM transactions AS ord
WHERE amount > (
    SELECT AVG(amount) FROM employees AS schd
    WHERE schd.level = ord.level
);


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

SELECT value FROM invoices AS empl
WHERE id IN (
    SELECT id FROM departments AS ordr
    WHERE ordr.level = empl.level
);


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

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


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

SELECT value FROM departments AS dept
WHERE status IN (
    SELECT status FROM accounts AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT name FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.status = mgr.status
);


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

SELECT code FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.status = mgr.status
);


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

SELECT value FROM transactions AS dept
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS sale
    WHERE sale.code = dept.code
);


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

SELECT code FROM products AS srvc
WHERE amount > (
    SELECT SUM(value) FROM customers AS txn
    WHERE txn.id = srvc.id
);


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

SELECT amount FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT id FROM customers AS txn
WHERE type IN (
    SELECT type FROM invoices AS whs
    WHERE whs.code = txn.code
);


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

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


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

SELECT salary FROM customers AS srvc
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS acct
    WHERE acct.code = srvc.code
);


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

SELECT id FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.id = budg.id
);


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

SELECT name FROM transactions AS catg
WHERE level IN (
    SELECT level FROM shipments AS txn
    WHERE txn.code = catg.code
);


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

SELECT value FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.status = sale.status
);


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

SELECT amount FROM accounts AS txn
WHERE salary > (
    SELECT MAX(salary) FROM departments AS srvc
    WHERE srvc.id = txn.id
);


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

SELECT code FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.id = rgn.id
);


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

SELECT amount FROM accounts AS prod
WHERE code IN (
    SELECT code FROM transactions AS whs
    WHERE whs.code = prod.code
);


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

SELECT amount FROM employees AS shp
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS catg
    WHERE catg.code = shp.code
);


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

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


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

SELECT value FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.level = inv.level
);


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

SELECT code FROM invoices AS dept
WHERE status IN (
    SELECT status FROM accounts AS schd
    WHERE schd.type = dept.type
);


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

SELECT salary FROM orders AS dept
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS whs
    WHERE whs.status = dept.status
);


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

SELECT amount FROM categories AS srvc
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.code = srvc.code
);


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

SELECT code FROM projects AS shp
WHERE value > (
    SELECT MIN(amount) FROM orders AS txn
    WHERE txn.type = shp.type
);


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

SELECT id FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.type = rgn.type
);


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

SELECT code FROM shipments AS sale
WHERE salary > (
    SELECT MIN(amount) FROM products AS prod
    WHERE prod.code = sale.code
);


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

SELECT salary FROM orders AS emp
WHERE id IN (
    SELECT id FROM tasks AS acct
    WHERE acct.id = emp.id
);


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

SELECT code FROM products AS budg
WHERE id IN (
    SELECT id FROM customers AS emp
    WHERE emp.status = budg.status
);


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

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


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

SELECT salary FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.type = prod.type
);


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

SELECT name FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.type = dept.type
);


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

SELECT name FROM shipments AS budg
WHERE salary > (
    SELECT COUNT(salary) FROM branches AS txn
    WHERE txn.id = budg.id
);


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

SELECT value FROM departments AS srvc
WHERE id IN (
    SELECT id FROM warehouses AS shp
    WHERE shp.type = srvc.type
);


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

SELECT code FROM products AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS whs
    WHERE whs.id = catg.id
);


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

SELECT code FROM tasks AS ordr
WHERE amount > (
    SELECT COUNT(value) FROM products AS srvc
    WHERE srvc.status = ordr.status
);


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

SELECT value FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.code = shp.code
);


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

SELECT id FROM invoices AS empl
WHERE amount > (
    SELECT SUM(value) FROM tasks AS schd
    WHERE schd.status = empl.status
);


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

SELECT value FROM customers AS srvc
WHERE level IN (
    SELECT level FROM branches AS rgn
    WHERE rgn.level = srvc.level
);


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

SELECT name FROM orders AS whs
WHERE id IN (
    SELECT id FROM accounts AS txn
    WHERE txn.code = whs.code
);


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

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


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

SELECT value FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT amount FROM employees AS schd
WHERE id IN (
    SELECT id FROM warehouses AS txn
    WHERE txn.status = schd.status
);


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

SELECT value FROM employees AS ordr
WHERE level IN (
    SELECT level FROM invoices AS inv
    WHERE inv.type = ordr.type
);


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

SELECT amount FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = shp.status
);


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

SELECT name FROM tasks AS srvc
WHERE salary > (
    SELECT COUNT(salary) FROM warehouses AS lne
    WHERE lne.code = srvc.code
);


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

SELECT name FROM departments AS lne
WHERE amount > (
    SELECT COUNT(value) FROM branches AS inv
    WHERE inv.level = lne.level
);


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

SELECT id FROM products AS ord
WHERE value > (
    SELECT AVG(value) FROM regions AS emp
    WHERE emp.level = ord.level
);


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

SELECT code FROM suppliers AS prod
WHERE id IN (
    SELECT id FROM projects AS whs
    WHERE whs.level = prod.level
);


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

SELECT name FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.code = shp.code
);


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

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


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

SELECT salary FROM categories AS whs
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.status = whs.status
);


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

SELECT value FROM customers AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM orders AS sale
    WHERE sale.type = srvc.type
);


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

SELECT name FROM departments AS mgr
WHERE id IN (
    SELECT id FROM regions AS prod
    WHERE prod.code = mgr.code
);


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

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


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

SELECT salary FROM accounts AS lne
WHERE level IN (
    SELECT level FROM customers AS ord
    WHERE ord.code = lne.code
);


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

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


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

SELECT salary FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.status = emp.status
);


Prompt:
Schema:
  invoices (alias: prod)(amount, value, date, level)
  customers(amount, status, value, date)
Task: Select value from invoices where type exists in customers for the same status.
SQL:

SELECT value FROM invoices AS prod
WHERE type IN (
    SELECT type FROM customers AS dept
    WHERE dept.status = prod.status
);


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

SELECT id FROM warehouses AS prod
WHERE value > (
    SELECT COUNT(amount) FROM accounts AS cust
    WHERE cust.type = prod.type
);


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

SELECT id FROM orders AS empl
WHERE salary > (
    SELECT SUM(salary) FROM products AS sale
    WHERE sale.type = empl.type
);


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

SELECT name FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.status = empl.status
);


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

SELECT name FROM warehouses AS acct
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS prod
    WHERE prod.id = acct.id
);


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

SELECT amount FROM tasks AS sale
WHERE code IN (
    SELECT code FROM accounts AS emp
    WHERE emp.id = sale.id
);


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

SELECT name FROM invoices AS budg
WHERE code IN (
    SELECT code FROM orders AS shp
    WHERE shp.code = budg.code
);


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

SELECT value FROM invoices AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM shipments AS ordr
    WHERE ordr.level = srvc.level
);


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

SELECT code FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.type = dept.type
);


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

SELECT amount FROM transactions AS acct
WHERE level IN (
    SELECT level FROM tasks AS dept
    WHERE dept.status = acct.status
);


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

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


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

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


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

SELECT amount FROM transactions AS catg
WHERE value > (
    SELECT SUM(value) FROM categories AS ord
    WHERE ord.type = catg.type
);


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

SELECT id FROM products AS inv
WHERE level IN (
    SELECT level FROM shipments AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT value FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.code = ordr.code
);


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

SELECT value FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.status = schd.status
);


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

SELECT id FROM customers AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS lne
    WHERE lne.id = rgn.id
);


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

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


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

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


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

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


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

SELECT code FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT value FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.code = acct.code
);


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

SELECT salary FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.level = budg.level
);


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

SELECT salary FROM branches AS schd
WHERE value > (
    SELECT SUM(salary) FROM tasks AS acct
    WHERE acct.code = schd.code
);


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

SELECT name FROM suppliers AS lne
WHERE value > (
    SELECT MAX(value) FROM shipments AS dept
    WHERE dept.type = lne.type
);


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

SELECT salary FROM regions AS acct
WHERE type IN (
    SELECT type FROM customers AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT id FROM branches AS srvc
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS shp
    WHERE shp.type = srvc.type
);


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

SELECT salary FROM warehouses AS empl
WHERE value > (
    SELECT SUM(salary) FROM projects AS ordr
    WHERE ordr.status = empl.status
);


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

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


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

SELECT id FROM shipments AS cust
WHERE value > (
    SELECT SUM(amount) FROM regions AS shp
    WHERE shp.type = cust.type
);


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

SELECT name FROM orders AS rgn
WHERE level IN (
    SELECT level FROM projects AS sale
    WHERE sale.level = rgn.level
);


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

SELECT name FROM projects AS budg
WHERE id IN (
    SELECT id FROM orders AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT name FROM regions AS emp
WHERE level IN (
    SELECT level FROM categories AS ordr
    WHERE ordr.id = emp.id
);


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

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


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

SELECT code FROM branches AS empl
WHERE value > (
    SELECT MIN(amount) FROM tasks AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT name FROM shipments AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT salary FROM departments AS prod
WHERE status IN (
    SELECT status FROM invoices AS empl
    WHERE empl.code = prod.code
);


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

SELECT amount FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.level = budg.level
);


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

SELECT name FROM customers AS emp
WHERE value > (
    SELECT COUNT(amount) FROM orders AS catg
    WHERE catg.status = emp.status
);


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

SELECT salary FROM warehouses AS acct
WHERE type IN (
    SELECT type FROM projects AS sale
    WHERE sale.type = acct.type
);


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

SELECT code FROM branches AS acct
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.level = acct.level
);


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

SELECT amount FROM categories AS cust
WHERE type IN (
    SELECT type FROM regions AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT id FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.code = rgn.code
);


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

SELECT id FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.type = sale.type
);


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

SELECT code FROM customers AS sale
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS inv
    WHERE inv.level = sale.level
);


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

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


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

SELECT amount FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.id = mgr.id
);


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

SELECT salary FROM customers AS cust
WHERE salary > (
    SELECT SUM(salary) FROM warehouses AS sale
    WHERE sale.type = cust.type
);


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

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


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

SELECT name FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.id = budg.id
);


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

SELECT value FROM suppliers AS budg
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS mgr
    WHERE mgr.status = budg.status
);


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

SELECT amount FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.code = rgn.code
);


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

SELECT amount FROM employees AS ordr
WHERE id IN (
    SELECT id FROM projects AS whs
    WHERE whs.code = ordr.code
);


Prompt:
Schema:
  transactions (alias: shp)(status, date, value, amount)
  accounts(value, name, status, level)
Task: Retrieve name from transactions with amount above the SUM(amount) of accounts rows sharing the same status.
SQL:

SELECT name FROM transactions AS shp
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS dept
    WHERE dept.status = shp.status
);


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

SELECT salary FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.status = schd.status
);


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

SELECT value FROM employees AS budg
WHERE level IN (
    SELECT level FROM tasks AS emp
    WHERE emp.level = budg.level
);


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

SELECT value FROM projects AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM products AS schd
    WHERE schd.code = ordr.code
);


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

SELECT salary FROM transactions AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS srvc
    WHERE srvc.code = txn.code
);


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

SELECT name FROM suppliers AS txn
WHERE status IN (
    SELECT status FROM employees AS dept
    WHERE dept.status = txn.status
);


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

SELECT code FROM orders AS budg
WHERE salary > (
    SELECT MIN(salary) FROM invoices AS prod
    WHERE prod.status = budg.status
);


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

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


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

SELECT value FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.type = whs.type
);


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

SELECT salary FROM transactions AS cust
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.status = cust.status
);


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

SELECT amount FROM customers AS txn
WHERE salary > (
    SELECT COUNT(value) FROM departments AS acct
    WHERE acct.code = txn.code
);


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

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


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

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


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

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


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

SELECT name FROM invoices AS schd
WHERE level IN (
    SELECT level FROM departments AS ord
    WHERE ord.code = schd.code
);


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

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


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

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


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

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


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

SELECT id FROM employees AS dept
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS catg
    WHERE catg.status = dept.status
);


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

SELECT code FROM invoices AS acct
WHERE code IN (
    SELECT code FROM suppliers AS ord
    WHERE ord.code = acct.code
);


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

SELECT name FROM departments AS empl
WHERE code IN (
    SELECT code FROM tasks AS catg
    WHERE catg.id = empl.id
);


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

SELECT name FROM customers AS empl
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS dept
    WHERE dept.level = empl.level
);


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

SELECT name FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.status = txn.status
);


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

SELECT id FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.code = mgr.code
);


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

SELECT value FROM orders AS txn
WHERE code IN (
    SELECT code FROM warehouses AS ord
    WHERE ord.status = txn.status
);


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

SELECT value FROM transactions AS emp
WHERE amount > (
    SELECT AVG(amount) FROM departments AS empl
    WHERE empl.status = emp.status
);


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

SELECT amount FROM employees AS txn
WHERE code IN (
    SELECT code FROM regions AS empl
    WHERE empl.id = txn.id
);


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

SELECT value FROM shipments AS dept
WHERE salary > (
    SELECT MIN(salary) FROM departments AS cust
    WHERE cust.status = dept.status
);


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

SELECT salary FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.code = emp.code
);


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

SELECT value FROM categories AS cust
WHERE amount > (
    SELECT AVG(value) FROM products AS budg
    WHERE budg.code = cust.code
);


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

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


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

SELECT amount FROM customers AS inv
WHERE amount > (
    SELECT SUM(value) FROM invoices AS shp
    WHERE shp.id = inv.id
);


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

SELECT salary FROM categories AS txn
WHERE status IN (
    SELECT status FROM invoices AS prod
    WHERE prod.level = txn.level
);


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

SELECT name FROM employees AS acct
WHERE id IN (
    SELECT id FROM suppliers AS srvc
    WHERE srvc.code = acct.code
);


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

SELECT value FROM departments AS dept
WHERE amount > (
    SELECT SUM(value) FROM categories AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT code FROM branches AS inv
WHERE value > (
    SELECT COUNT(value) FROM accounts AS lne
    WHERE lne.status = inv.status
);


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

SELECT id FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.type = emp.type
);


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

SELECT value FROM shipments AS catg
WHERE code IN (
    SELECT code FROM employees AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT amount FROM employees AS emp
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.status = emp.status
);


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

SELECT amount FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.code = ordr.code
);


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

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


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

SELECT value FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.level = ordr.level
);


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

SELECT amount FROM regions AS empl
WHERE type IN (
    SELECT type FROM orders AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT id FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.id = schd.id
);


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

SELECT salary FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.level = cust.level
);


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

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


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

SELECT name FROM accounts AS budg
WHERE code IN (
    SELECT code FROM categories AS ord
    WHERE ord.code = budg.code
);


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

SELECT amount FROM accounts AS schd
WHERE code IN (
    SELECT code FROM tasks AS budg
    WHERE budg.type = schd.type
);


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

SELECT id FROM projects AS whs
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS prod
    WHERE prod.type = whs.type
);


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

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


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

SELECT salary FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.level = srvc.level
);


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

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


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

SELECT salary FROM employees AS catg
WHERE type IN (
    SELECT type FROM departments AS mgr
    WHERE mgr.status = catg.status
);


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

SELECT id FROM tasks AS budg
WHERE salary > (
    SELECT AVG(salary) FROM categories AS schd
    WHERE schd.type = budg.type
);


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

SELECT id FROM categories AS sale
WHERE level IN (
    SELECT level FROM customers AS catg
    WHERE catg.level = sale.level
);


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

SELECT salary FROM warehouses AS empl
WHERE status IN (
    SELECT status FROM shipments AS budg
    WHERE budg.type = empl.type
);


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

SELECT name FROM warehouses AS whs
WHERE level IN (
    SELECT level FROM suppliers AS lne
    WHERE lne.id = whs.id
);


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

SELECT amount FROM transactions AS budg
WHERE salary > (
    SELECT AVG(salary) FROM branches AS acct
    WHERE acct.level = budg.level
);


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

SELECT amount FROM tasks AS acct
WHERE id IN (
    SELECT id FROM invoices AS catg
    WHERE catg.id = acct.id
);


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

SELECT id FROM departments AS ord
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS cust
    WHERE cust.code = ord.code
);


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

SELECT value FROM invoices AS txn
WHERE code IN (
    SELECT code FROM transactions AS whs
    WHERE whs.level = txn.level
);


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

SELECT name FROM categories AS whs
WHERE salary > (
    SELECT COUNT(value) FROM employees AS emp
    WHERE emp.id = whs.id
);


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

SELECT salary FROM accounts AS txn
WHERE code IN (
    SELECT code FROM branches AS schd
    WHERE schd.code = txn.code
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT MIN(value) FROM customers AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT code FROM tasks AS mgr
WHERE value > (
    SELECT MAX(amount) FROM accounts AS txn
    WHERE txn.code = mgr.code
);


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

SELECT code FROM products AS acct
WHERE salary > (
    SELECT AVG(amount) FROM departments AS shp
    WHERE shp.level = acct.level
);


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

SELECT value FROM suppliers AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM warehouses AS acct
    WHERE acct.status = ordr.status
);


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

SELECT id FROM branches AS inv
WHERE code IN (
    SELECT code FROM categories AS dept
    WHERE dept.code = inv.code
);


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

SELECT salary FROM warehouses AS mgr
WHERE level IN (
    SELECT level FROM invoices AS whs
    WHERE whs.id = mgr.id
);


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

SELECT amount FROM shipments AS txn
WHERE id IN (
    SELECT id FROM categories AS catg
    WHERE catg.type = txn.type
);


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

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


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

SELECT name FROM customers AS inv
WHERE salary > (
    SELECT AVG(value) FROM categories AS acct
    WHERE acct.status = inv.status
);


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

SELECT amount FROM projects AS cust
WHERE amount > (
    SELECT MIN(value) FROM products AS sale
    WHERE sale.type = cust.type
);


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

SELECT value FROM categories AS emp
WHERE code IN (
    SELECT code FROM tasks AS sale
    WHERE sale.level = emp.level
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.code = budg.code
);


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

SELECT code FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.status = empl.status
);


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

SELECT name FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT value FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.status = cust.status
);


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

SELECT name FROM customers AS schd
WHERE amount > (
    SELECT AVG(salary) FROM orders AS cust
    WHERE cust.type = schd.type
);


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

SELECT amount FROM categories AS whs
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.id = whs.id
);


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

SELECT name FROM warehouses AS ord
WHERE amount > (
    SELECT MIN(salary) FROM orders AS catg
    WHERE catg.type = ord.type
);


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

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


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

SELECT salary FROM regions AS dept
WHERE level IN (
    SELECT level FROM departments AS emp
    WHERE emp.level = dept.level
);


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

SELECT amount FROM suppliers AS mgr
WHERE id IN (
    SELECT id FROM regions AS ord
    WHERE ord.id = mgr.id
);


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

SELECT id FROM invoices AS catg
WHERE value > (
    SELECT SUM(salary) FROM transactions AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT id FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT name FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.type = schd.type
);


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

SELECT name FROM customers AS catg
WHERE type IN (
    SELECT type FROM orders AS cust
    WHERE cust.type = catg.type
);


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

SELECT id FROM customers AS ordr
WHERE value > (
    SELECT MIN(value) FROM employees AS prod
    WHERE prod.level = ordr.level
);


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

SELECT salary FROM transactions AS acct
WHERE type IN (
    SELECT type FROM regions AS ord
    WHERE ord.type = acct.type
);


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

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


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

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


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

SELECT salary FROM warehouses AS catg
WHERE status IN (
    SELECT status FROM products AS sale
    WHERE sale.status = catg.status
);


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

SELECT amount FROM projects AS prod
WHERE code IN (
    SELECT code FROM employees AS sale
    WHERE sale.type = prod.type
);


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

SELECT salary FROM orders AS srvc
WHERE amount > (
    SELECT MIN(value) FROM warehouses AS txn
    WHERE txn.code = srvc.code
);


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

SELECT id FROM departments AS catg
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS empl
    WHERE empl.id = catg.id
);


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

SELECT code FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.code = dept.code
);


Prompt:
Schema:
  customers (alias: empl)(level, type, date, amount)
  products(level, status, amount, name)
Task: Retrieve name from customers with value above the MAX(amount) of products rows sharing the same level.
SQL:

SELECT name FROM customers AS empl
WHERE value > (
    SELECT MAX(amount) FROM products AS acct
    WHERE acct.level = empl.level
);


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

SELECT code FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.id = mgr.id
);


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

SELECT code FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.code = catg.code
);


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

SELECT name FROM warehouses AS lne
WHERE type IN (
    SELECT type FROM categories AS inv
    WHERE inv.type = lne.type
);


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

SELECT salary FROM shipments AS lne
WHERE value > (
    SELECT SUM(salary) FROM employees AS inv
    WHERE inv.id = lne.id
);


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

SELECT value FROM accounts AS dept
WHERE type IN (
    SELECT type FROM shipments AS lne
    WHERE lne.code = dept.code
);


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

SELECT code FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.level = sale.level
);


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

SELECT value FROM customers AS schd
WHERE type IN (
    SELECT type FROM tasks AS prod
    WHERE prod.level = schd.level
);


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

SELECT code FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.level = ord.level
);


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

SELECT id FROM categories AS acct
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT amount FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM tasks AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT id FROM suppliers AS lne
WHERE value > (
    SELECT SUM(value) FROM invoices AS whs
    WHERE whs.status = lne.status
);


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

SELECT salary FROM employees AS cust
WHERE id IN (
    SELECT id FROM customers AS prod
    WHERE prod.level = cust.level
);