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

SELECT amount FROM branches AS whs
WHERE type IN (
    SELECT type FROM customers AS dept
    WHERE dept.status = whs.status
);


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

SELECT value FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.id = srvc.id
);


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

SELECT code FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = inv.level
);


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

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


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

SELECT name FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT amount FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.status = lne.status
);


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

SELECT code FROM tasks AS txn
WHERE level IN (
    SELECT level FROM customers AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT amount FROM warehouses AS whs
WHERE salary > (
    SELECT MIN(salary) FROM regions AS txn
    WHERE txn.level = whs.level
);


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

SELECT salary FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.level = ordr.level
);


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

SELECT amount FROM employees AS inv
WHERE code IN (
    SELECT code FROM categories AS empl
    WHERE empl.status = inv.status
);


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

SELECT value FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.id = lne.id
);


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

SELECT amount FROM invoices AS prod
WHERE code IN (
    SELECT code FROM orders AS sale
    WHERE sale.code = prod.code
);


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

SELECT value FROM departments AS acct
WHERE code IN (
    SELECT code FROM orders AS cust
    WHERE cust.id = acct.id
);


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

SELECT value FROM suppliers AS txn
WHERE value > (
    SELECT AVG(amount) FROM shipments AS acct
    WHERE acct.id = txn.id
);


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

SELECT salary FROM warehouses AS schd
WHERE salary > (
    SELECT MIN(value) FROM accounts AS dept
    WHERE dept.id = schd.id
);


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

SELECT amount FROM orders AS whs
WHERE code IN (
    SELECT code FROM shipments AS txn
    WHERE txn.type = whs.type
);


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

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


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

SELECT id FROM customers AS prod
WHERE salary > (
    SELECT MAX(salary) FROM employees AS empl
    WHERE empl.type = prod.type
);


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

SELECT code FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.status = mgr.status
);


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

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


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

SELECT name FROM accounts AS mgr
WHERE value > (
    SELECT MAX(salary) FROM employees AS prod
    WHERE prod.level = mgr.level
);


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

SELECT id FROM invoices AS rgn
WHERE status IN (
    SELECT status FROM shipments AS inv
    WHERE inv.type = rgn.type
);


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

SELECT value FROM projects AS ord
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS acct
    WHERE acct.status = ord.status
);


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

SELECT value FROM branches AS sale
WHERE value > (
    SELECT AVG(value) FROM customers AS whs
    WHERE whs.code = sale.code
);


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

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


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

SELECT id FROM departments AS shp
WHERE amount > (
    SELECT SUM(amount) FROM branches AS lne
    WHERE lne.id = shp.id
);


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

SELECT name FROM tasks AS cust
WHERE amount > (
    SELECT COUNT(value) FROM orders AS prod
    WHERE prod.status = cust.status
);


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

SELECT value FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT id FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.status = shp.status
);


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

SELECT salary FROM accounts AS schd
WHERE id IN (
    SELECT id FROM branches AS budg
    WHERE budg.level = schd.level
);


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

SELECT code FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.level = empl.level
);


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

SELECT salary FROM tasks AS txn
WHERE value > (
    SELECT MIN(salary) FROM invoices AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT value FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.status = rgn.status
);


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

SELECT name FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = txn.type
);


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

SELECT code FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.type = lne.type
);


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

SELECT amount FROM warehouses AS emp
WHERE type IN (
    SELECT type FROM accounts AS inv
    WHERE inv.type = emp.type
);


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

SELECT id FROM projects AS empl
WHERE type IN (
    SELECT type FROM accounts AS txn
    WHERE txn.status = empl.status
);


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

SELECT name FROM products AS catg
WHERE salary > (
    SELECT SUM(salary) FROM transactions AS lne
    WHERE lne.level = catg.level
);


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

SELECT name FROM departments AS ord
WHERE id IN (
    SELECT id FROM employees AS acct
    WHERE acct.type = ord.type
);


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

SELECT name FROM transactions AS budg
WHERE amount > (
    SELECT SUM(value) FROM accounts AS inv
    WHERE inv.status = budg.status
);


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

SELECT salary FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT salary FROM regions AS ordr
WHERE value > (
    SELECT MIN(amount) FROM shipments AS schd
    WHERE schd.id = ordr.id
);


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

SELECT name FROM departments AS inv
WHERE value > (
    SELECT SUM(salary) FROM transactions AS shp
    WHERE shp.id = inv.id
);


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

SELECT amount FROM projects AS ordr
WHERE value > (
    SELECT MIN(salary) FROM branches AS schd
    WHERE schd.type = ordr.type
);


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

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


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

SELECT value FROM shipments AS empl
WHERE salary > (
    SELECT COUNT(value) FROM departments AS emp
    WHERE emp.type = empl.type
);


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

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


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

SELECT id FROM departments AS acct
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS schd
    WHERE schd.code = acct.code
);


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

SELECT code FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.level = lne.level
);


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

SELECT name FROM accounts AS empl
WHERE salary > (
    SELECT AVG(value) FROM employees AS prod
    WHERE prod.status = empl.status
);


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

SELECT value FROM customers AS prod
WHERE salary > (
    SELECT COUNT(value) FROM accounts AS empl
    WHERE empl.type = prod.type
);


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

SELECT salary FROM products AS cust
WHERE status IN (
    SELECT status FROM warehouses AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT id FROM products AS txn
WHERE id IN (
    SELECT id FROM transactions AS sale
    WHERE sale.code = txn.code
);


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

SELECT id FROM customers AS shp
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS budg
    WHERE budg.code = shp.code
);


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

SELECT salary FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.code = rgn.code
);


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

SELECT name FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT name FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.code = ord.code
);


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

SELECT id FROM employees AS schd
WHERE level IN (
    SELECT level FROM products AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT value FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.status = cust.status
);


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

SELECT amount FROM branches AS ordr
WHERE type IN (
    SELECT type FROM tasks AS lne
    WHERE lne.status = ordr.status
);


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

SELECT amount FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.id = sale.id
);


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

SELECT salary FROM regions AS emp
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.code = emp.code
);


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

SELECT name FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT value FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.type = emp.type
);


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

SELECT salary FROM warehouses AS acct
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT code FROM accounts AS ordr
WHERE level IN (
    SELECT level FROM shipments AS ord
    WHERE ord.level = ordr.level
);


Prompt:
Schema:
  branches (alias: lne)(value, code, salary, level)
  regions(id, name, type, 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 lne
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT amount FROM accounts AS ordr
WHERE status IN (
    SELECT status FROM products AS inv
    WHERE inv.level = ordr.level
);


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

SELECT name FROM accounts AS shp
WHERE id IN (
    SELECT id FROM tasks AS cust
    WHERE cust.status = shp.status
);


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

SELECT code FROM transactions AS prod
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS acct
    WHERE acct.id = prod.id
);


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

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


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

SELECT amount FROM customers AS inv
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.level = inv.level
);


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

SELECT name FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.status = inv.status
);


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

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


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

SELECT code FROM accounts AS mgr
WHERE value > (
    SELECT MAX(salary) FROM departments AS inv
    WHERE inv.type = mgr.type
);


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

SELECT value FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.level = mgr.level
);


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

SELECT id FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.id = whs.id
);


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

SELECT amount FROM departments AS shp
WHERE amount > (
    SELECT MAX(value) FROM categories AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT salary FROM orders AS txn
WHERE id IN (
    SELECT id FROM suppliers AS acct
    WHERE acct.type = txn.type
);


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

SELECT name FROM shipments AS emp
WHERE amount > (
    SELECT MIN(amount) FROM departments AS inv
    WHERE inv.status = emp.status
);


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

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


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

SELECT value FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT name FROM projects AS ordr
WHERE value > (
    SELECT COUNT(value) FROM departments AS emp
    WHERE emp.level = ordr.level
);


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

SELECT name FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.level = srvc.level
);


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

SELECT code FROM categories AS mgr
WHERE amount > (
    SELECT MAX(value) FROM tasks AS shp
    WHERE shp.type = mgr.type
);


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

SELECT value FROM shipments AS sale
WHERE type IN (
    SELECT type FROM transactions AS shp
    WHERE shp.id = sale.id
);


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

SELECT value FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.level = rgn.level
);


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

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


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

SELECT id FROM invoices AS catg
WHERE amount > (
    SELECT MIN(amount) FROM warehouses AS whs
    WHERE whs.status = catg.status
);


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

SELECT id FROM departments AS shp
WHERE id IN (
    SELECT id FROM projects AS cust
    WHERE cust.status = shp.status
);


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

SELECT value FROM categories AS inv
WHERE type IN (
    SELECT type FROM orders AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT amount FROM products AS txn
WHERE id IN (
    SELECT id FROM categories AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT code FROM departments AS prod
WHERE value > (
    SELECT COUNT(salary) FROM branches AS whs
    WHERE whs.type = prod.type
);


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

SELECT salary FROM suppliers AS emp
WHERE id IN (
    SELECT id FROM accounts AS whs
    WHERE whs.code = emp.code
);


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

SELECT value FROM accounts AS cust
WHERE salary > (
    SELECT AVG(salary) FROM projects AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT id FROM transactions AS cust
WHERE value > (
    SELECT SUM(salary) FROM employees AS ord
    WHERE ord.status = cust.status
);


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

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


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

SELECT id FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.code = whs.code
);


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

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


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

SELECT name FROM accounts AS ord
WHERE value > (
    SELECT AVG(amount) FROM orders AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT amount FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.id = lne.id
);


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

SELECT code FROM projects AS txn
WHERE status IN (
    SELECT status FROM accounts AS dept
    WHERE dept.type = txn.type
);


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

SELECT value FROM regions AS inv
WHERE code IN (
    SELECT code FROM customers AS empl
    WHERE empl.id = inv.id
);


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

SELECT code FROM accounts AS lne
WHERE salary > (
    SELECT COUNT(amount) FROM customers AS whs
    WHERE whs.type = lne.type
);


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

SELECT amount FROM customers AS ord
WHERE status IN (
    SELECT status FROM branches AS inv
    WHERE inv.status = ord.status
);


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

SELECT salary FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.type = rgn.type
);


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

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


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

SELECT name FROM suppliers AS catg
WHERE id IN (
    SELECT id FROM transactions AS ord
    WHERE ord.id = catg.id
);


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

SELECT salary FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.status = rgn.status
);


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

SELECT code FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.type = inv.type
);


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

SELECT code FROM departments AS empl
WHERE amount > (
    SELECT MIN(salary) FROM regions AS catg
    WHERE catg.type = empl.type
);


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

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


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

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


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

SELECT code FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.code = ordr.code
);


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

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


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

SELECT value FROM regions AS catg
WHERE salary > (
    SELECT AVG(value) FROM transactions AS empl
    WHERE empl.type = catg.type
);


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

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


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

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


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

SELECT name FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.code = shp.code
);


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

SELECT value FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.id = whs.id
);


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

SELECT value FROM regions AS prod
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS acct
    WHERE acct.id = prod.id
);


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

SELECT value FROM products AS catg
WHERE id IN (
    SELECT id FROM employees AS inv
    WHERE inv.level = catg.level
);


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

SELECT id FROM suppliers AS cust
WHERE type IN (
    SELECT type FROM invoices AS dept
    WHERE dept.type = cust.type
);


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

SELECT salary FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT id FROM tasks AS whs
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.level = whs.level
);


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

SELECT id FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.type = prod.type
);


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

SELECT id FROM products AS txn
WHERE value > (
    SELECT SUM(value) FROM invoices AS emp
    WHERE emp.type = txn.type
);


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

SELECT value FROM departments AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM suppliers AS shp
    WHERE shp.id = lne.id
);


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

SELECT amount FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.status = cust.status
);


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

SELECT value FROM invoices AS dept
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.level = dept.level
);


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

SELECT name FROM customers AS prod
WHERE salary > (
    SELECT SUM(amount) FROM projects AS empl
    WHERE empl.level = prod.level
);


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

SELECT amount FROM employees AS cust
WHERE id IN (
    SELECT id FROM categories AS lne
    WHERE lne.level = cust.level
);


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

SELECT value FROM branches AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS txn
    WHERE txn.status = acct.status
);


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

SELECT amount FROM products AS emp
WHERE value > (
    SELECT COUNT(amount) FROM regions AS empl
    WHERE empl.status = emp.status
);


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

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


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

SELECT salary FROM customers AS inv
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.status = inv.status
);


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

SELECT salary FROM categories AS empl
WHERE value > (
    SELECT COUNT(amount) FROM employees AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT value FROM employees AS rgn
WHERE value > (
    SELECT AVG(amount) FROM tasks AS cust
    WHERE cust.id = rgn.id
);


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

SELECT id FROM products AS acct
WHERE id IN (
    SELECT id FROM warehouses AS sale
    WHERE sale.level = acct.level
);


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

SELECT name FROM branches AS empl
WHERE id IN (
    SELECT id FROM orders AS sale
    WHERE sale.type = empl.type
);


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

SELECT amount FROM shipments AS emp
WHERE value > (
    SELECT COUNT(amount) FROM invoices AS schd
    WHERE schd.status = emp.status
);


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

SELECT amount FROM projects AS shp
WHERE status IN (
    SELECT status FROM warehouses AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT name FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.status = acct.status
);


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

SELECT salary FROM products AS catg
WHERE level IN (
    SELECT level FROM suppliers AS sale
    WHERE sale.id = catg.id
);


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

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


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

SELECT amount FROM categories AS txn
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.type = txn.type
);


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

SELECT id FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT salary FROM shipments AS budg
WHERE amount > (
    SELECT MIN(value) FROM categories AS txn
    WHERE txn.status = budg.status
);


Prompt:
Schema:
  regions (alias: cust)(code, id, salary, type)
  categories(value, status, id, date)
Task: Retrieve salary from regions with value above the COUNT(value) of categories rows sharing the same id.
SQL:

SELECT salary FROM regions AS cust
WHERE value > (
    SELECT COUNT(value) FROM categories AS dept
    WHERE dept.id = cust.id
);


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

SELECT name FROM departments AS ord
WHERE id IN (
    SELECT id FROM regions AS acct
    WHERE acct.type = ord.type
);


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

SELECT amount FROM branches AS rgn
WHERE salary > (
    SELECT COUNT(value) FROM customers AS inv
    WHERE inv.status = rgn.status
);


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

SELECT amount FROM branches AS acct
WHERE amount > (
    SELECT COUNT(value) FROM projects AS emp
    WHERE emp.level = acct.level
);


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

SELECT code FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.status = prod.status
);


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

SELECT name FROM regions AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM warehouses AS mgr
    WHERE mgr.type = catg.type
);


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

SELECT code FROM categories AS dept
WHERE value > (
    SELECT COUNT(amount) FROM employees AS whs
    WHERE whs.status = dept.status
);


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

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


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

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


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

SELECT id FROM projects AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM branches AS catg
    WHERE catg.code = ordr.code
);


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

SELECT amount FROM branches AS txn
WHERE code IN (
    SELECT code FROM warehouses AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT amount FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.level = inv.level
);


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

SELECT amount FROM projects AS sale
WHERE status IN (
    SELECT status FROM customers AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT code FROM customers AS whs
WHERE salary > (
    SELECT SUM(amount) FROM warehouses AS sale
    WHERE sale.level = whs.level
);


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

SELECT code FROM transactions AS mgr
WHERE type IN (
    SELECT type FROM warehouses AS txn
    WHERE txn.status = mgr.status
);


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

SELECT name FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.status = acct.status
);


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

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


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

SELECT name FROM transactions AS ord
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.id = ord.id
);


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

SELECT amount FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT code FROM projects AS schd
WHERE status IN (
    SELECT status FROM accounts AS inv
    WHERE inv.status = schd.status
);


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

SELECT code FROM projects AS lne
WHERE status IN (
    SELECT status FROM regions AS inv
    WHERE inv.id = lne.id
);


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

SELECT name FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.type = empl.type
);


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

SELECT code FROM transactions AS cust
WHERE code IN (
    SELECT code FROM categories AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT name FROM projects AS schd
WHERE type IN (
    SELECT type FROM orders AS whs
    WHERE whs.level = schd.level
);


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

SELECT value FROM transactions AS lne
WHERE value > (
    SELECT AVG(amount) FROM regions AS sale
    WHERE sale.level = lne.level
);


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

SELECT name FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.code = cust.code
);


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

SELECT id FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.type = emp.type
);


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

SELECT value FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = dept.type
);


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

SELECT amount FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.level = inv.level
);


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

SELECT name FROM products AS emp
WHERE salary > (
    SELECT MIN(salary) FROM projects AS txn
    WHERE txn.status = emp.status
);


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

SELECT amount FROM customers AS acct
WHERE amount > (
    SELECT MIN(amount) FROM products AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT salary FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.level = mgr.level
);


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

SELECT amount FROM categories AS shp
WHERE code IN (
    SELECT code FROM invoices AS ord
    WHERE ord.type = shp.type
);


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

SELECT amount FROM invoices AS txn
WHERE level IN (
    SELECT level FROM suppliers AS schd
    WHERE schd.type = txn.type
);


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

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


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

SELECT id FROM departments AS ord
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS budg
    WHERE budg.level = ord.level
);


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

SELECT salary FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.type = sale.type
);


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

SELECT code FROM products AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM regions AS shp
    WHERE shp.type = rgn.type
);


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

SELECT code FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.code = shp.code
);


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

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


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

SELECT code FROM employees AS prod
WHERE salary > (
    SELECT AVG(amount) FROM invoices AS shp
    WHERE shp.type = prod.type
);


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

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


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

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


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

SELECT amount FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT amount FROM customers AS catg
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS lne
    WHERE lne.code = catg.code
);


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

SELECT amount FROM warehouses AS rgn
WHERE value > (
    SELECT MIN(salary) FROM categories AS cust
    WHERE cust.type = rgn.type
);


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

SELECT salary FROM tasks AS cust
WHERE level IN (
    SELECT level FROM customers AS ord
    WHERE ord.id = cust.id
);


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

SELECT salary FROM suppliers AS acct
WHERE value > (
    SELECT MIN(value) FROM warehouses AS emp
    WHERE emp.code = acct.code
);


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

SELECT value FROM projects AS mgr
WHERE value > (
    SELECT MIN(value) FROM employees AS txn
    WHERE txn.status = mgr.status
);


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

SELECT code FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.level = emp.level
);


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

SELECT amount FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.status = emp.status
);


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

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


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

SELECT code FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.code = inv.code
);


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

SELECT name FROM orders AS mgr
WHERE amount > (
    SELECT SUM(value) FROM departments AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT code FROM projects AS dept
WHERE value > (
    SELECT MAX(value) FROM employees AS shp
    WHERE shp.id = dept.id
);


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

SELECT value FROM customers AS ordr
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.type = ordr.type
);


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

SELECT amount FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.id = budg.id
);


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

SELECT value FROM employees AS catg
WHERE status IN (
    SELECT status FROM invoices AS mgr
    WHERE mgr.id = catg.id
);


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

SELECT id FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.level = schd.level
);


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

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


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

SELECT value FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.id = schd.id
);


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

SELECT code FROM regions AS shp
WHERE value > (
    SELECT SUM(amount) FROM branches AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT id FROM customers AS ord
WHERE value > (
    SELECT AVG(salary) FROM accounts AS cust
    WHERE cust.type = ord.type
);


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

SELECT salary FROM orders AS prod
WHERE level IN (
    SELECT level FROM warehouses AS dept
    WHERE dept.level = prod.level
);


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

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


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

SELECT salary FROM orders AS whs
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS txn
    WHERE txn.level = whs.level
);


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

SELECT name FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.status = acct.status
);


Prompt:
Schema:
  employees (alias: dept)(level, value, type, id)
  categories(value, name, level, amount)
Task: Retrieve amount from employees with amount above the MIN(value) of categories rows sharing the same type.
SQL:

SELECT amount FROM employees AS dept
WHERE amount > (
    SELECT MIN(value) FROM categories AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT salary FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.id = txn.id
);


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

SELECT code FROM accounts AS budg
WHERE amount > (
    SELECT SUM(salary) FROM products AS schd
    WHERE schd.id = budg.id
);


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

SELECT name FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.id = sale.id
);


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

SELECT name FROM projects AS shp
WHERE status IN (
    SELECT status FROM employees AS acct
    WHERE acct.id = shp.id
);


Prompt:
Schema:
  regions (alias: emp)(type, date, status, level)
  categories(date, value, type, id)
Task: Retrieve value from regions with amount above the MAX(amount) of categories rows sharing the same type.
SQL:

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


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

SELECT name FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.code = whs.code
);


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

SELECT code FROM customers AS rgn
WHERE salary > (
    SELECT MIN(value) FROM categories AS dept
    WHERE dept.level = rgn.level
);


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

SELECT value FROM accounts AS shp
WHERE salary > (
    SELECT SUM(value) FROM suppliers AS empl
    WHERE empl.type = shp.type
);


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

SELECT amount FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.id = srvc.id
);


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

SELECT value FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.id = budg.id
);


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

SELECT id FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.level = ordr.level
);


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

SELECT value FROM suppliers AS catg
WHERE value > (
    SELECT AVG(salary) FROM employees AS sale
    WHERE sale.id = catg.id
);


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

SELECT code FROM invoices AS whs
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS prod
    WHERE prod.code = whs.code
);


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

SELECT salary FROM products AS emp
WHERE type IN (
    SELECT type FROM transactions AS sale
    WHERE sale.status = emp.status
);


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

SELECT code FROM accounts AS empl
WHERE value > (
    SELECT AVG(salary) FROM departments AS schd
    WHERE schd.status = empl.status
);


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

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


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

SELECT salary FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.id = ord.id
);


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

SELECT name FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.status = txn.status
);


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

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


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

SELECT amount FROM customers AS ord
WHERE id IN (
    SELECT id FROM employees AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT salary FROM employees AS schd
WHERE status IN (
    SELECT status FROM accounts AS catg
    WHERE catg.type = schd.type
);


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

SELECT salary FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.code = ord.code
);


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

SELECT name FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.code = sale.code
);


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

SELECT id FROM branches AS srvc
WHERE value > (
    SELECT MIN(value) FROM orders AS dept
    WHERE dept.id = srvc.id
);


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

SELECT value FROM accounts AS ord
WHERE status IN (
    SELECT status FROM shipments AS cust
    WHERE cust.id = ord.id
);


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

SELECT name FROM regions AS prod
WHERE level IN (
    SELECT level FROM accounts AS shp
    WHERE shp.code = prod.code
);


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

SELECT name FROM products AS lne
WHERE id IN (
    SELECT id FROM accounts AS dept
    WHERE dept.level = lne.level
);


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

SELECT value FROM invoices AS srvc
WHERE value > (
    SELECT AVG(amount) FROM projects AS lne
    WHERE lne.status = srvc.status
);


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

SELECT id FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.id = srvc.id
);


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

SELECT value FROM employees AS sale
WHERE salary > (
    SELECT SUM(salary) FROM customers AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT name FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.type = txn.type
);


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

SELECT id FROM shipments AS acct
WHERE level IN (
    SELECT level FROM employees AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT name FROM shipments AS sale
WHERE salary > (
    SELECT AVG(value) FROM accounts AS emp
    WHERE emp.status = sale.status
);


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

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


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

SELECT id FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.id = emp.id
);


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

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


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

SELECT salary FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.code = inv.code
);


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

SELECT value FROM employees AS empl
WHERE type IN (
    SELECT type FROM shipments AS cust
    WHERE cust.status = empl.status
);


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

SELECT amount FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.status = cust.status
);


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

SELECT amount FROM suppliers AS acct
WHERE amount > (
    SELECT MAX(value) FROM projects AS budg
    WHERE budg.code = acct.code
);


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

SELECT value FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.type = empl.type
);


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

SELECT id FROM departments AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM warehouses AS inv
    WHERE inv.code = empl.code
);


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

SELECT name FROM categories AS schd
WHERE value > (
    SELECT MAX(value) FROM suppliers AS emp
    WHERE emp.level = schd.level
);


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

SELECT id FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.type = lne.type
);


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

SELECT name FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT code FROM branches AS acct
WHERE value > (
    SELECT AVG(amount) FROM regions AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT value FROM tasks AS whs
WHERE level IN (
    SELECT level FROM orders AS txn
    WHERE txn.level = whs.level
);


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

SELECT amount FROM orders AS emp
WHERE value > (
    SELECT AVG(value) FROM employees AS sale
    WHERE sale.status = emp.status
);


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

SELECT salary FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.id = txn.id
);


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

SELECT salary FROM categories AS budg
WHERE type IN (
    SELECT type FROM accounts AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT value FROM categories AS rgn
WHERE status IN (
    SELECT status FROM warehouses AS empl
    WHERE empl.status = rgn.status
);


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

SELECT amount FROM transactions AS whs
WHERE value > (
    SELECT AVG(salary) FROM categories AS txn
    WHERE txn.code = whs.code
);


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

SELECT code FROM accounts AS txn
WHERE level IN (
    SELECT level FROM departments AS shp
    WHERE shp.status = txn.status
);


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

SELECT id FROM employees AS dept
WHERE id IN (
    SELECT id FROM products AS catg
    WHERE catg.code = dept.code
);


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

SELECT code FROM tasks AS inv
WHERE level IN (
    SELECT level FROM customers AS txn
    WHERE txn.status = inv.status
);


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

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


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

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


Prompt:
Schema:
  transactions (alias: schd)(type, id, name, date)
  customers(name, status, id, date)
Task: Retrieve name from transactions with salary above the SUM(salary) of customers rows sharing the same level.
SQL:

SELECT name FROM transactions AS schd
WHERE salary > (
    SELECT SUM(salary) FROM customers AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT salary FROM accounts AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM products AS lne
    WHERE lne.type = srvc.type
);


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

SELECT name FROM shipments AS dept
WHERE salary > (
    SELECT MAX(value) FROM employees AS whs
    WHERE whs.id = dept.id
);


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

SELECT code FROM invoices AS whs
WHERE code IN (
    SELECT code FROM projects AS lne
    WHERE lne.id = whs.id
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT name FROM products AS txn
WHERE level IN (
    SELECT level FROM transactions AS acct
    WHERE acct.id = txn.id
);


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

SELECT code FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.code = mgr.code
);


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

SELECT salary FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT value FROM warehouses AS empl
WHERE level IN (
    SELECT level FROM regions AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT salary FROM warehouses AS inv
WHERE value > (
    SELECT MIN(amount) FROM accounts AS emp
    WHERE emp.type = inv.type
);


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

SELECT value FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.code = ordr.code
);


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

SELECT code FROM shipments AS inv
WHERE id IN (
    SELECT id FROM warehouses AS prod
    WHERE prod.status = inv.status
);


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

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


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

SELECT amount FROM products AS budg
WHERE amount > (
    SELECT MAX(value) FROM projects AS srvc
    WHERE srvc.type = budg.type
);


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

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


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

SELECT salary FROM customers AS lne
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS inv
    WHERE inv.type = lne.type
);


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

SELECT amount FROM tasks AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM employees AS empl
    WHERE empl.id = rgn.id
);


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

SELECT amount FROM warehouses AS schd
WHERE value > (
    SELECT MIN(salary) FROM employees AS catg
    WHERE catg.type = schd.type
);


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

SELECT id FROM tasks AS srvc
WHERE level IN (
    SELECT level FROM categories AS empl
    WHERE empl.type = srvc.type
);