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

SELECT code FROM invoices AS mgr
WHERE code IN (
    SELECT code FROM accounts AS sale
    WHERE sale.type = mgr.type
);


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

SELECT value FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.type = txn.type
);


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

SELECT amount FROM invoices AS inv
WHERE status IN (
    SELECT status FROM warehouses AS budg
    WHERE budg.status = inv.status
);


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

SELECT salary FROM products AS acct
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS mgr
    WHERE mgr.level = acct.level
);


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

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


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

SELECT amount FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.level = catg.level
);


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

SELECT value FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = lne.type
);


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

SELECT amount FROM regions AS rgn
WHERE code IN (
    SELECT code FROM projects AS srvc
    WHERE srvc.level = rgn.level
);


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

SELECT code FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.status = txn.status
);


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

SELECT name FROM invoices AS whs
WHERE salary > (
    SELECT MAX(value) FROM orders AS shp
    WHERE shp.level = whs.level
);


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

SELECT amount FROM suppliers AS acct
WHERE status IN (
    SELECT status FROM departments AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT salary FROM shipments AS schd
WHERE id IN (
    SELECT id FROM employees AS txn
    WHERE txn.type = schd.type
);


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

SELECT id FROM customers AS whs
WHERE level IN (
    SELECT level FROM tasks AS acct
    WHERE acct.status = whs.status
);


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

SELECT code FROM suppliers AS emp
WHERE value > (
    SELECT SUM(value) FROM projects AS inv
    WHERE inv.type = emp.type
);


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

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


Prompt:
Schema:
  projects (alias: whs)(level, type, value, code)
  accounts(level, type, id, code)
Task: Retrieve id from projects with value above the MAX(amount) of accounts rows sharing the same code.
SQL:

SELECT id FROM projects AS whs
WHERE value > (
    SELECT MAX(amount) FROM accounts AS sale
    WHERE sale.code = whs.code
);


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

SELECT salary FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.code = prod.code
);


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

SELECT amount FROM warehouses AS budg
WHERE status IN (
    SELECT status FROM categories AS acct
    WHERE acct.level = budg.level
);


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

SELECT value FROM transactions AS catg
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.code = catg.code
);


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

SELECT code FROM categories AS cust
WHERE salary > (
    SELECT AVG(value) FROM invoices AS whs
    WHERE whs.status = cust.status
);


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

SELECT salary FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.status = budg.status
);


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

SELECT amount FROM categories AS empl
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.level = empl.level
);


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

SELECT name FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.code = rgn.code
);


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

SELECT value FROM tasks AS emp
WHERE amount > (
    SELECT SUM(value) FROM categories AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT name FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.code = shp.code
);


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

SELECT code FROM branches AS catg
WHERE code IN (
    SELECT code FROM accounts AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT code FROM tasks AS whs
WHERE id IN (
    SELECT id FROM orders AS acct
    WHERE acct.status = whs.status
);


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

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


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

SELECT id FROM customers AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS budg
    WHERE budg.type = shp.type
);


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

SELECT salary FROM shipments AS catg
WHERE salary > (
    SELECT MAX(salary) FROM departments AS schd
    WHERE schd.id = catg.id
);


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

SELECT id FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM suppliers AS sale
    WHERE sale.type = ordr.type
);


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

SELECT salary FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT amount FROM categories AS rgn
WHERE code IN (
    SELECT code FROM regions AS sale
    WHERE sale.id = rgn.id
);


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

SELECT salary FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.id = empl.id
);


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

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


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

SELECT salary FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.type = catg.type
);


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

SELECT amount FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.level = srvc.level
);


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

SELECT value FROM branches AS txn
WHERE code IN (
    SELECT code FROM products AS shp
    WHERE shp.status = txn.status
);


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

SELECT code FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.level = catg.level
);


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

SELECT id FROM categories AS mgr
WHERE type IN (
    SELECT type FROM products AS empl
    WHERE empl.type = mgr.type
);


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

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


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

SELECT name FROM categories AS srvc
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS txn
    WHERE txn.status = srvc.status
);


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

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


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

SELECT salary FROM projects AS ord
WHERE type IN (
    SELECT type FROM categories AS acct
    WHERE acct.level = ord.level
);


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

SELECT value FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.level = whs.level
);


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

SELECT name FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM suppliers AS emp
    WHERE emp.status = ordr.status
);


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

SELECT name FROM invoices AS sale
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS inv
    WHERE inv.code = sale.code
);


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

SELECT amount FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT id FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.status = ordr.status
);


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

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


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

SELECT name FROM accounts AS inv
WHERE status IN (
    SELECT status FROM products AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT amount FROM shipments AS mgr
WHERE type IN (
    SELECT type FROM customers AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT salary FROM projects AS rgn
WHERE id IN (
    SELECT id FROM customers AS sale
    WHERE sale.id = rgn.id
);


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

SELECT amount FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.code = ord.code
);


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

SELECT salary FROM orders AS shp
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT amount FROM shipments AS acct
WHERE id IN (
    SELECT id FROM employees AS sale
    WHERE sale.code = acct.code
);


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

SELECT id FROM customers AS shp
WHERE value > (
    SELECT COUNT(salary) FROM accounts AS sale
    WHERE sale.type = shp.type
);


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

SELECT salary FROM branches AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM warehouses AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT name FROM departments AS emp
WHERE code IN (
    SELECT code FROM customers AS dept
    WHERE dept.id = emp.id
);


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

SELECT id FROM suppliers AS schd
WHERE status IN (
    SELECT status FROM branches AS acct
    WHERE acct.level = schd.level
);


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

SELECT amount FROM projects AS inv
WHERE salary > (
    SELECT SUM(amount) FROM customers AS ord
    WHERE ord.id = inv.id
);


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

SELECT code FROM tasks AS srvc
WHERE value > (
    SELECT MIN(amount) FROM orders AS schd
    WHERE schd.id = srvc.id
);


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

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


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

SELECT code FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.id = ord.id
);


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

SELECT name FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT value FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.code = budg.code
);


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

SELECT name FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.id = lne.id
);


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

SELECT id FROM departments AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS inv
    WHERE inv.id = dept.id
);


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

SELECT code FROM products AS emp
WHERE status IN (
    SELECT status FROM accounts AS rgn
    WHERE rgn.level = emp.level
);


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

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


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

SELECT code FROM regions AS txn
WHERE amount > (
    SELECT AVG(value) FROM transactions AS empl
    WHERE empl.status = txn.status
);


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

SELECT code FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT salary FROM invoices AS shp
WHERE amount > (
    SELECT SUM(salary) FROM customers AS catg
    WHERE catg.status = shp.status
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.id = ord.id
);


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

SELECT value FROM shipments AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM products AS schd
    WHERE schd.type = ordr.type
);


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

SELECT name FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.code = rgn.code
);


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

SELECT code FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.code = shp.code
);


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

SELECT id FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.code = dept.code
);


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

SELECT id FROM accounts AS acct
WHERE salary > (
    SELECT AVG(value) FROM orders AS emp
    WHERE emp.type = acct.type
);


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

SELECT code FROM departments AS schd
WHERE salary > (
    SELECT AVG(salary) FROM customers AS emp
    WHERE emp.code = schd.code
);


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

SELECT amount FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.level = prod.level
);


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

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


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

SELECT value FROM regions AS mgr
WHERE status IN (
    SELECT status FROM transactions AS emp
    WHERE emp.type = mgr.type
);


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

SELECT id FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.code = inv.code
);


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

SELECT salary FROM branches AS rgn
WHERE amount > (
    SELECT MAX(amount) FROM categories AS prod
    WHERE prod.code = rgn.code
);


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

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


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

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


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

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


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

SELECT name FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.code = shp.code
);


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

SELECT amount FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = txn.level
);


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

SELECT value FROM transactions AS dept
WHERE amount > (
    SELECT SUM(amount) FROM invoices AS prod
    WHERE prod.code = dept.code
);


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

SELECT code FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = empl.level
);


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

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


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

SELECT salary FROM warehouses AS whs
WHERE amount > (
    SELECT MAX(salary) FROM suppliers AS ord
    WHERE ord.id = whs.id
);


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

SELECT id FROM categories AS emp
WHERE value > (
    SELECT MAX(value) FROM products AS inv
    WHERE inv.type = emp.type
);


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

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


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

SELECT value FROM tasks AS acct
WHERE value > (
    SELECT AVG(amount) FROM regions AS emp
    WHERE emp.level = acct.level
);


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

SELECT code FROM categories AS ord
WHERE salary > (
    SELECT AVG(value) FROM branches AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT value FROM branches AS lne
WHERE status IN (
    SELECT status FROM warehouses AS shp
    WHERE shp.code = lne.code
);


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

SELECT name FROM departments AS ordr
WHERE code IN (
    SELECT code FROM regions AS sale
    WHERE sale.level = ordr.level
);


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

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


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

SELECT name FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.id = rgn.id
);


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

SELECT name FROM orders AS dept
WHERE value > (
    SELECT SUM(value) FROM suppliers AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT name FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.code = lne.code
);


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

SELECT amount FROM shipments AS budg
WHERE status IN (
    SELECT status FROM tasks AS acct
    WHERE acct.code = budg.code
);


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

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


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

SELECT code FROM branches AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT name FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.level = rgn.level
);


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

SELECT id FROM transactions AS mgr
WHERE value > (
    SELECT COUNT(amount) FROM products AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT salary FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.id = mgr.id
);


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

SELECT name FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.code = shp.code
);


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

SELECT value FROM suppliers AS whs
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.level = whs.level
);


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

SELECT value FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.level = ordr.level
);


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

SELECT id FROM employees AS empl
WHERE type IN (
    SELECT type FROM invoices AS emp
    WHERE emp.code = empl.code
);


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

SELECT id FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.type = catg.type
);


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

SELECT value FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT name FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.type = mgr.type
);


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

SELECT name FROM products AS dept
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.id = dept.id
);


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

SELECT name FROM regions AS dept
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS cust
    WHERE cust.level = dept.level
);


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

SELECT code FROM invoices AS whs
WHERE level IN (
    SELECT level FROM products AS shp
    WHERE shp.code = whs.code
);


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

SELECT value FROM transactions AS schd
WHERE code IN (
    SELECT code FROM branches AS ord
    WHERE ord.type = schd.type
);


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

SELECT name FROM transactions AS budg
WHERE id IN (
    SELECT id FROM invoices AS inv
    WHERE inv.code = budg.code
);


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

SELECT id FROM suppliers AS cust
WHERE amount > (
    SELECT MAX(value) FROM projects AS ord
    WHERE ord.status = cust.status
);


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

SELECT code FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.type = dept.type
);


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

SELECT salary FROM suppliers AS dept
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS ord
    WHERE ord.level = dept.level
);


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

SELECT code FROM suppliers AS dept
WHERE type IN (
    SELECT type FROM employees AS cust
    WHERE cust.status = dept.status
);


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

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


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

SELECT amount FROM invoices AS dept
WHERE type IN (
    SELECT type FROM warehouses AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT name FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.code = empl.code
);


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

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


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

SELECT code FROM shipments AS cust
WHERE value > (
    SELECT AVG(amount) FROM departments AS catg
    WHERE catg.id = cust.id
);


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

SELECT amount FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.type = inv.type
);


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

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


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

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


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

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


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

SELECT code FROM accounts AS empl
WHERE level IN (
    SELECT level FROM invoices AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT salary FROM branches AS sale
WHERE status IN (
    SELECT status FROM regions AS rgn
    WHERE rgn.type = sale.type
);


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

SELECT id FROM customers AS shp
WHERE code IN (
    SELECT code FROM employees AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.type = ord.type
);


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

SELECT id FROM branches AS inv
WHERE value > (
    SELECT MIN(value) FROM customers AS sale
    WHERE sale.code = inv.code
);


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

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


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

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


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

SELECT salary FROM regions AS srvc
WHERE code IN (
    SELECT code FROM accounts AS dept
    WHERE dept.type = srvc.type
);


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

SELECT amount FROM accounts AS inv
WHERE code IN (
    SELECT code FROM orders AS schd
    WHERE schd.id = inv.id
);


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

SELECT id FROM branches AS sale
WHERE type IN (
    SELECT type FROM projects AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT id FROM tasks AS catg
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS dept
    WHERE dept.code = catg.code
);


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

SELECT amount FROM departments AS cust
WHERE value > (
    SELECT COUNT(amount) FROM products AS dept
    WHERE dept.code = cust.code
);


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

SELECT id FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.status = catg.status
);


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

SELECT code FROM transactions AS sale
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS emp
    WHERE emp.code = sale.code
);


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

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


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

SELECT id FROM accounts AS ord
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT value FROM categories AS txn
WHERE status IN (
    SELECT status FROM tasks AS emp
    WHERE emp.type = txn.type
);


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

SELECT id FROM projects AS ord
WHERE salary > (
    SELECT AVG(amount) FROM customers AS whs
    WHERE whs.level = ord.level
);


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

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


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

SELECT name FROM employees AS lne
WHERE type IN (
    SELECT type FROM branches AS cust
    WHERE cust.level = lne.level
);


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

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


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

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


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

SELECT id FROM projects AS dept
WHERE type IN (
    SELECT type FROM warehouses AS srvc
    WHERE srvc.code = dept.code
);


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

SELECT name FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.id = catg.id
);


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.status = ord.status
);


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

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


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

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


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

SELECT value FROM invoices AS shp
WHERE salary > (
    SELECT SUM(salary) FROM departments AS inv
    WHERE inv.type = shp.type
);


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

SELECT amount FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT name FROM departments AS catg
WHERE type IN (
    SELECT type FROM transactions AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT id FROM transactions AS inv
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.id = inv.id
);


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

SELECT amount FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.level = srvc.level
);


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

SELECT amount FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.code = prod.code
);


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

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


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

SELECT id FROM warehouses AS schd
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.id = schd.id
);


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

SELECT code FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT code FROM projects AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM branches AS lne
    WHERE lne.type = mgr.type
);


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

SELECT code FROM branches AS whs
WHERE status IN (
    SELECT status FROM shipments AS txn
    WHERE txn.code = whs.code
);


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

SELECT id FROM orders AS mgr
WHERE salary > (
    SELECT MAX(value) FROM invoices AS cust
    WHERE cust.level = mgr.level
);


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

SELECT name FROM shipments AS schd
WHERE code IN (
    SELECT code FROM projects AS budg
    WHERE budg.level = schd.level
);


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

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


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

SELECT name FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.status = txn.status
);


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

SELECT code FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT amount FROM tasks AS ord
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS schd
    WHERE schd.id = ord.id
);


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

SELECT code FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.id = rgn.id
);


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

SELECT amount FROM branches AS lne
WHERE code IN (
    SELECT code FROM transactions AS txn
    WHERE txn.code = lne.code
);


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

SELECT name FROM customers AS ordr
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS empl
    WHERE empl.status = ordr.status
);


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

SELECT value FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM categories AS whs
    WHERE whs.level = rgn.level
);


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

SELECT amount FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.type = lne.type
);


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

SELECT code FROM invoices AS empl
WHERE salary > (
    SELECT MIN(value) FROM employees AS whs
    WHERE whs.type = empl.type
);


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

SELECT id FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.code = shp.code
);


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

SELECT name FROM accounts AS dept
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS whs
    WHERE whs.code = dept.code
);


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

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


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

SELECT amount FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = schd.type
);


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

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


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

SELECT name FROM branches AS acct
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT code FROM shipments AS catg
WHERE value > (
    SELECT MIN(amount) FROM products AS emp
    WHERE emp.type = catg.type
);


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

SELECT salary FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.type = rgn.type
);


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

SELECT name FROM invoices AS mgr
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS ord
    WHERE ord.code = mgr.code
);


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

SELECT name FROM transactions AS lne
WHERE level IN (
    SELECT level FROM employees AS cust
    WHERE cust.code = lne.code
);


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

SELECT amount FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.status = txn.status
);


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

SELECT salary FROM shipments AS catg
WHERE value > (
    SELECT SUM(amount) FROM invoices AS emp
    WHERE emp.code = catg.code
);


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

SELECT salary FROM categories AS txn
WHERE type IN (
    SELECT type FROM products AS inv
    WHERE inv.code = txn.code
);


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

SELECT code FROM employees AS whs
WHERE id IN (
    SELECT id FROM categories AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT value FROM tasks AS schd
WHERE type IN (
    SELECT type FROM customers AS acct
    WHERE acct.code = schd.code
);


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

SELECT id FROM categories AS emp
WHERE code IN (
    SELECT code FROM branches AS catg
    WHERE catg.status = emp.status
);


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

SELECT amount FROM orders AS prod
WHERE amount > (
    SELECT SUM(salary) FROM branches AS emp
    WHERE emp.code = prod.code
);


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

SELECT amount FROM departments AS prod
WHERE status IN (
    SELECT status FROM projects AS ord
    WHERE ord.code = prod.code
);


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

SELECT name FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.status = whs.status
);


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

SELECT salary FROM branches AS shp
WHERE level IN (
    SELECT level FROM suppliers AS prod
    WHERE prod.code = shp.code
);


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

SELECT code FROM categories AS acct
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS emp
    WHERE emp.status = acct.status
);


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

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


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

SELECT name FROM orders AS emp
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS lne
    WHERE lne.status = emp.status
);


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.code = dept.code
);


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

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


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

SELECT amount FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.status = mgr.status
);


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

SELECT value FROM suppliers AS cust
WHERE salary > (
    SELECT AVG(salary) FROM products AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT code FROM regions AS cust
WHERE amount > (
    SELECT SUM(value) FROM invoices AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT code FROM transactions AS sale
WHERE amount > (
    SELECT SUM(amount) FROM suppliers AS emp
    WHERE emp.level = sale.level
);


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

SELECT amount FROM shipments AS budg
WHERE id IN (
    SELECT id FROM tasks AS emp
    WHERE emp.type = budg.type
);


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

SELECT amount FROM customers AS cust
WHERE salary > (
    SELECT MAX(value) FROM invoices AS ord
    WHERE ord.level = cust.level
);


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

SELECT code FROM customers AS inv
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.id = inv.id
);


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

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


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

SELECT id FROM customers AS acct
WHERE status IN (
    SELECT status FROM suppliers AS lne
    WHERE lne.type = acct.type
);


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

SELECT code FROM departments AS whs
WHERE salary > (
    SELECT SUM(value) FROM tasks AS txn
    WHERE txn.level = whs.level
);


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

SELECT value FROM employees AS srvc
WHERE status IN (
    SELECT status FROM customers AS dept
    WHERE dept.type = srvc.type
);


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

SELECT amount FROM invoices AS ord
WHERE id IN (
    SELECT id FROM categories AS txn
    WHERE txn.status = ord.status
);


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

SELECT id FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = txn.id
);


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

SELECT amount FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.type = emp.type
);


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

SELECT salary FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.id = inv.id
);


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

SELECT id FROM accounts AS acct
WHERE amount > (
    SELECT MIN(amount) FROM customers AS emp
    WHERE emp.id = acct.id
);


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

SELECT salary FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.status = schd.status
);


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

SELECT amount FROM invoices AS lne
WHERE level IN (
    SELECT level FROM shipments AS emp
    WHERE emp.status = lne.status
);


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

SELECT amount FROM branches AS sale
WHERE status IN (
    SELECT status FROM customers AS prod
    WHERE prod.type = sale.type
);


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

SELECT id FROM warehouses AS cust
WHERE value > (
    SELECT SUM(amount) FROM customers AS sale
    WHERE sale.id = cust.id
);


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

SELECT code FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT name FROM suppliers AS sale
WHERE type IN (
    SELECT type FROM projects AS lne
    WHERE lne.status = sale.status
);


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

SELECT amount FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.id = prod.id
);


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

SELECT salary FROM projects AS catg
WHERE salary > (
    SELECT COUNT(value) FROM products AS empl
    WHERE empl.level = catg.level
);


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

SELECT name FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.level = budg.level
);


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

SELECT id FROM projects AS ordr
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.id = ordr.id
);


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

SELECT name FROM shipments AS dept
WHERE type IN (
    SELECT type FROM suppliers AS acct
    WHERE acct.code = dept.code
);


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

SELECT value FROM employees AS inv
WHERE amount > (
    SELECT MIN(amount) FROM projects AS acct
    WHERE acct.type = inv.type
);


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

SELECT value FROM departments AS lne
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.status = lne.status
);


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

SELECT id FROM transactions AS ord
WHERE type IN (
    SELECT type FROM customers AS acct
    WHERE acct.code = ord.code
);


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

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


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

SELECT salary FROM departments AS mgr
WHERE code IN (
    SELECT code FROM shipments AS cust
    WHERE cust.type = mgr.type
);


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

SELECT amount FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.type = schd.type
);


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

SELECT amount FROM projects AS catg
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT name FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.type = inv.type
);


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

SELECT id FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.type = catg.type
);


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

SELECT salary FROM customers AS acct
WHERE id IN (
    SELECT id FROM suppliers AS cust
    WHERE cust.code = acct.code
);


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

SELECT code FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.status = mgr.status
);


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

SELECT id FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.level = txn.level
);


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

SELECT code FROM tasks AS dept
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT code FROM branches AS inv
WHERE value > (
    SELECT MIN(amount) FROM departments AS emp
    WHERE emp.type = inv.type
);


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

SELECT id FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.code = rgn.code
);


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

SELECT name FROM invoices AS acct
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.status = acct.status
);


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

SELECT salary FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.level = sale.level
);


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

SELECT id FROM branches AS emp
WHERE level IN (
    SELECT level FROM projects AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT code FROM invoices AS mgr
WHERE amount > (
    SELECT AVG(salary) FROM categories AS sale
    WHERE sale.status = mgr.status
);


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

SELECT id FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.code = ord.code
);


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

SELECT salary FROM suppliers AS ord
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.level = ord.level
);


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

SELECT salary FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.status = emp.status
);


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

SELECT id FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.status = dept.status
);


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

SELECT amount FROM branches AS prod
WHERE salary > (
    SELECT MAX(salary) FROM employees AS empl
    WHERE empl.level = prod.level
);


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

SELECT id FROM invoices AS mgr
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS budg
    WHERE budg.code = mgr.code
);


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

SELECT code FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = prod.type
);


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

SELECT code FROM tasks AS empl
WHERE value > (
    SELECT MIN(amount) FROM warehouses AS whs
    WHERE whs.id = empl.id
);


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

SELECT id FROM shipments AS rgn
WHERE salary > (
    SELECT SUM(value) FROM orders AS empl
    WHERE empl.level = rgn.level
);


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

SELECT name FROM employees AS dept
WHERE type IN (
    SELECT type FROM warehouses AS cust
    WHERE cust.code = dept.code
);


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

SELECT name FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.type = catg.type
);


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

SELECT name FROM tasks AS mgr
WHERE code IN (
    SELECT code FROM projects AS cust
    WHERE cust.type = mgr.type
);


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

SELECT name FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT amount FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.level = shp.level
);


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

SELECT code FROM customers AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT amount FROM orders AS acct
WHERE salary > (
    SELECT COUNT(amount) FROM tasks AS mgr
    WHERE mgr.code = acct.code
);


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

SELECT code FROM shipments AS catg
WHERE type IN (
    SELECT type FROM customers AS emp
    WHERE emp.status = catg.status
);


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

SELECT name FROM employees AS ordr
WHERE salary > (
    SELECT SUM(value) FROM invoices AS whs
    WHERE whs.type = ordr.type
);


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

SELECT code FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT name FROM branches AS sale
WHERE value > (
    SELECT SUM(salary) FROM products AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT salary FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.code = ord.code
);


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

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


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

SELECT code FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.status = emp.status
);


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

SELECT amount FROM accounts AS prod
WHERE value > (
    SELECT MAX(salary) FROM invoices AS shp
    WHERE shp.type = prod.type
);


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

SELECT salary FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.type = rgn.type
);


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

SELECT salary FROM branches AS shp
WHERE salary > (
    SELECT MIN(salary) FROM products AS acct
    WHERE acct.status = shp.status
);


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

SELECT value FROM transactions AS lne
WHERE value > (
    SELECT MAX(salary) FROM products AS rgn
    WHERE rgn.level = lne.level
);


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

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


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

SELECT value FROM departments AS rgn
WHERE level IN (
    SELECT level FROM categories AS empl
    WHERE empl.code = rgn.code
);


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

SELECT id FROM customers AS dept
WHERE level IN (
    SELECT level FROM products AS lne
    WHERE lne.type = dept.type
);


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

SELECT id FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = ord.type
);


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

SELECT code FROM suppliers AS whs
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.type = whs.type
);


Prompt:
Schema:
  categories (alias: empl)(code, name, salary, value)
  projects(salary, level, name, value)
Task: Retrieve name from categories with value above the COUNT(value) of projects rows sharing the same type.
SQL:

SELECT name FROM categories AS empl
WHERE value > (
    SELECT COUNT(value) FROM projects AS acct
    WHERE acct.type = empl.type
);


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

SELECT salary FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.type = shp.type
);


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

SELECT id FROM products AS mgr
WHERE level IN (
    SELECT level FROM transactions AS whs
    WHERE whs.type = mgr.type
);


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

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


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

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