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

SELECT id FROM suppliers AS whs
WHERE status IN (
    SELECT status FROM orders AS shp
    WHERE shp.type = whs.type
);


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

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


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.code = shp.code
);


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

SELECT salary FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.type = ordr.type
);


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

SELECT id FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.status = cust.status
);


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

SELECT id FROM accounts AS prod
WHERE level IN (
    SELECT level FROM transactions AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT amount FROM categories AS acct
WHERE value > (
    SELECT SUM(amount) FROM shipments AS catg
    WHERE catg.status = acct.status
);


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

SELECT amount FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.status = rgn.status
);


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

SELECT salary FROM branches AS shp
WHERE id IN (
    SELECT id FROM projects AS budg
    WHERE budg.code = shp.code
);


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

SELECT code FROM regions AS empl
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT salary FROM tasks AS ordr
WHERE status IN (
    SELECT status FROM regions AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT value FROM products AS sale
WHERE type IN (
    SELECT type FROM tasks AS schd
    WHERE schd.status = sale.status
);


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

SELECT salary FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT name FROM employees AS lne
WHERE level IN (
    SELECT level FROM suppliers AS catg
    WHERE catg.code = lne.code
);


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

SELECT id FROM customers AS empl
WHERE value > (
    SELECT COUNT(value) FROM orders AS dept
    WHERE dept.type = empl.type
);


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

SELECT value FROM accounts AS rgn
WHERE level IN (
    SELECT level FROM suppliers AS cust
    WHERE cust.code = rgn.code
);


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

SELECT code FROM projects AS ord
WHERE id IN (
    SELECT id FROM categories AS txn
    WHERE txn.code = ord.code
);


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

SELECT value FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.id = lne.id
);


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

SELECT id FROM employees AS schd
WHERE status IN (
    SELECT status FROM regions AS prod
    WHERE prod.level = schd.level
);


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

SELECT name FROM departments AS ordr
WHERE amount > (
    SELECT SUM(salary) FROM products AS lne
    WHERE lne.status = ordr.status
);


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

SELECT id FROM customers AS catg
WHERE level IN (
    SELECT level FROM departments AS shp
    WHERE shp.level = catg.level
);


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

SELECT value FROM tasks AS acct
WHERE status IN (
    SELECT status FROM transactions AS lne
    WHERE lne.level = acct.level
);


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

SELECT salary FROM suppliers AS dept
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS whs
    WHERE whs.status = dept.status
);


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

SELECT value FROM customers AS emp
WHERE status IN (
    SELECT status FROM branches AS sale
    WHERE sale.id = emp.id
);


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

SELECT value FROM regions AS dept
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.id = dept.id
);


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

SELECT salary FROM accounts AS lne
WHERE salary > (
    SELECT COUNT(amount) FROM warehouses AS acct
    WHERE acct.status = lne.status
);


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

SELECT amount FROM shipments AS sale
WHERE type IN (
    SELECT type FROM regions AS txn
    WHERE txn.status = sale.status
);


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

SELECT value FROM shipments AS whs
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.type = whs.type
);


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

SELECT name FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.code = schd.code
);


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

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


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

SELECT amount FROM regions AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM invoices AS empl
    WHERE empl.id = mgr.id
);


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

SELECT code FROM products AS lne
WHERE salary > (
    SELECT SUM(value) FROM invoices AS shp
    WHERE shp.id = lne.id
);


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

SELECT amount FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT salary FROM departments AS prod
WHERE code IN (
    SELECT code FROM tasks AS acct
    WHERE acct.id = prod.id
);


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

SELECT amount FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.level = shp.level
);


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

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


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

SELECT salary FROM invoices AS ordr
WHERE id IN (
    SELECT id FROM customers AS prod
    WHERE prod.id = ordr.id
);


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

SELECT code FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.type = rgn.type
);


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

SELECT salary FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.code = cust.code
);


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

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


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

SELECT amount FROM products AS lne
WHERE code IN (
    SELECT code FROM accounts AS cust
    WHERE cust.code = lne.code
);


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

SELECT salary FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT name FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.type = dept.type
);


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

SELECT id FROM employees AS lne
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS shp
    WHERE shp.level = lne.level
);


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

SELECT salary FROM tasks AS dept
WHERE amount > (
    SELECT MAX(amount) FROM categories AS ord
    WHERE ord.level = dept.level
);


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

SELECT value FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = lne.code
);


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

SELECT code FROM tasks AS ord
WHERE type IN (
    SELECT type FROM regions AS empl
    WHERE empl.level = ord.level
);


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

SELECT value FROM suppliers AS budg
WHERE salary > (
    SELECT COUNT(value) FROM orders AS srvc
    WHERE srvc.level = budg.level
);


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

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


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

SELECT name FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.type = rgn.type
);


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

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


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

SELECT id FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.level = srvc.level
);


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

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


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

SELECT name FROM tasks AS whs
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.id = whs.id
);


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

SELECT id FROM customers AS ordr
WHERE type IN (
    SELECT type FROM orders AS ord
    WHERE ord.id = ordr.id
);


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

SELECT amount FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.code = emp.code
);


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

SELECT amount FROM transactions AS ordr
WHERE level IN (
    SELECT level FROM categories AS emp
    WHERE emp.status = ordr.status
);


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

SELECT value FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.level = acct.level
);


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

SELECT salary FROM projects AS ord
WHERE id IN (
    SELECT id FROM orders AS mgr
    WHERE mgr.type = ord.type
);


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

SELECT code FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.level = cust.level
);


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

SELECT value FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.status = catg.status
);


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

SELECT id FROM tasks AS budg
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.status = budg.status
);


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

SELECT id FROM categories AS emp
WHERE amount > (
    SELECT AVG(amount) FROM orders AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT name FROM customers AS mgr
WHERE status IN (
    SELECT status FROM accounts AS prod
    WHERE prod.status = mgr.status
);


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

SELECT amount FROM invoices AS lne
WHERE type IN (
    SELECT type FROM accounts AS ordr
    WHERE ordr.type = lne.type
);


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

SELECT salary FROM accounts AS whs
WHERE value > (
    SELECT MIN(amount) FROM categories AS catg
    WHERE catg.level = whs.level
);


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

SELECT name FROM departments AS dept
WHERE value > (
    SELECT MIN(value) FROM orders AS empl
    WHERE empl.id = dept.id
);


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

SELECT value FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.code = mgr.code
);


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

SELECT code FROM regions AS empl
WHERE amount > (
    SELECT MAX(salary) FROM employees AS srvc
    WHERE srvc.level = empl.level
);


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

SELECT name FROM employees AS dept
WHERE status IN (
    SELECT status FROM tasks AS lne
    WHERE lne.status = dept.status
);


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

SELECT salary FROM accounts AS srvc
WHERE id IN (
    SELECT id FROM customers AS txn
    WHERE txn.level = srvc.level
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.id = inv.id
);


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

SELECT amount FROM products AS rgn
WHERE type IN (
    SELECT type FROM accounts AS srvc
    WHERE srvc.status = rgn.status
);


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

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


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

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


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

SELECT name FROM departments AS budg
WHERE status IN (
    SELECT status FROM transactions AS txn
    WHERE txn.id = budg.id
);


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

SELECT amount FROM shipments AS sale
WHERE value > (
    SELECT AVG(salary) FROM products AS emp
    WHERE emp.code = sale.code
);


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

SELECT salary FROM branches AS empl
WHERE level IN (
    SELECT level FROM categories AS mgr
    WHERE mgr.status = empl.status
);


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

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


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

SELECT amount FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.code = inv.code
);


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

SELECT salary FROM projects AS whs
WHERE level IN (
    SELECT level FROM regions AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT id FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.code = rgn.code
);


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

SELECT name FROM employees AS empl
WHERE salary > (
    SELECT SUM(value) FROM regions AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT amount FROM branches AS budg
WHERE amount > (
    SELECT MAX(salary) FROM employees AS ord
    WHERE ord.type = budg.type
);


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

SELECT code FROM orders AS emp
WHERE status IN (
    SELECT status FROM categories AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT value FROM departments AS empl
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.status = empl.status
);


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

SELECT id FROM customers AS whs
WHERE id IN (
    SELECT id FROM categories AS shp
    WHERE shp.id = whs.id
);


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

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


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

SELECT name FROM branches AS acct
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT salary FROM projects AS cust
WHERE value > (
    SELECT COUNT(amount) FROM employees AS budg
    WHERE budg.level = cust.level
);


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

SELECT id FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT name FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.level = txn.level
);


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

SELECT salary FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.type = rgn.type
);


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

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


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

SELECT id FROM shipments AS ordr
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.type = ordr.type
);


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

SELECT id FROM products AS shp
WHERE salary > (
    SELECT MIN(value) FROM regions AS budg
    WHERE budg.code = shp.code
);


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

SELECT value FROM departments AS schd
WHERE id IN (
    SELECT id FROM customers AS ordr
    WHERE ordr.type = schd.type
);


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

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


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

SELECT code FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.level = lne.level
);


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

SELECT code FROM customers AS whs
WHERE type IN (
    SELECT type FROM regions AS sale
    WHERE sale.type = whs.type
);


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

SELECT id FROM invoices AS sale
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.level = sale.level
);


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

SELECT name FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.type = ord.type
);


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

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


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

SELECT code FROM tasks AS acct
WHERE salary > (
    SELECT SUM(amount) FROM regions AS budg
    WHERE budg.status = acct.status
);


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

SELECT amount FROM suppliers AS sale
WHERE type IN (
    SELECT type FROM orders AS shp
    WHERE shp.type = sale.type
);


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

SELECT id FROM products AS whs
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT code FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.id = sale.id
);


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

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


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

SELECT name FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.level = txn.level
);


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

SELECT salary FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.status = schd.status
);


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

SELECT amount FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = budg.status
);


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

SELECT salary FROM shipments AS whs
WHERE salary > (
    SELECT COUNT(amount) FROM transactions AS dept
    WHERE dept.type = whs.type
);


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

SELECT amount FROM tasks AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM customers AS catg
    WHERE catg.status = ordr.status
);


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

SELECT value FROM employees AS ord
WHERE value > (
    SELECT MIN(amount) FROM shipments AS schd
    WHERE schd.id = ord.id
);


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

SELECT salary FROM regions AS srvc
WHERE value > (
    SELECT SUM(value) FROM transactions AS ordr
    WHERE ordr.status = srvc.status
);


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

SELECT code FROM tasks AS rgn
WHERE level IN (
    SELECT level FROM customers AS inv
    WHERE inv.type = rgn.type
);


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

SELECT id FROM projects AS budg
WHERE value > (
    SELECT MIN(amount) FROM employees AS ord
    WHERE ord.level = budg.level
);


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

SELECT code FROM projects AS empl
WHERE type IN (
    SELECT type FROM categories AS ordr
    WHERE ordr.id = empl.id
);


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

SELECT value FROM invoices AS rgn
WHERE amount > (
    SELECT MIN(value) FROM suppliers AS shp
    WHERE shp.status = rgn.status
);


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

SELECT id FROM shipments AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT value FROM invoices AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS shp
    WHERE shp.id = schd.id
);


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

SELECT name FROM projects AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM suppliers AS sale
    WHERE sale.type = ordr.type
);


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

SELECT id FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.level = dept.level
);


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

SELECT name FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT name FROM customers AS catg
WHERE code IN (
    SELECT code FROM branches AS ord
    WHERE ord.level = catg.level
);


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

SELECT code FROM branches AS ordr
WHERE value > (
    SELECT MAX(value) FROM accounts AS lne
    WHERE lne.type = ordr.type
);


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

SELECT value FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.id = srvc.id
);


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

SELECT id FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.code = txn.code
);


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

SELECT salary FROM branches AS emp
WHERE amount > (
    SELECT COUNT(value) FROM categories AS inv
    WHERE inv.id = emp.id
);


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

SELECT code FROM tasks AS cust
WHERE amount > (
    SELECT SUM(value) FROM employees AS prod
    WHERE prod.code = cust.code
);


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

SELECT code FROM invoices AS srvc
WHERE amount > (
    SELECT SUM(amount) FROM departments AS ord
    WHERE ord.level = srvc.level
);


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

SELECT name FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.id = schd.id
);


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

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


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

SELECT amount FROM categories AS srvc
WHERE level IN (
    SELECT level FROM invoices AS shp
    WHERE shp.type = srvc.type
);


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

SELECT id FROM orders AS catg
WHERE id IN (
    SELECT id FROM suppliers AS lne
    WHERE lne.code = catg.code
);


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

SELECT code FROM customers AS txn
WHERE type IN (
    SELECT type FROM accounts AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT id FROM regions AS whs
WHERE value > (
    SELECT MAX(salary) FROM customers AS srvc
    WHERE srvc.status = whs.status
);


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

SELECT id FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.status = lne.status
);


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

SELECT code FROM categories AS empl
WHERE amount > (
    SELECT AVG(salary) FROM warehouses AS emp
    WHERE emp.code = empl.code
);


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

SELECT code FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.id = lne.id
);


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

SELECT code FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.level = dept.level
);


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

SELECT code FROM projects AS shp
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS budg
    WHERE budg.type = shp.type
);


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

SELECT salary FROM products AS acct
WHERE status IN (
    SELECT status FROM categories AS sale
    WHERE sale.status = acct.status
);


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

SELECT id FROM regions AS rgn
WHERE salary > (
    SELECT MIN(value) FROM orders AS sale
    WHERE sale.type = rgn.type
);


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

SELECT amount FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.code = mgr.code
);


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

SELECT salary FROM orders AS whs
WHERE value > (
    SELECT AVG(amount) FROM shipments AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT name FROM categories AS dept
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS budg
    WHERE budg.id = dept.id
);


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

SELECT name FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.code = ordr.code
);


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

SELECT id FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.type = srvc.type
);


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

SELECT value FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.code = acct.code
);


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

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


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

SELECT code FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.id = inv.id
);


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

SELECT id FROM orders AS srvc
WHERE value > (
    SELECT MIN(amount) FROM invoices AS rgn
    WHERE rgn.type = srvc.type
);


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

SELECT id FROM orders AS mgr
WHERE value > (
    SELECT MIN(amount) FROM shipments AS lne
    WHERE lne.level = mgr.level
);


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

SELECT amount FROM accounts AS dept
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.id = dept.id
);


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

SELECT value FROM orders AS ord
WHERE id IN (
    SELECT id FROM customers AS catg
    WHERE catg.id = ord.id
);


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

SELECT salary FROM products AS budg
WHERE value > (
    SELECT COUNT(salary) FROM invoices AS emp
    WHERE emp.type = budg.type
);


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

SELECT value FROM orders AS cust
WHERE type IN (
    SELECT type FROM accounts AS catg
    WHERE catg.type = cust.type
);


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

SELECT code FROM shipments AS empl
WHERE amount > (
    SELECT AVG(value) FROM employees AS ordr
    WHERE ordr.id = empl.id
);


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

SELECT name FROM accounts AS mgr
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.code = mgr.code
);


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

SELECT salary FROM suppliers AS schd
WHERE value > (
    SELECT MIN(value) FROM shipments AS empl
    WHERE empl.level = schd.level
);


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

SELECT salary FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.id = prod.id
);


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

SELECT amount FROM branches AS schd
WHERE id IN (
    SELECT id FROM products AS cust
    WHERE cust.status = schd.status
);


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

SELECT name FROM tasks AS catg
WHERE status IN (
    SELECT status FROM products AS mgr
    WHERE mgr.type = catg.type
);


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

SELECT value FROM departments AS budg
WHERE type IN (
    SELECT type FROM projects AS schd
    WHERE schd.level = budg.level
);


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

SELECT name FROM orders AS dept
WHERE level IN (
    SELECT level FROM transactions AS emp
    WHERE emp.level = dept.level
);


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

SELECT value FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.id = cust.id
);


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

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


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

SELECT id FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.code = rgn.code
);


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

SELECT salary FROM shipments AS dept
WHERE salary > (
    SELECT AVG(value) FROM departments AS whs
    WHERE whs.type = dept.type
);


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

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


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

SELECT name FROM orders AS cust
WHERE code IN (
    SELECT code FROM branches AS prod
    WHERE prod.type = cust.type
);


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

SELECT name FROM employees AS emp
WHERE salary > (
    SELECT SUM(value) FROM orders AS shp
    WHERE shp.level = emp.level
);


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

SELECT name FROM products AS dept
WHERE salary > (
    SELECT MAX(value) FROM regions AS acct
    WHERE acct.id = dept.id
);


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

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


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

SELECT code FROM branches AS catg
WHERE level IN (
    SELECT level FROM products AS inv
    WHERE inv.code = catg.code
);


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

SELECT amount FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT code FROM tasks AS whs
WHERE type IN (
    SELECT type FROM regions AS txn
    WHERE txn.code = whs.code
);


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

SELECT id FROM departments AS emp
WHERE status IN (
    SELECT status FROM products AS dept
    WHERE dept.code = emp.code
);


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

SELECT code FROM categories AS ord
WHERE level IN (
    SELECT level FROM transactions AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT amount FROM regions AS txn
WHERE id IN (
    SELECT id FROM orders AS cust
    WHERE cust.code = txn.code
);


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

SELECT value FROM departments AS ordr
WHERE id IN (
    SELECT id FROM tasks AS txn
    WHERE txn.code = ordr.code
);


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

SELECT name FROM tasks AS ord
WHERE salary > (
    SELECT SUM(value) FROM transactions AS srvc
    WHERE srvc.code = ord.code
);


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

SELECT code FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT id FROM accounts AS ord
WHERE id IN (
    SELECT id FROM products AS catg
    WHERE catg.code = ord.code
);


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

SELECT name FROM projects AS txn
WHERE type IN (
    SELECT type FROM tasks AS ord
    WHERE ord.type = txn.type
);


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

SELECT name FROM accounts AS schd
WHERE code IN (
    SELECT code FROM categories AS lne
    WHERE lne.id = schd.id
);


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

SELECT code FROM projects AS dept
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.code = dept.code
);


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

SELECT code FROM employees AS prod
WHERE amount > (
    SELECT COUNT(value) FROM orders AS sale
    WHERE sale.level = prod.level
);


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

SELECT code FROM invoices AS budg
WHERE id IN (
    SELECT id FROM orders AS empl
    WHERE empl.id = budg.id
);


Prompt:
Schema:
  categories (alias: prod)(date, type, amount, value)
  customers(salary, type, date, value)
Task: Retrieve amount from categories with value above the MAX(value) of customers rows sharing the same code.
SQL:

SELECT amount FROM categories AS prod
WHERE value > (
    SELECT MAX(value) FROM customers AS mgr
    WHERE mgr.code = prod.code
);


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

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


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

SELECT amount FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.id = catg.id
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT name FROM branches AS catg
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS srvc
    WHERE srvc.type = catg.type
);


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

SELECT id FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.code = ordr.code
);


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

SELECT id FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.code = acct.code
);


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

SELECT salary FROM invoices AS whs
WHERE value > (
    SELECT SUM(value) FROM transactions AS catg
    WHERE catg.status = whs.status
);


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

SELECT id FROM transactions AS catg
WHERE code IN (
    SELECT code FROM invoices AS sale
    WHERE sale.id = catg.id
);


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

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


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

SELECT salary FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.type = rgn.type
);


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

SELECT name FROM transactions AS rgn
WHERE id IN (
    SELECT id FROM branches AS ord
    WHERE ord.level = rgn.level
);


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

SELECT salary FROM warehouses AS srvc
WHERE id IN (
    SELECT id FROM transactions AS prod
    WHERE prod.status = srvc.status
);


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

SELECT id FROM customers AS empl
WHERE code IN (
    SELECT code FROM projects AS schd
    WHERE schd.type = empl.type
);


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

SELECT salary FROM warehouses AS cust
WHERE status IN (
    SELECT status FROM departments AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT value FROM tasks AS catg
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS shp
    WHERE shp.code = catg.code
);


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

SELECT name FROM suppliers AS catg
WHERE level IN (
    SELECT level FROM customers AS empl
    WHERE empl.level = catg.level
);


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

SELECT code FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.status = catg.status
);


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

SELECT salary FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.id = whs.id
);


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

SELECT name FROM customers AS ordr
WHERE level IN (
    SELECT level FROM branches AS emp
    WHERE emp.status = ordr.status
);


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

SELECT name FROM orders AS mgr
WHERE code IN (
    SELECT code FROM products AS cust
    WHERE cust.type = mgr.type
);


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

SELECT salary FROM accounts AS cust
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS lne
    WHERE lne.type = cust.type
);


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

SELECT amount FROM invoices AS txn
WHERE id IN (
    SELECT id FROM tasks AS dept
    WHERE dept.status = txn.status
);


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

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


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

SELECT amount FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.status = ordr.status
);


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

SELECT salary FROM categories AS ord
WHERE status IN (
    SELECT status FROM projects AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT id FROM employees AS ord
WHERE id IN (
    SELECT id FROM regions AS shp
    WHERE shp.status = ord.status
);


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

SELECT name FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.code = inv.code
);


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

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


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

SELECT salary FROM employees AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS whs
    WHERE whs.code = ordr.code
);


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

SELECT name FROM transactions AS txn
WHERE level IN (
    SELECT level FROM categories AS acct
    WHERE acct.code = txn.code
);


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

SELECT code FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.status = lne.status
);


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

SELECT amount FROM transactions AS shp
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS lne
    WHERE lne.code = shp.code
);


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

SELECT id FROM products AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS lne
    WHERE lne.status = inv.status
);


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

SELECT id FROM employees AS mgr
WHERE type IN (
    SELECT type FROM regions AS shp
    WHERE shp.code = mgr.code
);


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

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


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

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


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

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


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

SELECT id FROM orders AS prod
WHERE type IN (
    SELECT type FROM shipments AS whs
    WHERE whs.code = prod.code
);


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

SELECT code FROM employees AS sale
WHERE status IN (
    SELECT status FROM tasks AS inv
    WHERE inv.id = sale.id
);


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

SELECT name FROM invoices AS rgn
WHERE status IN (
    SELECT status FROM projects AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT code FROM suppliers AS lne
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT name FROM shipments AS rgn
WHERE amount > (
    SELECT MAX(value) FROM tasks AS whs
    WHERE whs.type = rgn.type
);


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

SELECT amount FROM employees AS dept
WHERE salary > (
    SELECT MIN(amount) FROM projects AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT code FROM tasks AS ordr
WHERE value > (
    SELECT MIN(amount) FROM departments AS lne
    WHERE lne.code = ordr.code
);


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

SELECT value FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.id = emp.id
);


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

SELECT code FROM branches AS txn
WHERE amount > (
    SELECT MAX(value) FROM accounts AS prod
    WHERE prod.level = txn.level
);


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

SELECT code FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.type = lne.type
);


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

SELECT name FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.id = budg.id
);


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

SELECT amount FROM customers AS schd
WHERE value > (
    SELECT MAX(value) FROM orders AS acct
    WHERE acct.status = schd.status
);


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

SELECT value FROM transactions AS dept
WHERE salary > (
    SELECT MAX(salary) FROM products AS prod
    WHERE prod.type = dept.type
);


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

SELECT id FROM shipments AS ordr
WHERE id IN (
    SELECT id FROM branches AS empl
    WHERE empl.level = ordr.level
);


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

SELECT code FROM accounts AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.code = inv.code
);


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

SELECT id FROM employees AS inv
WHERE level IN (
    SELECT level FROM departments AS txn
    WHERE txn.code = inv.code
);


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

SELECT code FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.type = dept.type
);


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

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


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

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


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

SELECT salary FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.type = emp.type
);


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

SELECT code FROM invoices AS acct
WHERE level IN (
    SELECT level FROM products AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT name FROM branches AS ord
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS lne
    WHERE lne.type = ord.type
);


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

SELECT name FROM orders AS sale
WHERE value > (
    SELECT AVG(amount) FROM products AS emp
    WHERE emp.type = sale.type
);


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

SELECT salary FROM departments AS cust
WHERE level IN (
    SELECT level FROM invoices AS whs
    WHERE whs.type = cust.type
);


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

SELECT id FROM products AS acct
WHERE level IN (
    SELECT level FROM customers AS prod
    WHERE prod.code = acct.code
);


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

SELECT id FROM customers AS prod
WHERE code IN (
    SELECT code FROM shipments AS schd
    WHERE schd.id = prod.id
);


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

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


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

SELECT id FROM projects AS dept
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS mgr
    WHERE mgr.status = dept.status
);


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

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


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

SELECT name FROM products AS empl
WHERE id IN (
    SELECT id FROM invoices AS acct
    WHERE acct.code = empl.code
);


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

SELECT value FROM suppliers AS catg
WHERE code IN (
    SELECT code FROM branches AS inv
    WHERE inv.id = catg.id
);


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

SELECT amount FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.code = dept.code
);


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

SELECT code FROM employees AS lne
WHERE code IN (
    SELECT code FROM projects AS prod
    WHERE prod.status = lne.status
);


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

SELECT salary FROM invoices AS prod
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS ord
    WHERE ord.type = prod.type
);


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

SELECT id FROM orders AS prod
WHERE type IN (
    SELECT type FROM departments AS acct
    WHERE acct.type = prod.type
);


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

SELECT name FROM regions AS prod
WHERE level IN (
    SELECT level FROM warehouses AS txn
    WHERE txn.status = prod.status
);


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

SELECT name FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT salary FROM warehouses AS mgr
WHERE id IN (
    SELECT id FROM categories AS prod
    WHERE prod.level = mgr.level
);


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

SELECT code FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT id FROM invoices AS prod
WHERE level IN (
    SELECT level FROM branches AS emp
    WHERE emp.status = prod.status
);


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

SELECT name FROM employees AS mgr
WHERE id IN (
    SELECT id FROM transactions AS empl
    WHERE empl.status = mgr.status
);


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

SELECT id FROM regions AS cust
WHERE type IN (
    SELECT type FROM employees AS inv
    WHERE inv.code = cust.code
);


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

SELECT id FROM invoices AS cust
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS txn
    WHERE txn.id = cust.id
);


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

SELECT amount FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT code FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.status = dept.status
);


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

SELECT value FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT code FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT value FROM accounts AS sale
WHERE id IN (
    SELECT id FROM invoices AS schd
    WHERE schd.code = sale.code
);


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

SELECT value FROM products AS ordr
WHERE status IN (
    SELECT status FROM transactions AS empl
    WHERE empl.code = ordr.code
);


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

SELECT id FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.status = whs.status
);


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

SELECT value FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.level = sale.level
);


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

SELECT name FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.code = empl.code
);


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

SELECT salary FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM regions AS inv
    WHERE inv.type = ordr.type
);


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

SELECT id FROM orders AS rgn
WHERE value > (
    SELECT MIN(value) FROM regions AS catg
    WHERE catg.level = rgn.level
);


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

SELECT name FROM orders AS shp
WHERE type IN (
    SELECT type FROM tasks AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT value FROM departments AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM employees AS budg
    WHERE budg.level = ordr.level
);


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

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


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

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


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

SELECT code FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.id = cust.id
);


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

SELECT name FROM warehouses AS whs
WHERE type IN (
    SELECT type FROM departments AS emp
    WHERE emp.status = whs.status
);


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

SELECT salary FROM categories AS cust
WHERE status IN (
    SELECT status FROM branches AS ord
    WHERE ord.level = cust.level
);


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

SELECT amount FROM warehouses AS acct
WHERE status IN (
    SELECT status FROM departments AS catg
    WHERE catg.level = acct.level
);


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

SELECT value FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.id = txn.id
);


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

SELECT salary FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.code = emp.code
);


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

SELECT name FROM accounts AS rgn
WHERE status IN (
    SELECT status FROM customers AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT amount FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.code = lne.code
);


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

SELECT value FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.status = budg.status
);