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

SELECT amount FROM suppliers AS inv
WHERE code IN (
    SELECT code FROM orders AS whs
    WHERE whs.id = inv.id
);


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

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


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

SELECT name FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.level = shp.level
);


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

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


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

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


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

SELECT value FROM projects AS cust
WHERE salary > (
    SELECT MIN(salary) FROM customers AS inv
    WHERE inv.code = cust.code
);


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

SELECT salary FROM regions AS sale
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.id = sale.id
);


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

SELECT amount FROM departments AS ordr
WHERE amount > (
    SELECT AVG(value) FROM employees AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT salary FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = whs.status
);


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

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


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

SELECT value FROM orders AS rgn
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS ord
    WHERE ord.status = rgn.status
);


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

SELECT name FROM warehouses AS inv
WHERE status IN (
    SELECT status FROM tasks AS dept
    WHERE dept.code = inv.code
);


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

SELECT id FROM regions AS schd
WHERE salary > (
    SELECT SUM(value) FROM suppliers AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT value FROM branches AS catg
WHERE value > (
    SELECT COUNT(value) FROM departments AS budg
    WHERE budg.type = catg.type
);


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

SELECT value FROM warehouses AS emp
WHERE level IN (
    SELECT level FROM customers AS budg
    WHERE budg.type = emp.type
);


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

SELECT salary FROM departments AS mgr
WHERE code IN (
    SELECT code FROM accounts AS txn
    WHERE txn.level = mgr.level
);


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

SELECT salary FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.code = ord.code
);


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

SELECT id FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.type = schd.type
);


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

SELECT code FROM warehouses AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM orders AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT salary FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.code = sale.code
);


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

SELECT id FROM categories AS txn
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS inv
    WHERE inv.level = txn.level
);


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

SELECT id FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT value FROM branches AS empl
WHERE type IN (
    SELECT type FROM employees AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT value FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.type = dept.type
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT code FROM shipments AS txn
WHERE type IN (
    SELECT type FROM accounts AS whs
    WHERE whs.level = txn.level
);


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

SELECT id FROM shipments AS budg
WHERE type IN (
    SELECT type FROM suppliers AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.level = prod.level
);


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

SELECT salary FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.level = sale.level
);


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

SELECT value FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.code = empl.code
);


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

SELECT value FROM warehouses AS txn
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS ord
    WHERE ord.code = txn.code
);


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

SELECT code FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.id = schd.id
);


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

SELECT id FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.code = whs.code
);


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

SELECT id FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.type = mgr.type
);


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

SELECT salary FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT salary FROM warehouses AS txn
WHERE salary > (
    SELECT MAX(value) FROM categories AS prod
    WHERE prod.id = txn.id
);


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

SELECT value FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.status = lne.status
);


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

SELECT salary FROM employees AS budg
WHERE amount > (
    SELECT COUNT(amount) FROM accounts AS emp
    WHERE emp.level = budg.level
);


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

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


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

SELECT value FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = inv.type
);


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

SELECT amount FROM transactions AS shp
WHERE salary > (
    SELECT COUNT(value) FROM customers AS txn
    WHERE txn.id = shp.id
);


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

SELECT name FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.type = inv.type
);


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

SELECT id FROM products AS lne
WHERE status IN (
    SELECT status FROM projects AS emp
    WHERE emp.id = lne.id
);


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

SELECT name FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.type = lne.type
);


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

SELECT id FROM suppliers AS budg
WHERE code IN (
    SELECT code FROM warehouses AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT salary FROM products AS sale
WHERE salary > (
    SELECT MAX(amount) FROM categories AS dept
    WHERE dept.code = sale.code
);


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

SELECT amount FROM categories AS lne
WHERE level IN (
    SELECT level FROM invoices AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT amount FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.type = inv.type
);


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

SELECT id FROM departments AS catg
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS empl
    WHERE empl.status = catg.status
);


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

SELECT amount FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.code = whs.code
);


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

SELECT value FROM departments AS prod
WHERE value > (
    SELECT SUM(value) FROM products AS srvc
    WHERE srvc.code = prod.code
);


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

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


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

SELECT value FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = sale.id
);


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

SELECT amount FROM regions AS ordr
WHERE level IN (
    SELECT level FROM shipments AS txn
    WHERE txn.type = ordr.type
);


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

SELECT value FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.level = acct.level
);


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

SELECT id FROM orders AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM categories AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT amount FROM customers AS lne
WHERE amount > (
    SELECT SUM(amount) FROM employees AS inv
    WHERE inv.status = lne.status
);


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

SELECT amount FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.id = ordr.id
);


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

SELECT value FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.code = inv.code
);


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

SELECT id FROM tasks AS sale
WHERE status IN (
    SELECT status FROM shipments AS ord
    WHERE ord.type = sale.type
);


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

SELECT id FROM branches AS prod
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS catg
    WHERE catg.level = prod.level
);


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

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


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

SELECT id FROM invoices AS emp
WHERE level IN (
    SELECT level FROM employees AS schd
    WHERE schd.level = emp.level
);


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

SELECT value FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.level = acct.level
);


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

SELECT code FROM regions AS srvc
WHERE type IN (
    SELECT type FROM projects AS emp
    WHERE emp.id = srvc.id
);


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

SELECT amount FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT id FROM branches AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS dept
    WHERE dept.code = txn.code
);


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

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


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

SELECT id FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT code FROM regions AS budg
WHERE salary > (
    SELECT AVG(amount) FROM projects AS acct
    WHERE acct.id = budg.id
);


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

SELECT id FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.id = mgr.id
);


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

SELECT value FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT salary FROM projects AS inv
WHERE value > (
    SELECT MIN(amount) FROM regions AS dept
    WHERE dept.code = inv.code
);


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

SELECT id FROM transactions AS budg
WHERE value > (
    SELECT MAX(value) FROM categories AS txn
    WHERE txn.id = budg.id
);


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

SELECT amount FROM suppliers AS cust
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.type = cust.type
);


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

SELECT code FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.status = lne.status
);


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

SELECT name FROM shipments AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM customers AS cust
    WHERE cust.code = srvc.code
);


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

SELECT salary FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.status = sale.status
);


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

SELECT value FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.id = emp.id
);


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

SELECT code FROM branches AS emp
WHERE code IN (
    SELECT code FROM tasks AS cust
    WHERE cust.code = emp.code
);


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

SELECT amount FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.level = whs.level
);


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

SELECT salary FROM invoices AS acct
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS catg
    WHERE catg.type = acct.type
);


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

SELECT value FROM warehouses AS lne
WHERE status IN (
    SELECT status FROM accounts AS ord
    WHERE ord.status = lne.status
);


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

SELECT id FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT value FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.level = emp.level
);


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

SELECT name FROM accounts AS acct
WHERE status IN (
    SELECT status FROM shipments AS cust
    WHERE cust.level = acct.level
);


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

SELECT id FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.status = emp.status
);


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

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


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

SELECT id FROM regions AS empl
WHERE salary > (
    SELECT MAX(value) FROM invoices AS prod
    WHERE prod.code = empl.code
);


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

SELECT id FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.id = shp.id
);


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

SELECT salary FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = mgr.type
);


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

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


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

SELECT value FROM branches AS schd
WHERE status IN (
    SELECT status FROM suppliers AS lne
    WHERE lne.level = schd.level
);


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

SELECT name FROM transactions AS schd
WHERE status IN (
    SELECT status FROM projects AS txn
    WHERE txn.id = schd.id
);


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

SELECT id FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.type = lne.type
);


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

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


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

SELECT amount FROM invoices AS acct
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS catg
    WHERE catg.code = acct.code
);


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

SELECT code FROM orders AS lne
WHERE code IN (
    SELECT code FROM suppliers AS shp
    WHERE shp.level = lne.level
);


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

SELECT amount FROM customers AS prod
WHERE status IN (
    SELECT status FROM products AS shp
    WHERE shp.code = prod.code
);


Prompt:
Schema:
  branches (alias: inv)(value, id, salary, type)
  products(name, amount, type, salary)
Task: Retrieve value from branches with value above the MIN(value) of products rows sharing the same type.
SQL:

SELECT value FROM branches AS inv
WHERE value > (
    SELECT MIN(value) FROM products AS schd
    WHERE schd.type = inv.type
);


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

SELECT salary FROM warehouses AS txn
WHERE id IN (
    SELECT id FROM shipments AS emp
    WHERE emp.id = txn.id
);


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

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


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

SELECT value FROM categories AS acct
WHERE id IN (
    SELECT id FROM warehouses AS inv
    WHERE inv.level = acct.level
);


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

SELECT code FROM transactions AS emp
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.code = emp.code
);


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

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


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

SELECT code FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.code = lne.code
);


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

SELECT name FROM regions AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS budg
    WHERE budg.status = inv.status
);


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

SELECT code FROM warehouses AS sale
WHERE amount > (
    SELECT AVG(amount) FROM products AS inv
    WHERE inv.type = sale.type
);


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

SELECT value FROM regions AS mgr
WHERE code IN (
    SELECT code FROM invoices AS catg
    WHERE catg.id = mgr.id
);


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

SELECT amount FROM branches AS schd
WHERE level IN (
    SELECT level FROM departments AS budg
    WHERE budg.status = schd.status
);


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

SELECT salary FROM regions AS emp
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.code = emp.code
);


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

SELECT id FROM employees AS ordr
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.status = ordr.status
);


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

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


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

SELECT id FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.type = rgn.type
);


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

SELECT code FROM regions AS schd
WHERE level IN (
    SELECT level FROM categories AS shp
    WHERE shp.level = schd.level
);


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

SELECT code FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.status = empl.status
);


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

SELECT name FROM accounts AS lne
WHERE level IN (
    SELECT level FROM invoices AS prod
    WHERE prod.id = lne.id
);


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

SELECT salary FROM tasks AS shp
WHERE type IN (
    SELECT type FROM products AS lne
    WHERE lne.level = shp.level
);


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

SELECT amount FROM invoices AS ord
WHERE salary > (
    SELECT SUM(amount) FROM regions AS catg
    WHERE catg.id = ord.id
);


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

SELECT name FROM orders AS cust
WHERE value > (
    SELECT COUNT(value) FROM accounts AS prod
    WHERE prod.id = cust.id
);


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

SELECT id FROM shipments AS rgn
WHERE status IN (
    SELECT status FROM invoices AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT value FROM products AS lne
WHERE type IN (
    SELECT type FROM projects AS ordr
    WHERE ordr.level = lne.level
);


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

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


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

SELECT name FROM branches AS budg
WHERE code IN (
    SELECT code FROM transactions AS acct
    WHERE acct.id = budg.id
);


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

SELECT id FROM customers AS rgn
WHERE code IN (
    SELECT code FROM tasks AS shp
    WHERE shp.level = rgn.level
);


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

SELECT salary FROM tasks AS lne
WHERE code IN (
    SELECT code FROM orders AS shp
    WHERE shp.type = lne.type
);


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

SELECT amount FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.id = lne.id
);


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

SELECT name FROM departments AS dept
WHERE code IN (
    SELECT code FROM accounts AS sale
    WHERE sale.code = dept.code
);


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

SELECT salary FROM suppliers AS acct
WHERE level IN (
    SELECT level FROM products AS lne
    WHERE lne.type = acct.type
);


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

SELECT amount FROM products AS ordr
WHERE type IN (
    SELECT type FROM regions AS ord
    WHERE ord.code = ordr.code
);


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

SELECT name FROM categories AS budg
WHERE id IN (
    SELECT id FROM tasks AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT value FROM employees AS cust
WHERE code IN (
    SELECT code FROM transactions AS budg
    WHERE budg.type = cust.type
);


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

SELECT salary FROM products AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS srvc
    WHERE srvc.id = mgr.id
);


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

SELECT value FROM regions AS srvc
WHERE type IN (
    SELECT type FROM accounts AS rgn
    WHERE rgn.level = srvc.level
);


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

SELECT value FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.type = emp.type
);


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

SELECT salary FROM suppliers AS whs
WHERE id IN (
    SELECT id FROM projects AS txn
    WHERE txn.id = whs.id
);


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

SELECT salary FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.id = schd.id
);


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

SELECT amount FROM projects AS txn
WHERE type IN (
    SELECT type FROM branches AS ord
    WHERE ord.status = txn.status
);


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

SELECT code FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.type = catg.type
);


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

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


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

SELECT id FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.level = srvc.level
);


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

SELECT id FROM orders AS prod
WHERE level IN (
    SELECT level FROM suppliers AS empl
    WHERE empl.level = prod.level
);


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

SELECT amount FROM accounts AS catg
WHERE level IN (
    SELECT level FROM projects AS empl
    WHERE empl.type = catg.type
);


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

SELECT name FROM invoices AS empl
WHERE code IN (
    SELECT code FROM branches AS txn
    WHERE txn.level = empl.level
);


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

SELECT amount FROM shipments AS ord
WHERE level IN (
    SELECT level FROM branches AS shp
    WHERE shp.status = ord.status
);


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

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


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

SELECT id FROM departments AS whs
WHERE salary > (
    SELECT SUM(salary) FROM warehouses AS txn
    WHERE txn.level = whs.level
);


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

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


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

SELECT id FROM suppliers AS mgr
WHERE type IN (
    SELECT type FROM accounts AS sale
    WHERE sale.type = mgr.type
);


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

SELECT salary FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT value FROM transactions AS shp
WHERE status IN (
    SELECT status FROM tasks AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT salary FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.type = empl.type
);


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

SELECT salary FROM departments AS emp
WHERE status IN (
    SELECT status FROM warehouses AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT name FROM branches AS budg
WHERE id IN (
    SELECT id FROM departments AS acct
    WHERE acct.level = budg.level
);


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

SELECT value FROM products AS emp
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.status = emp.status
);


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

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


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

SELECT id FROM projects AS catg
WHERE type IN (
    SELECT type FROM departments AS budg
    WHERE budg.type = catg.type
);


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

SELECT salary FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.status = catg.status
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.id = shp.id
);


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

SELECT code FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.id = ord.id
);


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

SELECT value FROM employees AS empl
WHERE salary > (
    SELECT MAX(value) FROM departments AS schd
    WHERE schd.id = empl.id
);


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

SELECT id FROM suppliers AS emp
WHERE code IN (
    SELECT code FROM branches AS cust
    WHERE cust.code = emp.code
);


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

SELECT name FROM invoices AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM customers AS cust
    WHERE cust.status = rgn.status
);


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

SELECT salary FROM branches AS lne
WHERE amount > (
    SELECT SUM(salary) FROM categories AS dept
    WHERE dept.level = lne.level
);


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

SELECT id FROM products AS sale
WHERE value > (
    SELECT AVG(value) FROM shipments AS dept
    WHERE dept.id = sale.id
);


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

SELECT value FROM branches AS schd
WHERE id IN (
    SELECT id FROM orders AS prod
    WHERE prod.id = schd.id
);


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

SELECT value FROM departments AS dept
WHERE type IN (
    SELECT type FROM shipments AS inv
    WHERE inv.code = dept.code
);


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

SELECT salary FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.level = emp.level
);


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

SELECT name FROM departments AS lne
WHERE status IN (
    SELECT status FROM projects AS ord
    WHERE ord.type = lne.type
);


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

SELECT code FROM projects AS prod
WHERE code IN (
    SELECT code FROM regions AS acct
    WHERE acct.level = prod.level
);


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

SELECT amount FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.type = srvc.type
);


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

SELECT code FROM tasks AS prod
WHERE amount > (
    SELECT MAX(value) FROM categories AS srvc
    WHERE srvc.status = prod.status
);


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

SELECT salary FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.level = lne.level
);


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

SELECT name FROM warehouses AS empl
WHERE code IN (
    SELECT code FROM employees AS txn
    WHERE txn.type = empl.type
);


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

SELECT id FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.id = acct.id
);


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

SELECT code FROM transactions AS prod
WHERE amount > (
    SELECT MAX(amount) FROM projects AS dept
    WHERE dept.id = prod.id
);


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

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


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

SELECT code FROM branches AS inv
WHERE salary > (
    SELECT AVG(value) FROM employees AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT value FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.id = empl.id
);


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

SELECT salary FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.id = shp.id
);


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

SELECT name FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.status = shp.status
);


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

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


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

SELECT id FROM orders AS srvc
WHERE value > (
    SELECT MAX(value) FROM accounts AS acct
    WHERE acct.code = srvc.code
);


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

SELECT id FROM orders AS txn
WHERE level IN (
    SELECT level FROM suppliers AS inv
    WHERE inv.id = txn.id
);


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

SELECT amount FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.type = shp.type
);


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

SELECT salary FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT name FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM branches AS cust
    WHERE cust.code = budg.code
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT value FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.type = shp.type
);


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

SELECT salary FROM warehouses AS srvc
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS acct
    WHERE acct.type = srvc.type
);


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

SELECT name FROM tasks AS budg
WHERE salary > (
    SELECT SUM(value) FROM products AS mgr
    WHERE mgr.id = budg.id
);


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

SELECT id FROM shipments AS cust
WHERE status IN (
    SELECT status FROM projects AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT name FROM tasks AS emp
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.level = emp.level
);


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

SELECT salary FROM suppliers AS schd
WHERE value > (
    SELECT AVG(salary) FROM products AS inv
    WHERE inv.type = schd.type
);


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

SELECT salary FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = acct.code
);


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

SELECT code FROM warehouses AS ord
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.status = ord.status
);


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

SELECT id FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.status = txn.status
);


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

SELECT id FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.type = schd.type
);


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

SELECT amount FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.status = srvc.status
);


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

SELECT code FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.status = cust.status
);


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

SELECT id FROM accounts AS inv
WHERE code IN (
    SELECT code FROM shipments AS whs
    WHERE whs.type = inv.type
);


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

SELECT salary FROM departments AS schd
WHERE amount > (
    SELECT AVG(value) FROM tasks AS ord
    WHERE ord.id = schd.id
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.status = txn.status
);


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

SELECT amount FROM departments AS srvc
WHERE code IN (
    SELECT code FROM transactions AS txn
    WHERE txn.code = srvc.code
);


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

SELECT id FROM customers AS whs
WHERE amount > (
    SELECT MAX(value) FROM accounts AS inv
    WHERE inv.level = whs.level
);


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

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


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

SELECT salary FROM departments AS inv
WHERE value > (
    SELECT COUNT(amount) FROM branches AS catg
    WHERE catg.code = inv.code
);


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

SELECT salary FROM employees AS cust
WHERE id IN (
    SELECT id FROM categories AS txn
    WHERE txn.level = cust.level
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.id = rgn.id
);


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

SELECT value FROM suppliers AS ordr
WHERE value > (
    SELECT MIN(amount) FROM tasks AS budg
    WHERE budg.id = ordr.id
);


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

SELECT id FROM employees AS dept
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS cust
    WHERE cust.type = dept.type
);


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

SELECT amount FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.status = prod.status
);


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

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


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

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


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

SELECT amount FROM tasks AS inv
WHERE salary > (
    SELECT COUNT(value) FROM employees AS srvc
    WHERE srvc.level = inv.level
);


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

SELECT salary FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.id = srvc.id
);


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

SELECT salary FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.id = whs.id
);


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

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


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

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


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

SELECT value FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.code = prod.code
);


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

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


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

SELECT id FROM suppliers AS dept
WHERE id IN (
    SELECT id FROM warehouses AS inv
    WHERE inv.code = dept.code
);


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

SELECT amount FROM transactions AS prod
WHERE id IN (
    SELECT id FROM departments AS acct
    WHERE acct.id = prod.id
);


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

SELECT amount FROM projects AS lne
WHERE status IN (
    SELECT status FROM tasks AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT id FROM transactions AS whs
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT code FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.id = schd.id
);


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

SELECT amount FROM branches AS cust
WHERE value > (
    SELECT MAX(value) FROM suppliers AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT salary FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.level = txn.level
);


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

SELECT id FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM customers AS lne
    WHERE lne.type = ordr.type
);


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

SELECT value FROM regions AS budg
WHERE value > (
    SELECT MAX(salary) FROM branches AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT name FROM transactions AS emp
WHERE value > (
    SELECT AVG(salary) FROM employees AS lne
    WHERE lne.id = emp.id
);


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

SELECT value FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.code = acct.code
);


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

SELECT amount FROM invoices AS rgn
WHERE amount > (
    SELECT COUNT(amount) FROM accounts AS prod
    WHERE prod.type = rgn.type
);


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

SELECT id FROM invoices AS dept
WHERE amount > (
    SELECT SUM(value) FROM categories AS ord
    WHERE ord.id = dept.id
);


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

SELECT value FROM branches AS dept
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS shp
    WHERE shp.id = dept.id
);


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

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


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

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


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

SELECT code FROM orders AS budg
WHERE type IN (
    SELECT type FROM branches AS whs
    WHERE whs.code = budg.code
);


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

SELECT amount FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.level = cust.level
);


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

SELECT value FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.type = srvc.type
);


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

SELECT salary FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = lne.type
);


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

SELECT value FROM categories AS cust
WHERE status IN (
    SELECT status FROM regions AS catg
    WHERE catg.status = cust.status
);


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

SELECT amount FROM transactions AS ord
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.status = ord.status
);


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

SELECT code FROM products AS dept
WHERE amount > (
    SELECT AVG(salary) FROM projects AS lne
    WHERE lne.type = dept.type
);


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

SELECT name FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT value FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = srvc.level
);


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

SELECT id FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.type = ord.type
);


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

SELECT name FROM categories AS empl
WHERE level IN (
    SELECT level FROM departments AS ord
    WHERE ord.level = empl.level
);


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

SELECT name FROM regions AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS inv
    WHERE inv.status = shp.status
);


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

SELECT code FROM warehouses AS prod
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS dept
    WHERE dept.type = prod.type
);


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

SELECT name FROM invoices AS ord
WHERE status IN (
    SELECT status FROM tasks AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT name FROM suppliers AS budg
WHERE level IN (
    SELECT level FROM departments AS sale
    WHERE sale.type = budg.type
);


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

SELECT amount FROM products AS shp
WHERE status IN (
    SELECT status FROM invoices AS catg
    WHERE catg.level = shp.level
);


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

SELECT id FROM transactions AS mgr
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT amount FROM shipments AS srvc
WHERE level IN (
    SELECT level FROM products AS txn
    WHERE txn.id = srvc.id
);


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

SELECT amount FROM customers AS mgr
WHERE status IN (
    SELECT status FROM products AS lne
    WHERE lne.status = mgr.status
);


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

SELECT salary FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.level = schd.level
);


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

SELECT id FROM warehouses AS acct
WHERE salary > (
    SELECT MAX(salary) FROM regions AS shp
    WHERE shp.level = acct.level
);


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

SELECT amount FROM shipments AS schd
WHERE amount > (
    SELECT SUM(salary) FROM customers AS prod
    WHERE prod.status = schd.status
);


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

SELECT code FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.code = ordr.code
);


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

SELECT name FROM projects AS schd
WHERE level IN (
    SELECT level FROM suppliers AS dept
    WHERE dept.id = schd.id
);


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

SELECT value FROM products AS rgn
WHERE salary > (
    SELECT MAX(amount) FROM branches AS prod
    WHERE prod.status = rgn.status
);


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

SELECT salary FROM employees AS srvc
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.level = srvc.level
);


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

SELECT code FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.status = rgn.status
);


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

SELECT id FROM regions AS lne
WHERE amount > (
    SELECT SUM(value) FROM transactions AS ord
    WHERE ord.level = lne.level
);


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

SELECT name FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.level = dept.level
);


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

SELECT amount FROM products AS whs
WHERE status IN (
    SELECT status FROM employees AS inv
    WHERE inv.level = whs.level
);


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

SELECT id FROM orders AS budg
WHERE id IN (
    SELECT id FROM projects AS dept
    WHERE dept.id = budg.id
);


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

SELECT value FROM regions AS empl
WHERE amount > (
    SELECT AVG(amount) FROM orders AS lne
    WHERE lne.type = empl.type
);


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

SELECT name FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT id FROM projects AS inv
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS emp
    WHERE emp.id = inv.id
);


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

SELECT code FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.level = cust.level
);


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

SELECT code FROM regions AS inv
WHERE status IN (
    SELECT status FROM orders AS srvc
    WHERE srvc.level = inv.level
);


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

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


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

SELECT value FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.type = txn.type
);


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

SELECT salary FROM invoices AS srvc
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.id = srvc.id
);


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

SELECT value FROM suppliers AS whs
WHERE amount > (
    SELECT SUM(value) FROM customers AS ord
    WHERE ord.type = whs.type
);


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

SELECT salary FROM departments AS acct
WHERE amount > (
    SELECT AVG(value) FROM branches AS shp
    WHERE shp.id = acct.id
);


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

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


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

SELECT name FROM employees AS ordr
WHERE code IN (
    SELECT code FROM tasks AS empl
    WHERE empl.status = ordr.status
);


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

SELECT value FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.id = whs.id
);


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

SELECT name FROM customers AS ord
WHERE type IN (
    SELECT type FROM transactions AS lne
    WHERE lne.level = ord.level
);


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

SELECT value FROM tasks AS catg
WHERE value > (
    SELECT SUM(value) FROM products AS sale
    WHERE sale.code = catg.code
);


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

SELECT value FROM departments AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT name FROM shipments AS sale
WHERE id IN (
    SELECT id FROM orders AS schd
    WHERE schd.level = sale.level
);


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

SELECT salary FROM accounts AS schd
WHERE amount > (
    SELECT MAX(salary) FROM departments AS dept
    WHERE dept.code = schd.code
);


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

SELECT name FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.status = rgn.status
);


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

SELECT name FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT code FROM branches AS shp
WHERE amount > (
    SELECT SUM(salary) FROM customers AS empl
    WHERE empl.level = shp.level
);


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

SELECT value FROM transactions AS acct
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS lne
    WHERE lne.type = acct.type
);


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

SELECT code FROM suppliers AS schd
WHERE salary > (
    SELECT MIN(value) FROM invoices AS cust
    WHERE cust.code = schd.code
);


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

SELECT code FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT id FROM branches AS catg
WHERE value > (
    SELECT MAX(amount) FROM regions AS ord
    WHERE ord.id = catg.id
);


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

SELECT id FROM warehouses AS sale
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS rgn
    WHERE rgn.code = sale.code
);