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

SELECT name FROM invoices AS shp
WHERE level IN (
    SELECT level FROM customers AS schd
    WHERE schd.status = shp.status
);


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

SELECT amount FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.level = dept.level
);


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

SELECT name FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.type = whs.type
);


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

SELECT code FROM employees AS cust
WHERE salary > (
    SELECT SUM(value) FROM customers AS inv
    WHERE inv.type = cust.type
);


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

SELECT code FROM products AS budg
WHERE salary > (
    SELECT COUNT(salary) FROM employees AS mgr
    WHERE mgr.id = budg.id
);


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

SELECT value FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.level = prod.level
);


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

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


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

SELECT code FROM projects AS cust
WHERE id IN (
    SELECT id FROM transactions AS acct
    WHERE acct.type = cust.type
);


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

SELECT id FROM products AS inv
WHERE level IN (
    SELECT level FROM invoices AS ord
    WHERE ord.level = inv.level
);


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

SELECT code FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.type = acct.type
);


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

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


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

SELECT value FROM categories AS dept
WHERE value > (
    SELECT COUNT(salary) FROM suppliers AS mgr
    WHERE mgr.type = dept.type
);


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

SELECT id FROM departments AS sale
WHERE status IN (
    SELECT status FROM customers AS dept
    WHERE dept.status = sale.status
);


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

SELECT amount FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.level = txn.level
);


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

SELECT salary FROM products AS emp
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS empl
    WHERE empl.code = emp.code
);


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

SELECT name FROM shipments AS catg
WHERE value > (
    SELECT AVG(salary) FROM employees AS shp
    WHERE shp.id = catg.id
);


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

SELECT salary FROM shipments AS srvc
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.id = srvc.id
);


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

SELECT name FROM orders AS srvc
WHERE value > (
    SELECT COUNT(value) FROM projects AS lne
    WHERE lne.code = srvc.code
);


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

SELECT value FROM departments AS dept
WHERE salary > (
    SELECT MAX(amount) FROM employees AS whs
    WHERE whs.code = dept.code
);


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

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


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

SELECT value FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.status = lne.status
);


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

SELECT id FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.code = emp.code
);


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

SELECT value FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = lne.id
);


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

SELECT salary FROM projects AS budg
WHERE status IN (
    SELECT status FROM accounts AS cust
    WHERE cust.level = budg.level
);


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

SELECT salary FROM regions AS inv
WHERE salary > (
    SELECT MIN(value) FROM branches AS mgr
    WHERE mgr.level = inv.level
);


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

SELECT code FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.status = budg.status
);


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

SELECT value FROM orders AS srvc
WHERE value > (
    SELECT MAX(amount) FROM customers AS ordr
    WHERE ordr.code = srvc.code
);


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

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


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

SELECT value FROM branches AS acct
WHERE type IN (
    SELECT type FROM warehouses AS prod
    WHERE prod.code = acct.code
);


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

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


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

SELECT salary FROM employees AS ordr
WHERE status IN (
    SELECT status FROM transactions AS ord
    WHERE ord.type = ordr.type
);


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

SELECT amount FROM suppliers AS budg
WHERE type IN (
    SELECT type FROM shipments AS txn
    WHERE txn.status = budg.status
);


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

SELECT amount FROM projects AS dept
WHERE status IN (
    SELECT status FROM regions AS inv
    WHERE inv.id = dept.id
);


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

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


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

SELECT amount FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.code = ord.code
);


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

SELECT salary FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.type = schd.type
);


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

SELECT value FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.type = sale.type
);


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

SELECT salary FROM branches AS empl
WHERE amount > (
    SELECT SUM(salary) FROM products AS dept
    WHERE dept.status = empl.status
);


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

SELECT salary FROM branches AS srvc
WHERE value > (
    SELECT AVG(salary) FROM products AS dept
    WHERE dept.id = srvc.id
);


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

SELECT code FROM invoices AS acct
WHERE value > (
    SELECT COUNT(salary) FROM categories AS whs
    WHERE whs.id = acct.id
);


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

SELECT code FROM products AS cust
WHERE amount > (
    SELECT AVG(salary) FROM customers AS acct
    WHERE acct.id = cust.id
);


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

SELECT amount FROM departments AS ordr
WHERE level IN (
    SELECT level FROM accounts AS txn
    WHERE txn.code = ordr.code
);


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

SELECT salary FROM shipments AS catg
WHERE code IN (
    SELECT code FROM regions AS acct
    WHERE acct.id = catg.id
);


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

SELECT code FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = inv.id
);


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

SELECT code FROM tasks AS ord
WHERE status IN (
    SELECT status FROM transactions AS sale
    WHERE sale.id = ord.id
);


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

SELECT code FROM customers AS txn
WHERE id IN (
    SELECT id FROM projects AS acct
    WHERE acct.level = txn.level
);


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

SELECT amount FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.id = catg.id
);


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

SELECT id FROM categories AS schd
WHERE value > (
    SELECT COUNT(amount) FROM employees AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT id FROM suppliers AS srvc
WHERE level IN (
    SELECT level FROM accounts AS dept
    WHERE dept.level = srvc.level
);


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

SELECT value FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT id FROM warehouses AS ord
WHERE type IN (
    SELECT type FROM branches AS txn
    WHERE txn.type = ord.type
);


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

SELECT name FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.level = emp.level
);


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

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


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

SELECT name FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.level = txn.level
);


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

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


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

SELECT value FROM suppliers AS dept
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS cust
    WHERE cust.level = dept.level
);


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

SELECT code FROM transactions AS srvc
WHERE amount > (
    SELECT MIN(value) FROM employees AS lne
    WHERE lne.level = srvc.level
);


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

SELECT id FROM employees AS ordr
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.type = ordr.type
);


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

SELECT name FROM projects AS acct
WHERE status IN (
    SELECT status FROM accounts AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT id FROM regions AS whs
WHERE code IN (
    SELECT code FROM suppliers AS acct
    WHERE acct.id = whs.id
);


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

SELECT name FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT code FROM invoices AS empl
WHERE status IN (
    SELECT status FROM shipments AS lne
    WHERE lne.code = empl.code
);


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

SELECT name FROM departments AS whs
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.code = whs.code
);


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

SELECT id FROM branches AS budg
WHERE code IN (
    SELECT code FROM shipments AS txn
    WHERE txn.type = budg.type
);


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

SELECT id FROM tasks AS dept
WHERE amount > (
    SELECT AVG(amount) FROM branches AS catg
    WHERE catg.id = dept.id
);


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

SELECT amount FROM orders AS lne
WHERE value > (
    SELECT MIN(amount) FROM products AS budg
    WHERE budg.level = lne.level
);


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

SELECT value FROM projects AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS emp
    WHERE emp.type = mgr.type
);


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

SELECT code FROM tasks AS schd
WHERE status IN (
    SELECT status FROM shipments AS catg
    WHERE catg.status = schd.status
);


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

SELECT name FROM suppliers AS whs
WHERE id IN (
    SELECT id FROM categories AS lne
    WHERE lne.type = whs.type
);


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

SELECT code FROM categories AS rgn
WHERE salary > (
    SELECT SUM(value) FROM transactions AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT value FROM orders AS budg
WHERE level IN (
    SELECT level FROM suppliers AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT amount FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.type = shp.type
);


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

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


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

SELECT code FROM suppliers AS srvc
WHERE code IN (
    SELECT code FROM products AS txn
    WHERE txn.level = srvc.level
);


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

SELECT code FROM warehouses AS mgr
WHERE value > (
    SELECT MAX(value) FROM accounts AS emp
    WHERE emp.id = mgr.id
);


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

SELECT salary FROM customers AS prod
WHERE type IN (
    SELECT type FROM shipments AS mgr
    WHERE mgr.code = prod.code
);


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

SELECT value FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = cust.level
);


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

SELECT salary FROM categories AS srvc
WHERE level IN (
    SELECT level FROM orders AS ordr
    WHERE ordr.type = srvc.type
);


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

SELECT amount FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.type = budg.type
);


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

SELECT salary FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.code = schd.code
);


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

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


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

SELECT value FROM suppliers AS inv
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS cust
    WHERE cust.code = inv.code
);


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

SELECT salary FROM departments AS ord
WHERE status IN (
    SELECT status FROM invoices AS acct
    WHERE acct.id = ord.id
);


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

SELECT code FROM orders AS sale
WHERE status IN (
    SELECT status FROM departments AS dept
    WHERE dept.status = sale.status
);


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

SELECT value FROM regions AS acct
WHERE level IN (
    SELECT level FROM orders AS rgn
    WHERE rgn.code = acct.code
);


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

SELECT name FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.id = cust.id
);


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

SELECT salary FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.id = ord.id
);


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

SELECT salary FROM accounts AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM regions AS catg
    WHERE catg.code = ordr.code
);


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

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


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

SELECT code FROM warehouses AS lne
WHERE value > (
    SELECT MIN(value) FROM customers AS shp
    WHERE shp.status = lne.status
);


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

SELECT salary FROM projects AS mgr
WHERE code IN (
    SELECT code FROM departments AS schd
    WHERE schd.id = mgr.id
);


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

SELECT salary FROM customers AS emp
WHERE status IN (
    SELECT status FROM invoices AS lne
    WHERE lne.level = emp.level
);


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

SELECT value FROM shipments AS emp
WHERE value > (
    SELECT AVG(salary) FROM orders AS cust
    WHERE cust.status = emp.status
);


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

SELECT value FROM accounts AS shp
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS emp
    WHERE emp.level = shp.level
);


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

SELECT value FROM regions AS mgr
WHERE salary > (
    SELECT MAX(value) FROM shipments AS schd
    WHERE schd.level = mgr.level
);


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

SELECT code FROM employees AS emp
WHERE type IN (
    SELECT type FROM projects AS shp
    WHERE shp.code = emp.code
);


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

SELECT amount FROM accounts AS cust
WHERE status IN (
    SELECT status FROM tasks AS ord
    WHERE ord.code = cust.code
);


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

SELECT name FROM departments AS srvc
WHERE id IN (
    SELECT id FROM regions AS txn
    WHERE txn.status = srvc.status
);


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

SELECT value FROM departments AS sale
WHERE value > (
    SELECT MIN(value) FROM tasks AS dept
    WHERE dept.status = sale.status
);


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

SELECT name FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = whs.level
);


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

SELECT name FROM projects AS inv
WHERE value > (
    SELECT MAX(amount) FROM shipments AS lne
    WHERE lne.code = inv.code
);


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

SELECT amount FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.code = sale.code
);


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

SELECT value FROM employees AS ord
WHERE level IN (
    SELECT level FROM departments AS shp
    WHERE shp.type = ord.type
);


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

SELECT salary FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.status = empl.status
);


Prompt:
Schema:
  transactions (alias: txn)(status, level, amount, code)
  departments(id, type, salary, status)
Task: Retrieve amount from transactions with amount above the AVG(salary) of departments rows sharing the same level.
SQL:

SELECT amount FROM transactions AS txn
WHERE amount > (
    SELECT AVG(salary) FROM departments AS prod
    WHERE prod.level = txn.level
);


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

SELECT amount FROM customers AS srvc
WHERE id IN (
    SELECT id FROM regions AS dept
    WHERE dept.level = srvc.level
);


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

SELECT code FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.level = srvc.level
);


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

SELECT amount FROM regions AS sale
WHERE code IN (
    SELECT code FROM invoices AS shp
    WHERE shp.level = sale.level
);


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

SELECT id FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.level = inv.level
);


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

SELECT code FROM invoices AS budg
WHERE type IN (
    SELECT type FROM transactions AS emp
    WHERE emp.level = budg.level
);


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

SELECT amount FROM customers AS txn
WHERE code IN (
    SELECT code FROM products AS ordr
    WHERE ordr.type = txn.type
);


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

SELECT value FROM tasks AS budg
WHERE level IN (
    SELECT level FROM suppliers AS acct
    WHERE acct.id = budg.id
);


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

SELECT salary FROM categories AS inv
WHERE level IN (
    SELECT level FROM orders AS shp
    WHERE shp.code = inv.code
);


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

SELECT name FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.level = ordr.level
);


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

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


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT name FROM employees AS inv
WHERE type IN (
    SELECT type FROM branches AS ord
    WHERE ord.type = inv.type
);


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

SELECT amount FROM employees AS budg
WHERE code IN (
    SELECT code FROM products AS empl
    WHERE empl.status = budg.status
);


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

SELECT code FROM products AS schd
WHERE level IN (
    SELECT level FROM customers AS whs
    WHERE whs.level = schd.level
);


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

SELECT value FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = txn.status
);


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

SELECT name FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.status = lne.status
);


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

SELECT id FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.code = ordr.code
);


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

SELECT value FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.status = acct.status
);


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

SELECT salary FROM tasks AS mgr
WHERE value > (
    SELECT AVG(value) FROM suppliers AS sale
    WHERE sale.level = mgr.level
);


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

SELECT value FROM projects AS sale
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS shp
    WHERE shp.id = sale.id
);


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

SELECT code FROM products AS inv
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS acct
    WHERE acct.code = inv.code
);


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

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


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

SELECT value FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT amount FROM employees AS dept
WHERE salary > (
    SELECT MAX(amount) FROM orders AS catg
    WHERE catg.code = dept.code
);


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

SELECT name FROM shipments AS rgn
WHERE status IN (
    SELECT status FROM tasks AS empl
    WHERE empl.code = rgn.code
);


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

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


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

SELECT id FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.code = ordr.code
);


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

SELECT name FROM projects AS lne
WHERE level IN (
    SELECT level FROM suppliers AS ordr
    WHERE ordr.level = lne.level
);


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

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


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

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


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

SELECT code FROM departments AS cust
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS ord
    WHERE ord.status = cust.status
);


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

SELECT amount FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.level = mgr.level
);


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

SELECT value FROM departments AS ord
WHERE salary > (
    SELECT MIN(salary) FROM categories AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.id = ord.id
);


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

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


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

SELECT amount FROM branches AS txn
WHERE value > (
    SELECT SUM(value) FROM warehouses AS shp
    WHERE shp.type = txn.type
);


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

SELECT value FROM regions AS schd
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS empl
    WHERE empl.status = schd.status
);


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

SELECT id FROM accounts AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.id = inv.id
);


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

SELECT name FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.status = ordr.status
);


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

SELECT name FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.status = ord.status
);


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

SELECT code FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.status = sale.status
);


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

SELECT code FROM branches AS empl
WHERE salary > (
    SELECT MIN(amount) FROM regions AS inv
    WHERE inv.level = empl.level
);


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

SELECT code FROM categories AS emp
WHERE amount > (
    SELECT AVG(value) FROM regions AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT amount FROM projects AS shp
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT code FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.code = sale.code
);


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

SELECT value FROM transactions AS dept
WHERE id IN (
    SELECT id FROM projects AS budg
    WHERE budg.type = dept.type
);


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

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


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

SELECT name FROM products AS rgn
WHERE type IN (
    SELECT type FROM invoices AS whs
    WHERE whs.status = rgn.status
);


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

SELECT name FROM departments AS ord
WHERE salary > (
    SELECT MIN(salary) FROM categories AS prod
    WHERE prod.id = ord.id
);


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

SELECT amount FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.code = lne.code
);


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

SELECT salary FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.type = inv.type
);


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

SELECT id FROM suppliers AS schd
WHERE level IN (
    SELECT level FROM tasks AS empl
    WHERE empl.status = schd.status
);


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

SELECT name FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = catg.status
);


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

SELECT name FROM orders AS srvc
WHERE salary > (
    SELECT COUNT(value) FROM departments AS dept
    WHERE dept.id = srvc.id
);


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

SELECT name FROM shipments AS emp
WHERE amount > (
    SELECT COUNT(value) FROM products AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT salary FROM orders AS catg
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.type = catg.type
);


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

SELECT value FROM projects AS inv
WHERE status IN (
    SELECT status FROM shipments AS acct
    WHERE acct.type = inv.type
);


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

SELECT code FROM customers AS txn
WHERE value > (
    SELECT MAX(salary) FROM branches AS emp
    WHERE emp.code = txn.code
);


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

SELECT code FROM projects AS shp
WHERE id IN (
    SELECT id FROM categories AS schd
    WHERE schd.status = shp.status
);


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

SELECT amount FROM projects AS prod
WHERE amount > (
    SELECT SUM(amount) FROM transactions AS schd
    WHERE schd.level = prod.level
);


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

SELECT amount FROM regions AS ord
WHERE code IN (
    SELECT code FROM customers AS emp
    WHERE emp.code = ord.code
);


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

SELECT salary FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT salary FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.status = ord.status
);


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

SELECT name FROM products AS schd
WHERE value > (
    SELECT SUM(value) FROM warehouses AS catg
    WHERE catg.type = schd.type
);


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

SELECT name FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.level = empl.level
);


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

SELECT id FROM branches AS lne
WHERE salary > (
    SELECT COUNT(value) FROM customers AS cust
    WHERE cust.code = lne.code
);


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

SELECT value FROM projects AS srvc
WHERE id IN (
    SELECT id FROM shipments AS catg
    WHERE catg.type = srvc.type
);


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

SELECT salary FROM customers AS shp
WHERE value > (
    SELECT MIN(value) FROM orders AS inv
    WHERE inv.type = shp.type
);


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.type = txn.type
);


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

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


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

SELECT id FROM invoices AS ordr
WHERE type IN (
    SELECT type FROM departments AS inv
    WHERE inv.status = ordr.status
);


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

SELECT code FROM invoices AS shp
WHERE type IN (
    SELECT type FROM transactions AS empl
    WHERE empl.code = shp.code
);


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

SELECT value FROM suppliers AS cust
WHERE id IN (
    SELECT id FROM orders AS empl
    WHERE empl.id = cust.id
);


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

SELECT salary FROM branches AS emp
WHERE id IN (
    SELECT id FROM customers AS txn
    WHERE txn.level = emp.level
);


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

SELECT amount FROM shipments AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS catg
    WHERE catg.code = ordr.code
);


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

SELECT name FROM shipments AS catg
WHERE salary > (
    SELECT SUM(salary) FROM branches AS schd
    WHERE schd.level = catg.level
);


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

SELECT amount FROM tasks AS sale
WHERE amount > (
    SELECT MIN(salary) FROM projects AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT salary FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.code = cust.code
);


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

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


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

SELECT name FROM customers AS inv
WHERE code IN (
    SELECT code FROM branches AS acct
    WHERE acct.level = inv.level
);


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

SELECT code FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.status = schd.status
);


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

SELECT name FROM branches AS ord
WHERE type IN (
    SELECT type FROM products AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT name FROM accounts AS ordr
WHERE level IN (
    SELECT level FROM tasks AS shp
    WHERE shp.id = ordr.id
);


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

SELECT amount FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.type = shp.type
);


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

SELECT salary FROM branches AS empl
WHERE code IN (
    SELECT code FROM shipments AS prod
    WHERE prod.id = empl.id
);


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

SELECT value FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.level = ordr.level
);


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

SELECT salary FROM shipments AS rgn
WHERE salary > (
    SELECT MAX(value) FROM categories AS empl
    WHERE empl.level = rgn.level
);


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

SELECT id FROM branches AS inv
WHERE level IN (
    SELECT level FROM categories AS budg
    WHERE budg.level = inv.level
);


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

SELECT name FROM branches AS lne
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS emp
    WHERE emp.id = lne.id
);


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

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


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

SELECT value FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.id = sale.id
);


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

SELECT id FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.status = catg.status
);


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

SELECT amount FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.type = cust.type
);


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

SELECT id FROM categories AS sale
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS inv
    WHERE inv.id = sale.id
);


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

SELECT amount FROM transactions AS ordr
WHERE id IN (
    SELECT id FROM shipments AS lne
    WHERE lne.code = ordr.code
);


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

SELECT name FROM customers AS shp
WHERE value > (
    SELECT MIN(salary) FROM warehouses AS empl
    WHERE empl.level = shp.level
);


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

SELECT value FROM shipments AS rgn
WHERE id IN (
    SELECT id FROM products AS empl
    WHERE empl.code = rgn.code
);


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

SELECT name FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT salary FROM products AS lne
WHERE salary > (
    SELECT SUM(value) FROM customers AS cust
    WHERE cust.code = lne.code
);


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

SELECT code FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = emp.type
);


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

SELECT amount FROM employees AS catg
WHERE salary > (
    SELECT AVG(amount) FROM products AS inv
    WHERE inv.type = catg.type
);


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

SELECT value FROM shipments AS catg
WHERE value > (
    SELECT MIN(amount) FROM accounts AS lne
    WHERE lne.status = catg.status
);


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

SELECT amount FROM branches AS sale
WHERE id IN (
    SELECT id FROM shipments AS rgn
    WHERE rgn.level = sale.level
);


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

SELECT amount FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.status = lne.status
);


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

SELECT name FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.status = empl.status
);


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

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


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

SELECT id FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.type = mgr.type
);


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

SELECT salary FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.level = mgr.level
);


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

SELECT code FROM employees AS prod
WHERE value > (
    SELECT MAX(amount) FROM customers AS rgn
    WHERE rgn.level = prod.level
);


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

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


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

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


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

SELECT salary FROM customers AS cust
WHERE level IN (
    SELECT level FROM categories AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT amount FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.status = catg.status
);


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

SELECT id FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.code = budg.code
);


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

SELECT salary FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.id = dept.id
);


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

SELECT salary FROM suppliers AS dept
WHERE id IN (
    SELECT id FROM categories AS budg
    WHERE budg.status = dept.status
);


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

SELECT id FROM projects AS whs
WHERE amount > (
    SELECT MAX(amount) FROM departments AS sale
    WHERE sale.type = whs.type
);


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

SELECT name FROM customers AS empl
WHERE level IN (
    SELECT level FROM departments AS emp
    WHERE emp.code = empl.code
);


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

SELECT salary FROM invoices AS mgr
WHERE status IN (
    SELECT status FROM projects AS emp
    WHERE emp.level = mgr.level
);


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

SELECT name FROM customers AS lne
WHERE code IN (
    SELECT code FROM warehouses AS inv
    WHERE inv.level = lne.level
);


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

SELECT value FROM projects AS catg
WHERE level IN (
    SELECT level FROM warehouses AS sale
    WHERE sale.code = catg.code
);


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

SELECT name FROM branches AS catg
WHERE status IN (
    SELECT status FROM accounts AS budg
    WHERE budg.id = catg.id
);


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

SELECT id FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.type = whs.type
);


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

SELECT id FROM invoices AS dept
WHERE value > (
    SELECT MIN(value) FROM shipments AS catg
    WHERE catg.code = dept.code
);


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

SELECT code FROM departments AS catg
WHERE amount > (
    SELECT MAX(value) FROM employees AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT name FROM tasks AS prod
WHERE salary > (
    SELECT MAX(value) FROM invoices AS inv
    WHERE inv.code = prod.code
);


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

SELECT code FROM accounts AS cust
WHERE code IN (
    SELECT code FROM products AS dept
    WHERE dept.level = cust.level
);


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

SELECT name FROM regions AS empl
WHERE type IN (
    SELECT type FROM suppliers AS ord
    WHERE ord.code = empl.code
);


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

SELECT name FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.level = inv.level
);


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

SELECT code FROM accounts AS budg
WHERE id IN (
    SELECT id FROM products AS dept
    WHERE dept.status = budg.status
);


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

SELECT id FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.level = whs.level
);


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

SELECT value FROM regions AS srvc
WHERE amount > (
    SELECT SUM(amount) FROM transactions AS emp
    WHERE emp.level = srvc.level
);


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

SELECT id FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.level = emp.level
);


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

SELECT value FROM tasks AS inv
WHERE value > (
    SELECT COUNT(amount) FROM customers AS emp
    WHERE emp.status = inv.status
);


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

SELECT salary FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.status = ord.status
);


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

SELECT name FROM customers AS txn
WHERE value > (
    SELECT COUNT(amount) FROM invoices AS sale
    WHERE sale.status = txn.status
);


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

SELECT code FROM branches AS catg
WHERE value > (
    SELECT AVG(amount) FROM regions AS budg
    WHERE budg.type = catg.type
);


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

SELECT amount FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT name FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.type = txn.type
);


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

SELECT id FROM transactions AS cust
WHERE type IN (
    SELECT type FROM products AS catg
    WHERE catg.type = cust.type
);


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

SELECT id FROM regions AS catg
WHERE salary > (
    SELECT MAX(value) FROM accounts AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT value FROM projects AS prod
WHERE id IN (
    SELECT id FROM employees AS cust
    WHERE cust.status = prod.status
);


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

SELECT value FROM projects AS acct
WHERE value > (
    SELECT MIN(salary) FROM warehouses AS cust
    WHERE cust.type = acct.type
);


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

SELECT code FROM projects AS srvc
WHERE salary > (
    SELECT MAX(value) FROM customers AS empl
    WHERE empl.id = srvc.id
);


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

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


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

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


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

SELECT amount FROM suppliers AS inv
WHERE salary > (
    SELECT MAX(value) FROM tasks AS catg
    WHERE catg.code = inv.code
);


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

SELECT name FROM accounts AS catg
WHERE id IN (
    SELECT id FROM orders AS prod
    WHERE prod.status = catg.status
);


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

SELECT salary FROM transactions AS ordr
WHERE type IN (
    SELECT type FROM shipments AS lne
    WHERE lne.code = ordr.code
);


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

SELECT amount FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.type = ordr.type
);


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

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


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

SELECT code FROM employees AS srvc
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS whs
    WHERE whs.type = srvc.type
);


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

SELECT name FROM regions AS shp
WHERE id IN (
    SELECT id FROM invoices AS prod
    WHERE prod.status = shp.status
);


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

SELECT id FROM departments AS prod
WHERE level IN (
    SELECT level FROM transactions AS ord
    WHERE ord.id = prod.id
);


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

SELECT code FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.level = srvc.level
);


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

SELECT code FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.id = prod.id
);


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

SELECT value FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.id = shp.id
);


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

SELECT code FROM branches AS budg
WHERE salary > (
    SELECT SUM(salary) FROM projects AS ord
    WHERE ord.status = budg.status
);


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

SELECT salary FROM employees AS ordr
WHERE id IN (
    SELECT id FROM categories AS budg
    WHERE budg.status = ordr.status
);


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

SELECT code FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.code = ord.code
);


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

SELECT value FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.status = inv.status
);


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

SELECT amount FROM warehouses AS whs
WHERE level IN (
    SELECT level FROM accounts AS shp
    WHERE shp.status = whs.status
);


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

SELECT salary FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.id = ord.id
);


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

SELECT value FROM products AS txn
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT id FROM customers AS srvc
WHERE value > (
    SELECT COUNT(amount) FROM orders AS budg
    WHERE budg.type = srvc.type
);


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

SELECT id FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.type = ord.type
);


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

SELECT value FROM branches AS cust
WHERE type IN (
    SELECT type FROM projects AS acct
    WHERE acct.status = cust.status
);


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

SELECT name FROM products AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM departments AS acct
    WHERE acct.level = rgn.level
);


Prompt:
Schema:
  suppliers (alias: empl)(type, id, code, amount)
  tasks(value, code, id, type)
Task: Retrieve amount from suppliers with value above the SUM(amount) of tasks rows sharing the same status.
SQL:

SELECT amount FROM suppliers AS empl
WHERE value > (
    SELECT SUM(amount) FROM tasks AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT salary FROM accounts AS srvc
WHERE salary > (
    SELECT AVG(value) FROM regions AS ord
    WHERE ord.code = srvc.code
);


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

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


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

SELECT name FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.code = cust.code
);


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

SELECT name FROM customers AS schd
WHERE salary > (
    SELECT AVG(value) FROM employees AS emp
    WHERE emp.status = schd.status
);


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

SELECT code FROM transactions AS whs
WHERE status IN (
    SELECT status FROM branches AS prod
    WHERE prod.type = whs.type
);


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

SELECT amount FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.level = txn.level
);


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

SELECT id FROM suppliers AS emp
WHERE value > (
    SELECT COUNT(salary) FROM accounts AS cust
    WHERE cust.code = emp.code
);


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

SELECT code FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.status = inv.status
);


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

SELECT salary FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.level = emp.level
);


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

SELECT code FROM regions AS cust
WHERE id IN (
    SELECT id FROM transactions AS acct
    WHERE acct.code = cust.code
);


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

SELECT id FROM transactions AS lne
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS catg
    WHERE catg.type = lne.type
);


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

SELECT id FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.id = mgr.id
);


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

SELECT id FROM accounts AS prod
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS empl
    WHERE empl.status = prod.status
);


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

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


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

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


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

SELECT amount FROM shipments AS lne
WHERE value > (
    SELECT MIN(salary) FROM transactions AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT amount FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.level = budg.level
);


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

SELECT amount FROM tasks AS whs
WHERE type IN (
    SELECT type FROM departments AS ord
    WHERE ord.level = whs.level
);


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

SELECT salary FROM transactions AS txn
WHERE id IN (
    SELECT id FROM warehouses AS inv
    WHERE inv.id = txn.id
);


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

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


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

SELECT id FROM tasks AS catg
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.id = catg.id
);