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

SELECT salary FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT id FROM accounts AS txn
WHERE amount > (
    SELECT MIN(value) FROM invoices AS cust
    WHERE cust.code = txn.code
);


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT name FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.id = schd.id
);


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

SELECT name FROM accounts AS emp
WHERE code IN (
    SELECT code FROM orders AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT code FROM regions AS srvc
WHERE code IN (
    SELECT code FROM transactions AS cust
    WHERE cust.type = srvc.type
);


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

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


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

SELECT salary FROM projects AS acct
WHERE salary > (
    SELECT AVG(amount) FROM products AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT name FROM orders AS whs
WHERE value > (
    SELECT COUNT(value) FROM employees AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT value FROM projects AS ord
WHERE level IN (
    SELECT level FROM invoices AS rgn
    WHERE rgn.level = ord.level
);


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

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


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

SELECT amount FROM projects AS emp
WHERE level IN (
    SELECT level FROM categories AS catg
    WHERE catg.id = emp.id
);


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

SELECT value FROM orders AS inv
WHERE code IN (
    SELECT code FROM invoices AS shp
    WHERE shp.code = inv.code
);


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

SELECT name FROM suppliers AS lne
WHERE level IN (
    SELECT level FROM regions AS budg
    WHERE budg.id = lne.id
);


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

SELECT code FROM suppliers AS budg
WHERE value > (
    SELECT SUM(amount) FROM accounts AS acct
    WHERE acct.type = budg.type
);


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

SELECT value FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT amount FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.status = srvc.status
);


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

SELECT value FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.type = srvc.type
);


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

SELECT salary FROM products AS whs
WHERE value > (
    SELECT MAX(amount) FROM employees AS sale
    WHERE sale.status = whs.status
);


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

SELECT name FROM projects AS ord
WHERE type IN (
    SELECT type FROM orders AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT name FROM warehouses AS lne
WHERE code IN (
    SELECT code FROM employees AS whs
    WHERE whs.status = lne.status
);


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

SELECT id FROM warehouses AS whs
WHERE amount > (
    SELECT MAX(salary) FROM departments AS inv
    WHERE inv.level = whs.level
);


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

SELECT amount FROM customers AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS inv
    WHERE inv.level = ord.level
);


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

SELECT value FROM suppliers AS srvc
WHERE level IN (
    SELECT level FROM branches AS prod
    WHERE prod.code = srvc.code
);


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

SELECT id FROM transactions AS empl
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT value FROM invoices AS ord
WHERE type IN (
    SELECT type FROM customers AS rgn
    WHERE rgn.level = ord.level
);


Prompt:
Schema:
  orders (alias: inv)(value, level, type, salary)
  employees(type, name, date, level)
Task: Retrieve salary from orders with salary above the AVG(value) of employees rows sharing the same level.
SQL:

SELECT salary FROM orders AS inv
WHERE salary > (
    SELECT AVG(value) FROM employees AS emp
    WHERE emp.level = inv.level
);


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

SELECT amount FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.code = shp.code
);


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

SELECT code FROM branches AS emp
WHERE value > (
    SELECT MAX(value) FROM invoices AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT id FROM shipments AS budg
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS catg
    WHERE catg.level = budg.level
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.type = acct.type
);


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

SELECT name FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.level = ordr.level
);


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

SELECT amount FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.status = empl.status
);


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

SELECT name FROM invoices AS cust
WHERE id IN (
    SELECT id FROM categories AS schd
    WHERE schd.type = cust.type
);


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

SELECT salary FROM branches AS budg
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT amount FROM shipments AS lne
WHERE id IN (
    SELECT id FROM orders AS cust
    WHERE cust.id = lne.id
);


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

SELECT code FROM invoices AS dept
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS cust
    WHERE cust.level = dept.level
);


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

SELECT name FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.level = emp.level
);


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

SELECT code FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT amount FROM employees AS srvc
WHERE amount > (
    SELECT MAX(amount) FROM categories AS schd
    WHERE schd.id = srvc.id
);


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

SELECT id FROM accounts AS ord
WHERE value > (
    SELECT MIN(salary) FROM shipments AS emp
    WHERE emp.code = ord.code
);


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

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


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

SELECT amount FROM customers AS ord
WHERE code IN (
    SELECT code FROM products AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT salary FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.id = mgr.id
);


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

SELECT name FROM departments AS ordr
WHERE value > (
    SELECT SUM(amount) FROM branches AS sale
    WHERE sale.status = ordr.status
);


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

SELECT name FROM regions AS srvc
WHERE value > (
    SELECT SUM(value) FROM shipments AS sale
    WHERE sale.type = srvc.type
);


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

SELECT salary FROM warehouses AS srvc
WHERE salary > (
    SELECT MAX(amount) FROM employees AS txn
    WHERE txn.type = srvc.type
);


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

SELECT amount FROM shipments AS lne
WHERE status IN (
    SELECT status FROM accounts AS emp
    WHERE emp.type = lne.type
);


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

SELECT amount FROM products AS empl
WHERE id IN (
    SELECT id FROM transactions AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT name FROM suppliers AS ord
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS inv
    WHERE inv.id = ord.id
);


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

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


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

SELECT code FROM products AS whs
WHERE type IN (
    SELECT type FROM warehouses AS inv
    WHERE inv.level = whs.level
);


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

SELECT name FROM projects AS rgn
WHERE value > (
    SELECT AVG(salary) FROM regions AS whs
    WHERE whs.type = rgn.type
);


Prompt:
Schema:
  categories (alias: ord)(id, salary, type, code)
  invoices(code, type, status, salary)
Task: Retrieve salary from categories with amount above the SUM(amount) of invoices rows sharing the same status.
SQL:

SELECT salary FROM categories AS ord
WHERE amount > (
    SELECT SUM(amount) FROM invoices AS empl
    WHERE empl.status = ord.status
);


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.code = dept.code
);


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

SELECT salary FROM suppliers AS dept
WHERE status IN (
    SELECT status FROM customers AS txn
    WHERE txn.code = dept.code
);


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

SELECT amount FROM employees AS acct
WHERE salary > (
    SELECT COUNT(value) FROM shipments AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT amount FROM customers AS prod
WHERE code IN (
    SELECT code FROM departments AS cust
    WHERE cust.id = prod.id
);


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

SELECT salary FROM accounts AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM products AS ord
    WHERE ord.code = rgn.code
);


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

SELECT code FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.type = catg.type
);


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

SELECT id FROM orders AS empl
WHERE level IN (
    SELECT level FROM projects AS sale
    WHERE sale.level = empl.level
);


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

SELECT name FROM transactions AS rgn
WHERE amount > (
    SELECT MAX(salary) FROM employees AS lne
    WHERE lne.level = rgn.level
);


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

SELECT amount FROM transactions AS cust
WHERE type IN (
    SELECT type FROM warehouses AS budg
    WHERE budg.code = cust.code
);


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

SELECT name FROM shipments AS schd
WHERE type IN (
    SELECT type FROM suppliers AS emp
    WHERE emp.level = schd.level
);


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

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


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

SELECT code FROM branches AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM customers AS inv
    WHERE inv.type = ordr.type
);


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

SELECT name FROM invoices AS cust
WHERE status IN (
    SELECT status FROM customers AS prod
    WHERE prod.status = cust.status
);


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

SELECT code FROM invoices AS ord
WHERE code IN (
    SELECT code FROM projects AS sale
    WHERE sale.level = ord.level
);


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

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


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

SELECT id FROM tasks AS sale
WHERE salary > (
    SELECT MAX(amount) FROM projects AS cust
    WHERE cust.type = sale.type
);


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

SELECT salary FROM customers AS budg
WHERE type IN (
    SELECT type FROM projects AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT salary FROM orders AS mgr
WHERE type IN (
    SELECT type FROM warehouses AS schd
    WHERE schd.code = mgr.code
);


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

SELECT id FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.id = rgn.id
);


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

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


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

SELECT name FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT name FROM orders AS budg
WHERE value > (
    SELECT MAX(amount) FROM products AS sale
    WHERE sale.status = budg.status
);


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

SELECT name FROM orders AS cust
WHERE level IN (
    SELECT level FROM branches AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT value FROM invoices AS emp
WHERE status IN (
    SELECT status FROM categories AS inv
    WHERE inv.status = emp.status
);


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

SELECT code FROM regions AS budg
WHERE amount > (
    SELECT AVG(salary) FROM orders AS dept
    WHERE dept.type = budg.type
);


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

SELECT value FROM suppliers AS dept
WHERE salary > (
    SELECT SUM(value) FROM products AS emp
    WHERE emp.id = dept.id
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.type = shp.type
);


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

SELECT amount FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.level = acct.level
);


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

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


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

SELECT name FROM branches AS prod
WHERE code IN (
    SELECT code FROM employees AS rgn
    WHERE rgn.type = prod.type
);


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

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


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.level = ord.level
);


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

SELECT value FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.type = emp.type
);


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

SELECT code FROM shipments AS ordr
WHERE id IN (
    SELECT id FROM suppliers AS acct
    WHERE acct.code = ordr.code
);


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

SELECT value FROM regions AS shp
WHERE status IN (
    SELECT status FROM warehouses AS txn
    WHERE txn.id = shp.id
);


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

SELECT amount FROM departments AS catg
WHERE value > (
    SELECT MAX(salary) FROM products AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT salary FROM transactions AS catg
WHERE salary > (
    SELECT MIN(value) FROM products AS srvc
    WHERE srvc.code = catg.code
);


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

SELECT value FROM shipments AS ord
WHERE code IN (
    SELECT code FROM suppliers AS mgr
    WHERE mgr.type = ord.type
);


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

SELECT code FROM invoices AS cust
WHERE type IN (
    SELECT type FROM employees AS ord
    WHERE ord.type = cust.type
);


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

SELECT id FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT value FROM products AS cust
WHERE id IN (
    SELECT id FROM departments AS srvc
    WHERE srvc.id = cust.id
);


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

SELECT value FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.id = cust.id
);


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

SELECT salary FROM suppliers AS inv
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.type = inv.type
);


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

SELECT amount FROM customers AS dept
WHERE value > (
    SELECT MAX(value) FROM accounts AS ord
    WHERE ord.level = dept.level
);


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

SELECT name FROM tasks AS prod
WHERE level IN (
    SELECT level FROM departments AS whs
    WHERE whs.type = prod.type
);


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

SELECT code FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.type = cust.type
);


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

SELECT name FROM orders AS sale
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS acct
    WHERE acct.status = sale.status
);


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

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


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

SELECT id FROM orders AS empl
WHERE salary > (
    SELECT MAX(amount) FROM employees AS cust
    WHERE cust.status = empl.status
);


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

SELECT salary FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT salary FROM transactions AS rgn
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS shp
    WHERE shp.id = rgn.id
);


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

SELECT id FROM projects AS mgr
WHERE value > (
    SELECT COUNT(amount) FROM warehouses AS prod
    WHERE prod.status = mgr.status
);


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

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


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

SELECT amount FROM projects AS shp
WHERE type IN (
    SELECT type FROM orders AS mgr
    WHERE mgr.type = shp.type
);


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

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


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

SELECT salary FROM projects AS whs
WHERE salary > (
    SELECT MIN(value) FROM transactions AS mgr
    WHERE mgr.level = whs.level
);


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

SELECT id FROM customers AS lne
WHERE amount > (
    SELECT MIN(amount) FROM warehouses AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT salary FROM orders AS inv
WHERE code IN (
    SELECT code FROM products AS acct
    WHERE acct.status = inv.status
);


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

SELECT code FROM customers AS cust
WHERE level IN (
    SELECT level FROM regions AS prod
    WHERE prod.type = cust.type
);


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

SELECT id FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.id = ordr.id
);


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

SELECT amount FROM transactions AS budg
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS acct
    WHERE acct.status = budg.status
);


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

SELECT id FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT code FROM employees AS lne
WHERE id IN (
    SELECT id FROM categories AS mgr
    WHERE mgr.id = lne.id
);


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

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


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

SELECT name FROM projects AS sale
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.type = sale.type
);


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

SELECT amount FROM employees AS sale
WHERE id IN (
    SELECT id FROM warehouses AS ord
    WHERE ord.status = sale.status
);


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

SELECT name FROM warehouses AS mgr
WHERE type IN (
    SELECT type FROM customers AS txn
    WHERE txn.type = mgr.type
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.code = acct.code
);


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

SELECT salary FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.type = mgr.type
);


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

SELECT code FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.type = sale.type
);


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

SELECT amount FROM suppliers AS ordr
WHERE status IN (
    SELECT status FROM regions AS whs
    WHERE whs.id = ordr.id
);


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

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


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

SELECT code FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = rgn.type
);


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

SELECT amount FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT code FROM customers AS mgr
WHERE code IN (
    SELECT code FROM tasks AS dept
    WHERE dept.status = mgr.status
);


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

SELECT code FROM regions AS dept
WHERE code IN (
    SELECT code FROM customers AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT amount FROM projects AS schd
WHERE level IN (
    SELECT level FROM products AS sale
    WHERE sale.code = schd.code
);


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

SELECT salary FROM employees AS budg
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS mgr
    WHERE mgr.id = budg.id
);


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

SELECT id FROM invoices AS schd
WHERE status IN (
    SELECT status FROM transactions AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT name FROM suppliers AS inv
WHERE level IN (
    SELECT level FROM employees AS prod
    WHERE prod.type = inv.type
);


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

SELECT amount FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.id = catg.id
);


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

SELECT amount FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.status = catg.status
);


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

SELECT code FROM departments AS schd
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS prod
    WHERE prod.id = schd.id
);


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

SELECT name FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.type = rgn.type
);


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

SELECT name FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.code = inv.code
);


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

SELECT id FROM warehouses AS dept
WHERE level IN (
    SELECT level FROM shipments AS catg
    WHERE catg.level = dept.level
);


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

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


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

SELECT amount FROM transactions AS dept
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS emp
    WHERE emp.type = dept.type
);


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

SELECT code FROM warehouses AS txn
WHERE code IN (
    SELECT code FROM orders AS emp
    WHERE emp.id = txn.id
);


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

SELECT code FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.level = whs.level
);


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

SELECT name FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT code FROM warehouses AS sale
WHERE id IN (
    SELECT id FROM orders AS budg
    WHERE budg.level = sale.level
);


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

SELECT id FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.type = dept.type
);


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

SELECT salary FROM accounts AS mgr
WHERE amount > (
    SELECT MAX(salary) FROM products AS cust
    WHERE cust.code = mgr.code
);


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

SELECT value FROM suppliers AS emp
WHERE status IN (
    SELECT status FROM invoices AS shp
    WHERE shp.status = emp.status
);


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

SELECT code FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.type = budg.type
);


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

SELECT salary FROM departments AS ord
WHERE code IN (
    SELECT code FROM categories AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT value FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.status = emp.status
);


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

SELECT name FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.status = prod.status
);


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

SELECT value FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT salary FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.level = whs.level
);


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

SELECT code FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = ordr.type
);


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

SELECT id FROM invoices AS acct
WHERE salary > (
    SELECT MAX(salary) FROM branches AS inv
    WHERE inv.code = acct.code
);


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

SELECT amount FROM shipments AS mgr
WHERE id IN (
    SELECT id FROM categories AS srvc
    WHERE srvc.id = mgr.id
);


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

SELECT code FROM tasks AS inv
WHERE id IN (
    SELECT id FROM branches AS ord
    WHERE ord.id = inv.id
);


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

SELECT id FROM products AS txn
WHERE status IN (
    SELECT status FROM employees AS whs
    WHERE whs.code = txn.code
);


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

SELECT salary FROM warehouses AS dept
WHERE value > (
    SELECT AVG(value) FROM categories AS srvc
    WHERE srvc.code = dept.code
);


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

SELECT id FROM regions AS prod
WHERE code IN (
    SELECT code FROM transactions AS lne
    WHERE lne.status = prod.status
);


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

SELECT code FROM transactions AS inv
WHERE code IN (
    SELECT code FROM warehouses AS srvc
    WHERE srvc.id = inv.id
);


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

SELECT code FROM branches AS txn
WHERE value > (
    SELECT COUNT(value) FROM products AS prod
    WHERE prod.id = txn.id
);


Prompt:
Schema:
  shipments (alias: catg)(salary, value, id, status)
  categories(status, level, id, value)
Task: Retrieve value from shipments with amount above the MIN(amount) of categories rows sharing the same id.
SQL:

SELECT value FROM shipments AS catg
WHERE amount > (
    SELECT MIN(amount) FROM categories AS cust
    WHERE cust.id = catg.id
);


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

SELECT salary FROM products AS lne
WHERE code IN (
    SELECT code FROM shipments AS prod
    WHERE prod.code = lne.code
);


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

SELECT name FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = srvc.code
);


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

SELECT code FROM orders AS emp
WHERE amount > (
    SELECT MIN(value) FROM branches AS lne
    WHERE lne.id = emp.id
);


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

SELECT code FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.level = ord.level
);


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

SELECT code FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.type = ord.type
);


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

SELECT code FROM accounts AS inv
WHERE code IN (
    SELECT code FROM invoices AS cust
    WHERE cust.id = inv.id
);


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

SELECT id FROM branches AS srvc
WHERE amount > (
    SELECT COUNT(amount) FROM departments AS shp
    WHERE shp.type = srvc.type
);


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

SELECT value FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = emp.code
);


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

SELECT name FROM transactions AS ordr
WHERE code IN (
    SELECT code FROM accounts AS sale
    WHERE sale.id = ordr.id
);


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

SELECT code FROM projects AS prod
WHERE amount > (
    SELECT SUM(salary) FROM employees AS cust
    WHERE cust.level = prod.level
);


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

SELECT code FROM projects AS budg
WHERE value > (
    SELECT AVG(value) FROM shipments AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT value FROM warehouses AS emp
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.status = emp.status
);


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

SELECT id FROM accounts AS mgr
WHERE salary > (
    SELECT AVG(amount) FROM projects AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT amount FROM invoices AS sale
WHERE amount > (
    SELECT MAX(amount) FROM orders AS catg
    WHERE catg.id = sale.id
);


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

SELECT name FROM invoices AS empl
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS srvc
    WHERE srvc.status = empl.status
);


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

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


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

SELECT name FROM categories AS whs
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS acct
    WHERE acct.id = whs.id
);


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

SELECT id FROM branches AS schd
WHERE level IN (
    SELECT level FROM regions AS cust
    WHERE cust.id = schd.id
);


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

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


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

SELECT name FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.status = whs.status
);


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

SELECT id FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT salary FROM accounts AS schd
WHERE id IN (
    SELECT id FROM departments AS sale
    WHERE sale.id = schd.id
);


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

SELECT value FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.level = txn.level
);


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

SELECT salary FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT MIN(salary) FROM branches AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT code FROM regions AS prod
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS ordr
    WHERE ordr.status = prod.status
);


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

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


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

SELECT value FROM suppliers AS sale
WHERE salary > (
    SELECT COUNT(value) FROM customers AS acct
    WHERE acct.code = sale.code
);


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

SELECT amount FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.status = budg.status
);


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

SELECT amount FROM shipments AS srvc
WHERE value > (
    SELECT SUM(salary) FROM orders AS schd
    WHERE schd.level = srvc.level
);


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

SELECT value FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = cust.id
);


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

SELECT salary FROM accounts AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS whs
    WHERE whs.id = empl.id
);


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

SELECT salary FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.code = empl.code
);


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

SELECT name FROM tasks AS inv
WHERE salary > (
    SELECT AVG(salary) FROM categories AS ordr
    WHERE ordr.status = inv.status
);


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

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


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

SELECT name FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = empl.code
);


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

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


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

SELECT name FROM tasks AS ord
WHERE amount > (
    SELECT AVG(value) FROM categories AS emp
    WHERE emp.id = ord.id
);


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

SELECT value FROM branches AS cust
WHERE status IN (
    SELECT status FROM shipments AS emp
    WHERE emp.type = cust.type
);


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

SELECT amount FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.code = dept.code
);


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

SELECT value FROM invoices AS emp
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.level = emp.level
);


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

SELECT code FROM orders AS catg
WHERE type IN (
    SELECT type FROM branches AS schd
    WHERE schd.level = catg.level
);


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

SELECT salary FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.level = schd.level
);


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

SELECT name FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.type = cust.type
);


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

SELECT id FROM regions AS budg
WHERE value > (
    SELECT COUNT(amount) FROM warehouses AS sale
    WHERE sale.level = budg.level
);


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

SELECT value FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.type = prod.type
);


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

SELECT salary FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.type = shp.type
);


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

SELECT value FROM orders AS srvc
WHERE amount > (
    SELECT MIN(value) FROM categories AS prod
    WHERE prod.status = srvc.status
);


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

SELECT amount FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.type = dept.type
);


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

SELECT salary FROM tasks AS cust
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS txn
    WHERE txn.type = cust.type
);


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

SELECT salary FROM orders AS lne
WHERE salary > (
    SELECT AVG(value) FROM regions AS budg
    WHERE budg.id = lne.id
);


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

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


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

SELECT id FROM customers AS whs
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS lne
    WHERE lne.type = whs.type
);


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

SELECT name FROM branches AS cust
WHERE amount > (
    SELECT MAX(value) FROM shipments AS inv
    WHERE inv.id = cust.id
);


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

SELECT code FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.id = txn.id
);


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

SELECT salary FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.code = whs.code
);


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

SELECT code FROM regions AS sale
WHERE value > (
    SELECT AVG(salary) FROM invoices AS schd
    WHERE schd.type = sale.type
);


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

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


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

SELECT value FROM orders AS lne
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.status = lne.status
);


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

SELECT code FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.level = lne.level
);


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

SELECT amount FROM projects AS acct
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS schd
    WHERE schd.type = acct.type
);


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

SELECT code FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = mgr.status
);


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

SELECT value FROM warehouses AS catg
WHERE type IN (
    SELECT type FROM orders AS acct
    WHERE acct.id = catg.id
);


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

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


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

SELECT amount FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.id = rgn.id
);


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

SELECT code FROM transactions AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM projects AS emp
    WHERE emp.type = ordr.type
);


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

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


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

SELECT value FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT value FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT name FROM orders AS rgn
WHERE code IN (
    SELECT code FROM products AS txn
    WHERE txn.type = rgn.type
);


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

SELECT id FROM products AS ordr
WHERE value > (
    SELECT SUM(salary) FROM departments AS dept
    WHERE dept.code = ordr.code
);


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

SELECT value FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = cust.id
);


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

SELECT value FROM departments AS ord
WHERE value > (
    SELECT AVG(value) FROM orders AS cust
    WHERE cust.code = ord.code
);


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

SELECT name FROM customers AS lne
WHERE amount > (
    SELECT SUM(value) FROM tasks AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT id FROM projects AS rgn
WHERE level IN (
    SELECT level FROM customers AS dept
    WHERE dept.type = rgn.type
);


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

SELECT value FROM orders AS schd
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.code = schd.code
);


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

SELECT name FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.id = srvc.id
);


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

SELECT amount FROM accounts AS prod
WHERE amount > (
    SELECT SUM(value) FROM employees AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT id FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT id FROM warehouses AS budg
WHERE value > (
    SELECT COUNT(amount) FROM customers AS sale
    WHERE sale.status = budg.status
);


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

SELECT name FROM customers AS prod
WHERE code IN (
    SELECT code FROM categories AS schd
    WHERE schd.level = prod.level
);


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

SELECT amount FROM products AS srvc
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.type = srvc.type
);


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

SELECT amount FROM customers AS cust
WHERE type IN (
    SELECT type FROM transactions AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT amount FROM categories AS catg
WHERE id IN (
    SELECT id FROM tasks AS prod
    WHERE prod.status = catg.status
);


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

SELECT id FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.level = catg.level
);


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

SELECT amount FROM suppliers AS rgn
WHERE value > (
    SELECT MIN(value) FROM transactions AS budg
    WHERE budg.code = rgn.code
);


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

SELECT salary FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.level = whs.level
);


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

SELECT salary FROM departments AS rgn
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS emp
    WHERE emp.status = rgn.status
);


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

SELECT amount FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.type = prod.type
);


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

SELECT salary FROM products AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS catg
    WHERE catg.status = schd.status
);


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

SELECT value FROM departments AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS dept
    WHERE dept.status = schd.status
);


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

SELECT code FROM transactions AS whs
WHERE id IN (
    SELECT id FROM customers AS acct
    WHERE acct.status = whs.status
);


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

SELECT amount FROM accounts AS empl
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.code = empl.code
);


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

SELECT salary FROM employees AS cust
WHERE status IN (
    SELECT status FROM shipments AS sale
    WHERE sale.type = cust.type
);


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

SELECT name FROM invoices AS budg
WHERE status IN (
    SELECT status FROM regions AS ord
    WHERE ord.level = budg.level
);


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

SELECT value FROM invoices AS shp
WHERE amount > (
    SELECT SUM(value) FROM accounts AS ord
    WHERE ord.type = shp.type
);


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

SELECT amount FROM customers AS mgr
WHERE level IN (
    SELECT level FROM orders AS acct
    WHERE acct.type = mgr.type
);


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

SELECT name FROM departments AS sale
WHERE code IN (
    SELECT code FROM suppliers AS whs
    WHERE whs.code = sale.code
);


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

SELECT id FROM shipments AS shp
WHERE id IN (
    SELECT id FROM products AS inv
    WHERE inv.type = shp.type
);


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

SELECT id FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.id = lne.id
);


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

SELECT amount FROM orders AS sale
WHERE amount > (
    SELECT SUM(amount) FROM branches AS empl
    WHERE empl.code = sale.code
);


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

SELECT code FROM projects AS ordr
WHERE type IN (
    SELECT type FROM customers AS ord
    WHERE ord.level = ordr.level
);


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

SELECT name FROM departments AS inv
WHERE amount > (
    SELECT AVG(value) FROM transactions AS lne
    WHERE lne.status = inv.status
);


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

SELECT name FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.code = shp.code
);


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

SELECT code FROM shipments AS empl
WHERE code IN (
    SELECT code FROM employees AS whs
    WHERE whs.level = empl.level
);


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

SELECT value FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.level = srvc.level
);


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

SELECT id FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.type = acct.type
);


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

SELECT value FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = inv.level
);


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

SELECT code FROM suppliers AS lne
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS ord
    WHERE ord.type = lne.type
);


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

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


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

SELECT salary FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.id = sale.id
);


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

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


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

SELECT salary FROM accounts AS rgn
WHERE value > (
    SELECT COUNT(amount) FROM departments AS shp
    WHERE shp.type = rgn.type
);


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

SELECT value FROM orders AS cust
WHERE value > (
    SELECT SUM(amount) FROM invoices AS dept
    WHERE dept.level = cust.level
);


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

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


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

SELECT salary FROM shipments AS inv
WHERE amount > (
    SELECT SUM(amount) FROM departments AS dept
    WHERE dept.id = inv.id
);


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

SELECT name FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.code = dept.code
);


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

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


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

SELECT amount FROM shipments AS inv
WHERE level IN (
    SELECT level FROM categories AS emp
    WHERE emp.code = inv.code
);


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

SELECT value FROM departments AS emp
WHERE salary > (
    SELECT SUM(amount) FROM regions AS catg
    WHERE catg.type = emp.type
);


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

SELECT id FROM products AS emp
WHERE level IN (
    SELECT level FROM branches AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT value FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.code = rgn.code
);


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

SELECT name FROM invoices AS lne
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS acct
    WHERE acct.status = lne.status
);


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

SELECT salary FROM transactions AS catg
WHERE type IN (
    SELECT type FROM invoices AS whs
    WHERE whs.level = catg.level
);


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

SELECT value FROM transactions AS shp
WHERE code IN (
    SELECT code FROM branches AS whs
    WHERE whs.code = shp.code
);


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

SELECT amount FROM transactions AS acct
WHERE amount > (
    SELECT MAX(value) FROM regions AS shp
    WHERE shp.status = acct.status
);


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

SELECT code FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.status = shp.status
);


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

SELECT amount FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.code = srvc.code
);


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

SELECT salary FROM transactions AS prod
WHERE id IN (
    SELECT id FROM tasks AS shp
    WHERE shp.level = prod.level
);