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

SELECT amount FROM customers AS emp
WHERE id IN (
    SELECT id FROM departments AS whs
    WHERE whs.id = emp.id
);


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

SELECT id FROM categories AS lne
WHERE status IN (
    SELECT status FROM employees AS cust
    WHERE cust.type = lne.type
);


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

SELECT id FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.level = mgr.level
);


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

SELECT name FROM accounts AS dept
WHERE amount > (
    SELECT MIN(salary) FROM transactions AS catg
    WHERE catg.id = dept.id
);


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

SELECT id FROM customers AS inv
WHERE level IN (
    SELECT level FROM projects AS catg
    WHERE catg.level = inv.level
);


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

SELECT value FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.type = txn.type
);


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

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


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

SELECT value FROM warehouses AS inv
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.level = inv.level
);


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

SELECT value FROM tasks AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS dept
    WHERE dept.level = shp.level
);


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

SELECT name FROM projects AS inv
WHERE value > (
    SELECT SUM(salary) FROM transactions AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT value FROM invoices AS ordr
WHERE id IN (
    SELECT id FROM products AS catg
    WHERE catg.id = ordr.id
);


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

SELECT id FROM categories AS dept
WHERE salary > (
    SELECT COUNT(amount) FROM tasks AS txn
    WHERE txn.type = dept.type
);


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

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


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

SELECT amount FROM products AS rgn
WHERE level IN (
    SELECT level FROM branches AS dept
    WHERE dept.id = rgn.id
);


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

SELECT salary FROM categories AS budg
WHERE code IN (
    SELECT code FROM warehouses AS shp
    WHERE shp.id = budg.id
);


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

SELECT name FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT name FROM projects AS sale
WHERE id IN (
    SELECT id FROM invoices AS catg
    WHERE catg.status = sale.status
);


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

SELECT value FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = cust.type
);


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

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


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

SELECT name FROM shipments AS ordr
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT id FROM branches AS budg
WHERE status IN (
    SELECT status FROM categories AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.id = cust.id
);


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

SELECT salary FROM transactions AS budg
WHERE code IN (
    SELECT code FROM employees AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT id FROM tasks AS budg
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.id = budg.id
);


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

SELECT salary FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = mgr.id
);


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

SELECT value FROM accounts AS prod
WHERE status IN (
    SELECT status FROM departments AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT name FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.id = mgr.id
);


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

SELECT name FROM branches AS acct
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.id = acct.id
);


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

SELECT name FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.code = lne.code
);


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

SELECT salary FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = budg.type
);


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

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


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

SELECT amount FROM branches AS empl
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS schd
    WHERE schd.status = empl.status
);


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

SELECT code FROM projects AS lne
WHERE level IN (
    SELECT level FROM branches AS schd
    WHERE schd.level = lne.level
);


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

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


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

SELECT amount FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.id = schd.id
);


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

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


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

SELECT value FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.code = sale.code
);


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

SELECT code FROM employees AS rgn
WHERE level IN (
    SELECT level FROM transactions AS dept
    WHERE dept.id = rgn.id
);


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

SELECT value FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = whs.level
);


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

SELECT amount FROM invoices AS ordr
WHERE salary > (
    SELECT MIN(salary) FROM branches AS acct
    WHERE acct.status = ordr.status
);


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

SELECT salary FROM warehouses AS cust
WHERE level IN (
    SELECT level FROM categories AS inv
    WHERE inv.level = cust.level
);


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

SELECT name FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT amount FROM regions AS sale
WHERE status IN (
    SELECT status FROM suppliers AS budg
    WHERE budg.code = sale.code
);


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

SELECT name FROM transactions AS whs
WHERE status IN (
    SELECT status FROM accounts AS empl
    WHERE empl.type = whs.type
);


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

SELECT salary FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.type = lne.type
);


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

SELECT id FROM warehouses AS acct
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS lne
    WHERE lne.type = acct.type
);


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

SELECT name FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.code = schd.code
);


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

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


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

SELECT name FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.id = emp.id
);


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

SELECT name FROM orders AS shp
WHERE salary > (
    SELECT MAX(value) FROM tasks AS catg
    WHERE catg.code = shp.code
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.status = txn.status
);


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

SELECT amount FROM orders AS prod
WHERE id IN (
    SELECT id FROM regions AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT name FROM employees AS shp
WHERE type IN (
    SELECT type FROM transactions AS budg
    WHERE budg.id = shp.id
);


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

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


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

SELECT amount FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = srvc.type
);


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

SELECT value FROM invoices AS budg
WHERE value > (
    SELECT MIN(value) FROM customers AS dept
    WHERE dept.code = budg.code
);


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

SELECT name FROM orders AS cust
WHERE level IN (
    SELECT level FROM suppliers AS prod
    WHERE prod.type = cust.type
);


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

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


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

SELECT salary FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.type = lne.type
);


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

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


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

SELECT value FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.type = srvc.type
);


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

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


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

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


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

SELECT salary FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.id = txn.id
);


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

SELECT id FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.type = mgr.type
);


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

SELECT name FROM orders AS mgr
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT value FROM tasks AS sale
WHERE value > (
    SELECT MIN(salary) FROM projects AS cust
    WHERE cust.level = sale.level
);


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

SELECT value FROM projects AS empl
WHERE code IN (
    SELECT code FROM warehouses AS budg
    WHERE budg.level = empl.level
);


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

SELECT value FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = catg.type
);


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

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


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

SELECT value FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.id = cust.id
);


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

SELECT salary FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = schd.level
);


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

SELECT salary FROM transactions AS lne
WHERE code IN (
    SELECT code FROM orders AS budg
    WHERE budg.code = lne.code
);


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

SELECT amount FROM categories AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT name FROM projects AS txn
WHERE value > (
    SELECT COUNT(value) FROM products AS shp
    WHERE shp.level = txn.level
);


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

SELECT name FROM projects AS schd
WHERE level IN (
    SELECT level FROM accounts AS mgr
    WHERE mgr.status = schd.status
);


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

SELECT id FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.level = txn.level
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.level = ord.level
);


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

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


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

SELECT value FROM transactions AS whs
WHERE amount > (
    SELECT MIN(value) FROM tasks AS empl
    WHERE empl.status = whs.status
);


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

SELECT amount FROM invoices AS rgn
WHERE value > (
    SELECT AVG(amount) FROM employees AS shp
    WHERE shp.code = rgn.code
);


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

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


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

SELECT id FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.type = cust.type
);


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

SELECT amount FROM products AS emp
WHERE salary > (
    SELECT MIN(value) FROM warehouses AS mgr
    WHERE mgr.level = emp.level
);


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

SELECT code FROM regions AS ord
WHERE salary > (
    SELECT AVG(salary) FROM departments AS acct
    WHERE acct.id = ord.id
);


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

SELECT name FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.code = rgn.code
);


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

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


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

SELECT name FROM products AS lne
WHERE id IN (
    SELECT id FROM regions AS acct
    WHERE acct.type = lne.type
);


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

SELECT name FROM categories AS sale
WHERE salary > (
    SELECT MIN(amount) FROM customers AS emp
    WHERE emp.type = sale.type
);


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

SELECT salary FROM invoices AS prod
WHERE status IN (
    SELECT status FROM orders AS dept
    WHERE dept.id = prod.id
);


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

SELECT salary FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.type = prod.type
);


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

SELECT name FROM orders AS shp
WHERE level IN (
    SELECT level FROM invoices AS dept
    WHERE dept.id = shp.id
);


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

SELECT name FROM regions AS mgr
WHERE id IN (
    SELECT id FROM transactions AS cust
    WHERE cust.type = mgr.type
);


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

SELECT name FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.type = rgn.type
);


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

SELECT id FROM regions AS emp
WHERE code IN (
    SELECT code FROM products AS prod
    WHERE prod.id = emp.id
);


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

SELECT code FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT salary FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.status = shp.status
);


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

SELECT value FROM projects AS ordr
WHERE type IN (
    SELECT type FROM employees AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT salary FROM invoices AS inv
WHERE salary > (
    SELECT MIN(salary) FROM categories AS dept
    WHERE dept.status = inv.status
);


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

SELECT value FROM accounts AS emp
WHERE id IN (
    SELECT id FROM branches AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT amount FROM products AS shp
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS budg
    WHERE budg.type = shp.type
);


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

SELECT salary FROM employees AS srvc
WHERE type IN (
    SELECT type FROM tasks AS whs
    WHERE whs.id = srvc.id
);


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

SELECT salary FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.code = budg.code
);


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

SELECT amount FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.id = empl.id
);


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

SELECT id FROM products AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM branches AS prod
    WHERE prod.status = mgr.status
);


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

SELECT code FROM products AS catg
WHERE value > (
    SELECT SUM(value) FROM branches AS mgr
    WHERE mgr.type = catg.type
);


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

SELECT id FROM branches AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM customers AS txn
    WHERE txn.level = ordr.level
);


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

SELECT salary FROM suppliers AS empl
WHERE id IN (
    SELECT id FROM branches AS budg
    WHERE budg.type = empl.type
);


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

SELECT salary FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.status = prod.status
);


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

SELECT id FROM warehouses AS shp
WHERE id IN (
    SELECT id FROM products AS txn
    WHERE txn.id = shp.id
);


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

SELECT amount FROM customers AS dept
WHERE code IN (
    SELECT code FROM orders AS prod
    WHERE prod.status = dept.status
);


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

SELECT amount FROM accounts AS schd
WHERE level IN (
    SELECT level FROM projects AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT amount FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT name FROM orders AS prod
WHERE code IN (
    SELECT code FROM projects AS txn
    WHERE txn.level = prod.level
);


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

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


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

SELECT amount FROM employees AS dept
WHERE level IN (
    SELECT level FROM projects AS catg
    WHERE catg.code = dept.code
);


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

SELECT name FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.id = budg.id
);


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

SELECT id FROM departments AS schd
WHERE salary > (
    SELECT AVG(amount) FROM branches AS budg
    WHERE budg.status = schd.status
);


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

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


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

SELECT code FROM branches AS empl
WHERE amount > (
    SELECT AVG(value) FROM invoices AS lne
    WHERE lne.status = empl.status
);


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

SELECT id FROM suppliers AS shp
WHERE code IN (
    SELECT code FROM regions AS ord
    WHERE ord.level = shp.level
);


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

SELECT amount FROM customers AS cust
WHERE code IN (
    SELECT code FROM projects AS catg
    WHERE catg.type = cust.type
);


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

SELECT id FROM departments AS srvc
WHERE id IN (
    SELECT id FROM products AS whs
    WHERE whs.type = srvc.type
);


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

SELECT salary FROM orders AS cust
WHERE type IN (
    SELECT type FROM categories AS budg
    WHERE budg.code = cust.code
);


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

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


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

SELECT id FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT salary FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.code = acct.code
);


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

SELECT id FROM products AS emp
WHERE salary > (
    SELECT SUM(value) FROM regions AS lne
    WHERE lne.level = emp.level
);


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

SELECT salary FROM accounts AS emp
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT salary FROM transactions AS txn
WHERE value > (
    SELECT MIN(value) FROM employees AS acct
    WHERE acct.level = txn.level
);


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

SELECT id FROM categories AS acct
WHERE code IN (
    SELECT code FROM transactions AS emp
    WHERE emp.id = acct.id
);


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

SELECT amount FROM tasks AS sale
WHERE type IN (
    SELECT type FROM shipments AS inv
    WHERE inv.level = sale.level
);


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

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


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

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


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

SELECT id FROM products AS mgr
WHERE value > (
    SELECT MIN(salary) FROM tasks AS lne
    WHERE lne.level = mgr.level
);


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

SELECT salary FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.code = emp.code
);


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

SELECT amount FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.status = lne.status
);


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

SELECT salary FROM invoices AS budg
WHERE level IN (
    SELECT level FROM tasks AS prod
    WHERE prod.code = budg.code
);


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

SELECT code FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT value FROM categories AS txn
WHERE value > (
    SELECT SUM(amount) FROM branches AS acct
    WHERE acct.id = txn.id
);


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

SELECT id FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.level = srvc.level
);


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

SELECT name FROM regions AS dept
WHERE value > (
    SELECT MIN(salary) FROM projects AS catg
    WHERE catg.type = dept.type
);


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

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


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

SELECT salary FROM invoices AS mgr
WHERE type IN (
    SELECT type FROM categories AS budg
    WHERE budg.status = mgr.status
);


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

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


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

SELECT name FROM regions AS dept
WHERE level IN (
    SELECT level FROM tasks AS inv
    WHERE inv.id = dept.id
);


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

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


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

SELECT value FROM warehouses AS rgn
WHERE status IN (
    SELECT status FROM products AS sale
    WHERE sale.level = rgn.level
);


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

SELECT code FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT salary FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.type = dept.type
);


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

SELECT amount FROM branches AS sale
WHERE status IN (
    SELECT status FROM accounts AS ord
    WHERE ord.id = sale.id
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT code FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.level = rgn.level
);


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

SELECT salary FROM categories AS txn
WHERE id IN (
    SELECT id FROM tasks AS dept
    WHERE dept.level = txn.level
);


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

SELECT value FROM branches AS emp
WHERE amount > (
    SELECT MIN(value) FROM projects AS txn
    WHERE txn.status = emp.status
);


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

SELECT value FROM shipments AS ord
WHERE salary > (
    SELECT AVG(value) FROM customers AS lne
    WHERE lne.level = ord.level
);


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

SELECT value FROM regions AS empl
WHERE amount > (
    SELECT AVG(value) FROM accounts AS budg
    WHERE budg.status = empl.status
);


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

SELECT salary FROM employees AS prod
WHERE status IN (
    SELECT status FROM suppliers AS cust
    WHERE cust.id = prod.id
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.id = rgn.id
);


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

SELECT value FROM orders AS dept
WHERE level IN (
    SELECT level FROM categories AS schd
    WHERE schd.status = dept.status
);


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

SELECT code FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.level = catg.level
);


Prompt:
Schema:
  warehouses (alias: rgn)(id, salary, name, date)
  customers(value, id, date, name)
Task: Retrieve salary from warehouses with salary above the MAX(salary) of customers rows sharing the same level.
SQL:

SELECT salary FROM warehouses AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM customers AS txn
    WHERE txn.level = rgn.level
);


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

SELECT name FROM invoices AS cust
WHERE value > (
    SELECT SUM(amount) FROM customers AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT name FROM branches AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM customers AS lne
    WHERE lne.status = srvc.status
);


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

SELECT name FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.status = budg.status
);


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

SELECT id FROM departments AS rgn
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.code = rgn.code
);


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

SELECT value FROM projects AS txn
WHERE level IN (
    SELECT level FROM regions AS lne
    WHERE lne.level = txn.level
);


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

SELECT value FROM shipments AS inv
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS prod
    WHERE prod.type = inv.type
);


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

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


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

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


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

SELECT salary FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.status = catg.status
);


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

SELECT code FROM employees AS cust
WHERE amount > (
    SELECT MAX(value) FROM regions AS srvc
    WHERE srvc.status = cust.status
);


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

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


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

SELECT code FROM products AS schd
WHERE code IN (
    SELECT code FROM tasks AS prod
    WHERE prod.level = schd.level
);


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

SELECT code FROM categories AS prod
WHERE type IN (
    SELECT type FROM employees AS txn
    WHERE txn.id = prod.id
);


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

SELECT amount FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT name FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.code = ordr.code
);


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

SELECT amount FROM regions AS schd
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS emp
    WHERE emp.id = schd.id
);


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

SELECT salary FROM branches AS lne
WHERE salary > (
    SELECT SUM(value) FROM regions AS catg
    WHERE catg.id = lne.id
);


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

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


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

SELECT amount FROM branches AS rgn
WHERE amount > (
    SELECT SUM(value) FROM suppliers AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT amount FROM shipments AS schd
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS budg
    WHERE budg.id = schd.id
);


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

SELECT value FROM projects AS ord
WHERE id IN (
    SELECT id FROM transactions AS sale
    WHERE sale.code = ord.code
);


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

SELECT amount FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.level = schd.level
);


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

SELECT amount FROM invoices AS lne
WHERE status IN (
    SELECT status FROM departments AS whs
    WHERE whs.status = lne.status
);


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

SELECT salary FROM transactions AS srvc
WHERE type IN (
    SELECT type FROM projects AS cust
    WHERE cust.id = srvc.id
);


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

SELECT value FROM invoices AS mgr
WHERE code IN (
    SELECT code FROM departments AS emp
    WHERE emp.code = mgr.code
);


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

SELECT name FROM employees AS mgr
WHERE id IN (
    SELECT id FROM orders AS whs
    WHERE whs.id = mgr.id
);


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

SELECT amount FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = lne.code
);


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

SELECT salary FROM accounts AS catg
WHERE id IN (
    SELECT id FROM warehouses AS empl
    WHERE empl.id = catg.id
);


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

SELECT id FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.code = srvc.code
);


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

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


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

SELECT code FROM customers AS srvc
WHERE code IN (
    SELECT code FROM warehouses AS shp
    WHERE shp.code = srvc.code
);


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

SELECT amount FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.level = sale.level
);


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

SELECT amount FROM shipments AS acct
WHERE type IN (
    SELECT type FROM suppliers AS ord
    WHERE ord.id = acct.id
);


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

SELECT name FROM invoices AS shp
WHERE value > (
    SELECT MIN(amount) FROM products AS prod
    WHERE prod.level = shp.level
);


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

SELECT id FROM products AS whs
WHERE status IN (
    SELECT status FROM projects AS sale
    WHERE sale.code = whs.code
);


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

SELECT value FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.status = inv.status
);


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

SELECT amount FROM customers AS ord
WHERE salary > (
    SELECT AVG(amount) FROM employees AS shp
    WHERE shp.level = ord.level
);


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

SELECT amount FROM accounts AS ordr
WHERE code IN (
    SELECT code FROM employees AS sale
    WHERE sale.type = ordr.type
);


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

SELECT salary FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.type = lne.type
);


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

SELECT code FROM projects AS lne
WHERE id IN (
    SELECT id FROM accounts AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT code FROM projects AS ord
WHERE value > (
    SELECT COUNT(salary) FROM branches AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT value FROM tasks AS srvc
WHERE value > (
    SELECT AVG(value) FROM transactions AS txn
    WHERE txn.level = srvc.level
);


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

SELECT value FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.code = rgn.code
);


Prompt:
Schema:
  shipments (alias: prod)(level, type, id, salary)
  categories(date, name, salary, level)
Task: Retrieve salary from shipments with salary above the MIN(value) of categories rows sharing the same type.
SQL:

SELECT salary FROM shipments AS prod
WHERE salary > (
    SELECT MIN(value) FROM categories AS shp
    WHERE shp.type = prod.type
);


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

SELECT id FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.code = shp.code
);


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

SELECT amount FROM warehouses AS whs
WHERE salary > (
    SELECT MAX(value) FROM invoices AS ordr
    WHERE ordr.level = whs.level
);


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

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


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

SELECT id FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT name FROM regions AS mgr
WHERE type IN (
    SELECT type FROM categories AS ord
    WHERE ord.code = mgr.code
);


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

SELECT code FROM branches AS acct
WHERE code IN (
    SELECT code FROM departments AS empl
    WHERE empl.id = acct.id
);


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

SELECT salary FROM products AS ordr
WHERE amount > (
    SELECT MAX(amount) FROM orders AS inv
    WHERE inv.type = ordr.type
);


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

SELECT amount FROM suppliers AS acct
WHERE id IN (
    SELECT id FROM accounts AS sale
    WHERE sale.code = acct.code
);


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

SELECT amount FROM products AS dept
WHERE value > (
    SELECT AVG(amount) FROM regions AS lne
    WHERE lne.status = dept.status
);


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

SELECT name FROM projects AS srvc
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS cust
    WHERE cust.level = srvc.level
);


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

SELECT amount FROM tasks AS budg
WHERE level IN (
    SELECT level FROM shipments AS schd
    WHERE schd.level = budg.level
);


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

SELECT name FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.level = txn.level
);


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

SELECT amount FROM products AS srvc
WHERE type IN (
    SELECT type FROM warehouses AS schd
    WHERE schd.id = srvc.id
);


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

SELECT code FROM tasks AS ordr
WHERE code IN (
    SELECT code FROM invoices AS prod
    WHERE prod.id = ordr.id
);


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

SELECT id FROM warehouses AS mgr
WHERE value > (
    SELECT MAX(amount) FROM tasks AS inv
    WHERE inv.status = mgr.status
);


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

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


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

SELECT code FROM projects AS prod
WHERE value > (
    SELECT MIN(amount) FROM departments AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT amount FROM regions AS acct
WHERE code IN (
    SELECT code FROM shipments AS lne
    WHERE lne.type = acct.type
);


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

SELECT name FROM customers AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS txn
    WHERE txn.id = rgn.id
);


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

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


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

SELECT value FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.code = txn.code
);


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

SELECT id FROM regions AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS lne
    WHERE lne.level = ord.level
);


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

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


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

SELECT value FROM customers AS budg
WHERE value > (
    SELECT SUM(value) FROM departments AS txn
    WHERE txn.id = budg.id
);


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

SELECT amount FROM suppliers AS cust
WHERE amount > (
    SELECT SUM(value) FROM categories AS budg
    WHERE budg.code = cust.code
);


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

SELECT name FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.id = shp.id
);


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

SELECT amount FROM suppliers AS lne
WHERE type IN (
    SELECT type FROM warehouses AS cust
    WHERE cust.type = lne.type
);


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

SELECT value FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.type = empl.type
);


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

SELECT code FROM shipments AS prod
WHERE code IN (
    SELECT code FROM branches AS emp
    WHERE emp.level = prod.level
);


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

SELECT salary FROM branches AS ordr
WHERE amount > (
    SELECT AVG(value) FROM categories AS sale
    WHERE sale.id = ordr.id
);


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

SELECT amount FROM products AS prod
WHERE salary > (
    SELECT MIN(salary) FROM departments AS emp
    WHERE emp.type = prod.type
);


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

SELECT name FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.code = budg.code
);


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

SELECT value FROM warehouses AS catg
WHERE type IN (
    SELECT type FROM accounts AS prod
    WHERE prod.type = catg.type
);


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

SELECT value FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.status = shp.status
);


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

SELECT value FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT amount FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT salary FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.type = txn.type
);


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

SELECT name FROM warehouses AS ord
WHERE amount > (
    SELECT AVG(value) FROM shipments AS dept
    WHERE dept.level = ord.level
);


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

SELECT value FROM transactions AS shp
WHERE salary > (
    SELECT AVG(amount) FROM customers AS empl
    WHERE empl.level = shp.level
);


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

SELECT name FROM suppliers AS sale
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.status = sale.status
);


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

SELECT name FROM orders AS prod
WHERE level IN (
    SELECT level FROM projects AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT amount FROM invoices AS budg
WHERE level IN (
    SELECT level FROM suppliers AS dept
    WHERE dept.status = budg.status
);


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

SELECT amount FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.level = empl.level
);


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

SELECT amount FROM customers AS acct
WHERE type IN (
    SELECT type FROM transactions AS ordr
    WHERE ordr.level = acct.level
);


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

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


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

SELECT amount FROM suppliers AS ordr
WHERE value > (
    SELECT SUM(salary) FROM orders AS shp
    WHERE shp.code = ordr.code
);


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

SELECT salary FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT code FROM orders AS empl
WHERE value > (
    SELECT SUM(value) FROM branches AS emp
    WHERE emp.code = empl.code
);


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

SELECT name FROM shipments AS acct
WHERE salary > (
    SELECT MIN(salary) FROM customers AS shp
    WHERE shp.level = acct.level
);


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

SELECT name FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.type = prod.type
);


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

SELECT code FROM departments AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS lne
    WHERE lne.type = shp.type
);


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

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


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

SELECT name FROM orders AS inv
WHERE type IN (
    SELECT type FROM regions AS txn
    WHERE txn.status = inv.status
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.level = txn.level
);


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

SELECT salary FROM employees AS empl
WHERE code IN (
    SELECT code FROM tasks AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT amount FROM products AS catg
WHERE type IN (
    SELECT type FROM departments AS txn
    WHERE txn.status = catg.status
);


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

SELECT id FROM customers AS empl
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS ord
    WHERE ord.status = empl.status
);


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

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


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

SELECT salary FROM warehouses AS cust
WHERE salary > (
    SELECT MAX(value) FROM accounts AS inv
    WHERE inv.id = cust.id
);


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

SELECT name FROM orders AS shp
WHERE id IN (
    SELECT id FROM products AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT amount FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.status = sale.status
);


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

SELECT code FROM categories AS inv
WHERE id IN (
    SELECT id FROM suppliers AS emp
    WHERE emp.status = inv.status
);


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

SELECT salary FROM departments AS txn
WHERE salary > (
    SELECT MAX(salary) FROM categories AS srvc
    WHERE srvc.id = txn.id
);


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

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


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

SELECT salary FROM orders AS txn
WHERE amount > (
    SELECT AVG(value) FROM categories AS dept
    WHERE dept.level = txn.level
);


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

SELECT amount FROM departments AS lne
WHERE value > (
    SELECT SUM(salary) FROM employees AS dept
    WHERE dept.type = lne.type
);


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

SELECT salary FROM regions AS mgr
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT code FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.status = ord.status
);


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

SELECT id FROM tasks AS lne
WHERE type IN (
    SELECT type FROM branches AS sale
    WHERE sale.status = lne.status
);


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

SELECT id FROM warehouses AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM products AS sale
    WHERE sale.id = ordr.id
);


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

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


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

SELECT name FROM regions AS ord
WHERE salary > (
    SELECT MIN(amount) FROM branches AS shp
    WHERE shp.type = ord.type
);


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

SELECT salary FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT amount FROM orders AS catg
WHERE salary > (
    SELECT SUM(value) FROM regions AS whs
    WHERE whs.id = catg.id
);


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

SELECT id FROM regions AS inv
WHERE type IN (
    SELECT type FROM tasks AS acct
    WHERE acct.status = inv.status
);


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

SELECT id FROM branches AS schd
WHERE amount > (
    SELECT MAX(value) FROM invoices AS whs
    WHERE whs.code = schd.code
);


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

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


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

SELECT id FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.status = sale.status
);


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

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


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

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


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

SELECT amount FROM shipments AS dept
WHERE id IN (
    SELECT id FROM projects AS ord
    WHERE ord.code = dept.code
);


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

SELECT name FROM employees AS acct
WHERE value > (
    SELECT AVG(amount) FROM accounts AS txn
    WHERE txn.level = acct.level
);


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

SELECT value FROM projects AS mgr
WHERE value > (
    SELECT AVG(value) FROM tasks AS emp
    WHERE emp.id = mgr.id
);


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

SELECT value FROM orders AS prod
WHERE amount > (
    SELECT MAX(value) FROM employees AS shp
    WHERE shp.id = prod.id
);


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

SELECT code FROM projects AS cust
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT id FROM invoices AS ord
WHERE salary > (
    SELECT SUM(value) FROM transactions AS prod
    WHERE prod.level = ord.level
);


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

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


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

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