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

SELECT value FROM customers AS sale
WHERE salary > (
    SELECT MIN(value) FROM projects AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT name FROM products AS ord
WHERE value > (
    SELECT AVG(value) FROM departments AS dept
    WHERE dept.level = ord.level
);


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

SELECT salary FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.id = txn.id
);


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

SELECT code FROM transactions AS schd
WHERE code IN (
    SELECT code FROM projects AS emp
    WHERE emp.status = schd.status
);


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

SELECT code FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.status = lne.status
);


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

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


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

SELECT amount FROM branches AS dept
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS mgr
    WHERE mgr.type = dept.type
);


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

SELECT code FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.status = emp.status
);


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

SELECT id FROM departments AS catg
WHERE id IN (
    SELECT id FROM categories AS shp
    WHERE shp.code = catg.code
);


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

SELECT code FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT id FROM transactions AS empl
WHERE amount > (
    SELECT MAX(value) FROM employees AS cust
    WHERE cust.id = empl.id
);


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

SELECT amount FROM transactions AS prod
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS lne
    WHERE lne.level = prod.level
);


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

SELECT code FROM shipments AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS txn
    WHERE txn.level = ordr.level
);


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

SELECT id FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.status = mgr.status
);


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

SELECT salary FROM invoices AS catg
WHERE id IN (
    SELECT id FROM warehouses AS lne
    WHERE lne.level = catg.level
);


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

SELECT value FROM customers AS cust
WHERE salary > (
    SELECT MIN(amount) FROM tasks AS dept
    WHERE dept.level = cust.level
);


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

SELECT salary FROM products AS acct
WHERE salary > (
    SELECT MIN(salary) FROM orders AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT id FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.code = emp.code
);


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

SELECT name FROM regions AS catg
WHERE value > (
    SELECT MAX(amount) FROM invoices AS budg
    WHERE budg.id = catg.id
);


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

SELECT value FROM suppliers AS srvc
WHERE type IN (
    SELECT type FROM products AS sale
    WHERE sale.type = srvc.type
);


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

SELECT code FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.level = schd.level
);


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

SELECT value FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.code = ord.code
);


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

SELECT code FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.level = ordr.level
);


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

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


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

SELECT value FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.id = srvc.id
);


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

SELECT value FROM shipments AS whs
WHERE level IN (
    SELECT level FROM projects AS emp
    WHERE emp.status = whs.status
);


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

SELECT id FROM tasks AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM customers AS sale
    WHERE sale.type = srvc.type
);


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

SELECT salary FROM departments AS whs
WHERE value > (
    SELECT SUM(amount) FROM accounts AS cust
    WHERE cust.code = whs.code
);


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

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


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

SELECT name FROM departments AS emp
WHERE value > (
    SELECT MAX(value) FROM transactions AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT name FROM departments AS rgn
WHERE code IN (
    SELECT code FROM tasks AS acct
    WHERE acct.id = rgn.id
);


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

SELECT id FROM branches AS mgr
WHERE status IN (
    SELECT status FROM departments AS prod
    WHERE prod.id = mgr.id
);


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

SELECT name FROM warehouses AS empl
WHERE id IN (
    SELECT id FROM departments AS catg
    WHERE catg.id = empl.id
);


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

SELECT salary FROM products AS dept
WHERE level IN (
    SELECT level FROM invoices AS acct
    WHERE acct.status = dept.status
);


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

SELECT name FROM tasks AS lne
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS shp
    WHERE shp.type = lne.type
);


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

SELECT id FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT id FROM employees AS ord
WHERE level IN (
    SELECT level FROM projects AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT code FROM shipments AS acct
WHERE salary > (
    SELECT SUM(value) FROM departments AS empl
    WHERE empl.status = acct.status
);


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

SELECT name FROM categories AS rgn
WHERE status IN (
    SELECT status FROM accounts AS schd
    WHERE schd.id = rgn.id
);


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

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


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

SELECT value FROM warehouses AS sale
WHERE salary > (
    SELECT MIN(amount) FROM customers AS catg
    WHERE catg.level = sale.level
);


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

SELECT id FROM regions AS budg
WHERE value > (
    SELECT SUM(amount) FROM orders AS prod
    WHERE prod.status = budg.status
);


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

SELECT code FROM employees AS empl
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS inv
    WHERE inv.status = empl.status
);


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

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


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

SELECT id FROM shipments AS whs
WHERE salary > (
    SELECT SUM(salary) FROM projects AS lne
    WHERE lne.type = whs.type
);


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

SELECT id FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.level = ord.level
);


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

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


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

SELECT salary FROM orders AS mgr
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT value FROM orders AS budg
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.status = budg.status
);


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

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


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

SELECT code FROM regions AS srvc
WHERE salary > (
    SELECT COUNT(value) FROM customers AS prod
    WHERE prod.type = srvc.type
);


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

SELECT salary FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.type = inv.type
);


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

SELECT name FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.type = sale.type
);


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

SELECT amount FROM products AS ord
WHERE level IN (
    SELECT level FROM categories AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT name FROM shipments AS mgr
WHERE value > (
    SELECT MIN(value) FROM orders AS schd
    WHERE schd.type = mgr.type
);


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

SELECT value FROM tasks AS acct
WHERE type IN (
    SELECT type FROM suppliers AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT code FROM branches AS acct
WHERE id IN (
    SELECT id FROM projects AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT salary FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.type = lne.type
);


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

SELECT code FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.status = dept.status
);


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

SELECT salary FROM products AS empl
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS shp
    WHERE shp.code = empl.code
);


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT id FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.level = whs.level
);


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

SELECT value FROM orders AS lne
WHERE id IN (
    SELECT id FROM branches AS ord
    WHERE ord.level = lne.level
);


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

SELECT id FROM products AS sale
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.status = sale.status
);


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

SELECT code FROM transactions AS cust
WHERE amount > (
    SELECT MIN(value) FROM departments AS whs
    WHERE whs.status = cust.status
);


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

SELECT value FROM tasks AS emp
WHERE id IN (
    SELECT id FROM departments AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT amount FROM tasks AS catg
WHERE amount > (
    SELECT MAX(value) FROM accounts AS emp
    WHERE emp.id = catg.id
);


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

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


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

SELECT value FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.type = prod.type
);


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

SELECT code FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.status = acct.status
);


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

SELECT salary FROM regions AS whs
WHERE status IN (
    SELECT status FROM warehouses AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT value FROM products AS dept
WHERE id IN (
    SELECT id FROM tasks AS acct
    WHERE acct.type = dept.type
);


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

SELECT value FROM departments AS sale
WHERE level IN (
    SELECT level FROM suppliers AS cust
    WHERE cust.code = sale.code
);


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

SELECT salary FROM employees AS ord
WHERE status IN (
    SELECT status FROM regions AS inv
    WHERE inv.status = ord.status
);


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

SELECT id FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.id = cust.id
);


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

SELECT value FROM shipments AS txn
WHERE value > (
    SELECT SUM(amount) FROM orders AS sale
    WHERE sale.code = txn.code
);


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

SELECT salary FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.type = mgr.type
);


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

SELECT value FROM products AS cust
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.id = cust.id
);


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

SELECT name FROM accounts AS ord
WHERE salary > (
    SELECT MIN(salary) FROM orders AS emp
    WHERE emp.type = ord.type
);


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

SELECT value FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = whs.code
);


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

SELECT code FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.level = ordr.level
);


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

SELECT name FROM employees AS rgn
WHERE level IN (
    SELECT level FROM departments AS acct
    WHERE acct.status = rgn.status
);


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

SELECT code FROM employees AS lne
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS acct
    WHERE acct.code = lne.code
);


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

SELECT code FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = catg.level
);


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

SELECT name FROM orders AS acct
WHERE amount > (
    SELECT SUM(salary) FROM branches AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT salary FROM invoices AS sale
WHERE value > (
    SELECT AVG(salary) FROM shipments AS shp
    WHERE shp.id = sale.id
);


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

SELECT salary FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.type = schd.type
);


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

SELECT salary FROM suppliers AS sale
WHERE value > (
    SELECT SUM(value) FROM branches AS ord
    WHERE ord.level = sale.level
);


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

SELECT code FROM customers AS ord
WHERE status IN (
    SELECT status FROM warehouses AS inv
    WHERE inv.id = ord.id
);


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

SELECT name FROM suppliers AS rgn
WHERE value > (
    SELECT MAX(amount) FROM categories AS srvc
    WHERE srvc.code = rgn.code
);


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

SELECT amount FROM customers AS shp
WHERE value > (
    SELECT COUNT(value) FROM departments AS emp
    WHERE emp.code = shp.code
);


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

SELECT code FROM projects AS acct
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.status = acct.status
);


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

SELECT id FROM employees AS lne
WHERE salary > (
    SELECT COUNT(value) FROM warehouses AS budg
    WHERE budg.level = lne.level
);


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

SELECT salary FROM projects AS mgr
WHERE id IN (
    SELECT id FROM customers AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT id FROM regions AS emp
WHERE type IN (
    SELECT type FROM accounts AS whs
    WHERE whs.status = emp.status
);


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

SELECT id FROM regions AS budg
WHERE level IN (
    SELECT level FROM products AS emp
    WHERE emp.status = budg.status
);


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

SELECT name FROM warehouses AS acct
WHERE level IN (
    SELECT level FROM departments AS lne
    WHERE lne.type = acct.type
);


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

SELECT id FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.status = txn.status
);


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

SELECT code FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = lne.code
);


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

SELECT id FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.type = ordr.type
);


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

SELECT code FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.code = rgn.code
);


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

SELECT value FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.status = cust.status
);


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

SELECT amount FROM accounts AS empl
WHERE salary > (
    SELECT AVG(salary) FROM departments AS ord
    WHERE ord.code = empl.code
);


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

SELECT amount FROM departments AS sale
WHERE type IN (
    SELECT type FROM regions AS prod
    WHERE prod.code = sale.code
);


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

SELECT value FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.id = shp.id
);


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

SELECT id FROM categories AS lne
WHERE type IN (
    SELECT type FROM products AS emp
    WHERE emp.level = lne.level
);


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

SELECT name FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.level = shp.level
);


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

SELECT value FROM shipments AS whs
WHERE amount > (
    SELECT SUM(value) FROM employees AS shp
    WHERE shp.code = whs.code
);


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

SELECT name FROM departments AS emp
WHERE type IN (
    SELECT type FROM transactions AS acct
    WHERE acct.status = emp.status
);


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

SELECT salary FROM projects AS dept
WHERE type IN (
    SELECT type FROM transactions AS sale
    WHERE sale.code = dept.code
);


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

SELECT salary FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.type = prod.type
);


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

SELECT amount FROM regions AS acct
WHERE amount > (
    SELECT SUM(amount) FROM employees AS txn
    WHERE txn.status = acct.status
);


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

SELECT name FROM branches AS mgr
WHERE amount > (
    SELECT SUM(value) FROM customers AS lne
    WHERE lne.id = mgr.id
);


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

SELECT name FROM customers AS txn
WHERE salary > (
    SELECT MIN(amount) FROM orders AS cust
    WHERE cust.level = txn.level
);


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

SELECT name FROM projects AS sale
WHERE level IN (
    SELECT level FROM categories AS lne
    WHERE lne.status = sale.status
);


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

SELECT salary FROM transactions AS mgr
WHERE type IN (
    SELECT type FROM departments AS whs
    WHERE whs.level = mgr.level
);


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

SELECT value FROM products AS acct
WHERE value > (
    SELECT COUNT(salary) FROM warehouses AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT name FROM shipments AS mgr
WHERE id IN (
    SELECT id FROM customers AS acct
    WHERE acct.status = mgr.status
);


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

SELECT name FROM regions AS whs
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT name FROM categories AS txn
WHERE amount > (
    SELECT MIN(salary) FROM suppliers AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT salary FROM categories AS lne
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT id FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT salary FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = lne.type
);


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

SELECT amount FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT id FROM products AS txn
WHERE status IN (
    SELECT status FROM tasks AS prod
    WHERE prod.code = txn.code
);


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

SELECT amount FROM customers AS srvc
WHERE id IN (
    SELECT id FROM projects AS cust
    WHERE cust.type = srvc.type
);


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

SELECT name FROM categories AS prod
WHERE type IN (
    SELECT type FROM shipments AS inv
    WHERE inv.type = prod.type
);


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

SELECT code FROM regions AS schd
WHERE status IN (
    SELECT status FROM tasks AS lne
    WHERE lne.status = schd.status
);


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

SELECT id FROM departments AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM projects AS whs
    WHERE whs.code = mgr.code
);


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

SELECT name FROM categories AS inv
WHERE status IN (
    SELECT status FROM employees AS shp
    WHERE shp.code = inv.code
);


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

SELECT id FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.level = sale.level
);


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

SELECT code FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT salary FROM invoices AS ordr
WHERE amount > (
    SELECT MAX(value) FROM tasks AS sale
    WHERE sale.status = ordr.status
);


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

SELECT value FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.level = mgr.level
);


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

SELECT amount FROM departments AS rgn
WHERE id IN (
    SELECT id FROM branches AS sale
    WHERE sale.status = rgn.status
);


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

SELECT code FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.level = whs.level
);


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

SELECT value FROM shipments AS txn
WHERE id IN (
    SELECT id FROM accounts AS inv
    WHERE inv.code = txn.code
);


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

SELECT salary FROM shipments AS ord
WHERE salary > (
    SELECT AVG(salary) FROM regions AS cust
    WHERE cust.type = ord.type
);


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

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


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

SELECT id FROM accounts AS schd
WHERE amount > (
    SELECT MIN(value) FROM tasks AS acct
    WHERE acct.status = schd.status
);


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

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


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

SELECT code FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.type = cust.type
);


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

SELECT salary FROM regions AS whs
WHERE amount > (
    SELECT SUM(amount) FROM departments AS shp
    WHERE shp.id = whs.id
);


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

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


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

SELECT value FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.code = txn.code
);


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

SELECT name FROM departments AS cust
WHERE code IN (
    SELECT code FROM shipments AS whs
    WHERE whs.status = cust.status
);


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

SELECT salary FROM suppliers AS acct
WHERE type IN (
    SELECT type FROM categories AS budg
    WHERE budg.level = acct.level
);


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

SELECT name FROM warehouses AS cust
WHERE salary > (
    SELECT MIN(value) FROM employees AS catg
    WHERE catg.code = cust.code
);


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

SELECT value FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.type = lne.type
);


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

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


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

SELECT name FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = emp.status
);


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

SELECT name FROM regions AS ordr
WHERE type IN (
    SELECT type FROM departments AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT code FROM categories AS inv
WHERE salary > (
    SELECT COUNT(amount) FROM customers AS whs
    WHERE whs.level = inv.level
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.id = rgn.id
);


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

SELECT amount FROM accounts AS acct
WHERE salary > (
    SELECT COUNT(value) FROM employees AS catg
    WHERE catg.id = acct.id
);


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

SELECT value FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.level = prod.level
);


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

SELECT id FROM departments AS cust
WHERE value > (
    SELECT COUNT(salary) FROM invoices AS prod
    WHERE prod.code = cust.code
);


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

SELECT salary FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.level = cust.level
);


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

SELECT value FROM regions AS whs
WHERE status IN (
    SELECT status FROM orders AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT name FROM employees AS prod
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.status = prod.status
);


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

SELECT code FROM categories AS mgr
WHERE value > (
    SELECT SUM(amount) FROM regions AS dept
    WHERE dept.type = mgr.type
);


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

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


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

SELECT id FROM tasks AS catg
WHERE value > (
    SELECT MIN(value) FROM transactions AS acct
    WHERE acct.level = catg.level
);


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

SELECT id FROM products AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS prod
    WHERE prod.level = ord.level
);


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

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


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

SELECT name FROM invoices AS emp
WHERE value > (
    SELECT SUM(salary) FROM transactions AS lne
    WHERE lne.type = emp.type
);


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

SELECT salary FROM branches AS cust
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.code = cust.code
);


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

SELECT id FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.id = emp.id
);


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

SELECT code FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.type = mgr.type
);


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

SELECT value FROM departments AS schd
WHERE type IN (
    SELECT type FROM customers AS srvc
    WHERE srvc.id = schd.id
);


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

SELECT name FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = whs.status
);


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

SELECT value FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.type = srvc.type
);


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

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


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

SELECT id FROM invoices AS whs
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS dept
    WHERE dept.status = whs.status
);


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

SELECT name FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.id = txn.id
);


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

SELECT amount FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.status = txn.status
);


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

SELECT code FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.code = emp.code
);


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

SELECT id FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.level = schd.level
);


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

SELECT amount FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM warehouses AS ord
    WHERE ord.status = rgn.status
);


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

SELECT salary FROM products AS dept
WHERE status IN (
    SELECT status FROM accounts AS empl
    WHERE empl.type = dept.type
);


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

SELECT salary FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.status = whs.status
);


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

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


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

SELECT id FROM departments AS inv
WHERE value > (
    SELECT COUNT(value) FROM employees AS whs
    WHERE whs.type = inv.type
);


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

SELECT value FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.level = prod.level
);


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

SELECT salary FROM departments AS cust
WHERE value > (
    SELECT SUM(amount) FROM employees AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT amount FROM products AS sale
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS whs
    WHERE whs.id = sale.id
);


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

SELECT value FROM employees AS ord
WHERE status IN (
    SELECT status FROM branches AS srvc
    WHERE srvc.code = ord.code
);


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

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


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

SELECT name FROM projects AS txn
WHERE id IN (
    SELECT id FROM categories AS whs
    WHERE whs.code = txn.code
);


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

SELECT salary FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.level = schd.level
);


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

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


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

SELECT salary FROM suppliers AS emp
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS inv
    WHERE inv.code = emp.code
);


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

SELECT amount FROM employees AS whs
WHERE status IN (
    SELECT status FROM invoices AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT amount FROM projects AS empl
WHERE amount > (
    SELECT MAX(salary) FROM departments AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT name FROM customers AS whs
WHERE amount > (
    SELECT MIN(salary) FROM employees AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT code FROM orders AS dept
WHERE code IN (
    SELECT code FROM invoices AS empl
    WHERE empl.type = dept.type
);


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

SELECT salary FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.type = shp.type
);


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

SELECT code FROM departments AS catg
WHERE status IN (
    SELECT status FROM warehouses AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT name FROM suppliers AS shp
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.code = shp.code
);


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

SELECT name FROM products AS schd
WHERE id IN (
    SELECT id FROM invoices AS dept
    WHERE dept.id = schd.id
);


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

SELECT id FROM warehouses AS whs
WHERE type IN (
    SELECT type FROM orders AS sale
    WHERE sale.id = whs.id
);


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

SELECT code FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.id = rgn.id
);


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

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


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

SELECT name FROM products AS ordr
WHERE value > (
    SELECT MIN(amount) FROM shipments AS lne
    WHERE lne.type = ordr.type
);


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

SELECT name FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = txn.id
);


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

SELECT name FROM categories AS lne
WHERE amount > (
    SELECT MAX(salary) FROM products AS txn
    WHERE txn.status = lne.status
);


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

SELECT salary FROM orders AS acct
WHERE value > (
    SELECT AVG(amount) FROM invoices AS dept
    WHERE dept.type = acct.type
);


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

SELECT name FROM invoices AS acct
WHERE id IN (
    SELECT id FROM transactions AS shp
    WHERE shp.status = acct.status
);


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

SELECT id FROM employees AS prod
WHERE salary > (
    SELECT COUNT(salary) FROM transactions AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT name FROM employees AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS empl
    WHERE empl.status = sale.status
);


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

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


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

SELECT value FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.level = ord.level
);


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

SELECT name FROM orders AS catg
WHERE code IN (
    SELECT code FROM products AS cust
    WHERE cust.id = catg.id
);


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

SELECT value FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.id = catg.id
);


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

SELECT amount FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT salary FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.code = empl.code
);


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

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


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

SELECT code FROM shipments AS ord
WHERE status IN (
    SELECT status FROM employees AS whs
    WHERE whs.status = ord.status
);


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

SELECT code FROM employees AS empl
WHERE value > (
    SELECT MAX(value) FROM transactions AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT name FROM departments AS empl
WHERE value > (
    SELECT COUNT(salary) FROM products AS lne
    WHERE lne.id = empl.id
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT name FROM orders AS lne
WHERE type IN (
    SELECT type FROM warehouses AS emp
    WHERE emp.id = lne.id
);


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

SELECT code FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.status = inv.status
);


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

SELECT name FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.type = sale.type
);


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

SELECT name FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.code = sale.code
);


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

SELECT salary FROM orders AS srvc
WHERE salary > (
    SELECT COUNT(value) FROM regions AS lne
    WHERE lne.id = srvc.id
);


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

SELECT id FROM branches AS cust
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS empl
    WHERE empl.level = cust.level
);


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

SELECT salary FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT id FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.type = srvc.type
);


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

SELECT code FROM suppliers AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS cust
    WHERE cust.type = srvc.type
);


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

SELECT salary FROM orders AS ord
WHERE code IN (
    SELECT code FROM projects AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT id FROM suppliers AS shp
WHERE salary > (
    SELECT MIN(value) FROM accounts AS dept
    WHERE dept.type = shp.type
);


Prompt:
Schema:
  transactions (alias: whs)(date, status, level, code)
  shipments(date, name, level, status)
Task: Find name from transactions where level appears in shipments entries with matching code.
SQL:

SELECT name FROM transactions AS whs
WHERE level IN (
    SELECT level FROM shipments AS srvc
    WHERE srvc.code = whs.code
);


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

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


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

SELECT value FROM departments AS emp
WHERE status IN (
    SELECT status FROM shipments AS rgn
    WHERE rgn.type = emp.type
);


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

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


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

SELECT amount FROM employees AS ordr
WHERE value > (
    SELECT AVG(amount) FROM invoices AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT salary FROM projects AS srvc
WHERE code IN (
    SELECT code FROM transactions AS empl
    WHERE empl.code = srvc.code
);


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

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


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

SELECT amount FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.status = cust.status
);


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

SELECT name FROM projects AS shp
WHERE status IN (
    SELECT status FROM transactions AS ord
    WHERE ord.type = shp.type
);


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

SELECT value FROM regions AS emp
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT code FROM departments AS srvc
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS prod
    WHERE prod.type = srvc.type
);


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

SELECT value FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.id = sale.id
);


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

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


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

SELECT code FROM shipments AS rgn
WHERE level IN (
    SELECT level FROM transactions AS budg
    WHERE budg.type = rgn.type
);


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

SELECT value FROM orders AS rgn
WHERE id IN (
    SELECT id FROM customers AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT amount FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.status = prod.status
);


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

SELECT amount FROM warehouses AS schd
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS whs
    WHERE whs.level = schd.level
);


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

SELECT amount FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.id = srvc.id
);


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

SELECT id FROM products AS lne
WHERE amount > (
    SELECT MAX(value) FROM invoices AS whs
    WHERE whs.level = lne.level
);


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

SELECT id FROM branches AS sale
WHERE status IN (
    SELECT status FROM categories AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT salary FROM invoices AS budg
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS cust
    WHERE cust.level = budg.level
);


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

SELECT code FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.id = acct.id
);


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

SELECT amount FROM departments AS inv
WHERE value > (
    SELECT SUM(value) FROM transactions AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.level = prod.level
);


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

SELECT amount FROM branches AS mgr
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS empl
    WHERE empl.id = mgr.id
);


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

SELECT code FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT salary FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.type = emp.type
);


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

SELECT salary FROM projects AS empl
WHERE id IN (
    SELECT id FROM warehouses AS dept
    WHERE dept.level = empl.level
);


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

SELECT salary FROM accounts AS acct
WHERE level IN (
    SELECT level FROM employees AS prod
    WHERE prod.type = acct.type
);


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

SELECT code FROM projects AS dept
WHERE value > (
    SELECT SUM(salary) FROM transactions AS catg
    WHERE catg.status = dept.status
);


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

SELECT amount FROM warehouses AS ordr
WHERE type IN (
    SELECT type FROM regions AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT salary FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.status = catg.status
);


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

SELECT id FROM invoices AS prod
WHERE status IN (
    SELECT status FROM departments AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT name FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.code = mgr.code
);


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

SELECT id FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.id = empl.id
);


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

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


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

SELECT value FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.id = sale.id
);


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

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


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

SELECT code FROM tasks AS srvc
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS dept
    WHERE dept.code = srvc.code
);


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

SELECT code FROM tasks AS txn
WHERE salary > (
    SELECT AVG(amount) FROM products AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT name FROM projects AS catg
WHERE level IN (
    SELECT level FROM categories AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT code FROM tasks AS ord
WHERE status IN (
    SELECT status FROM employees AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT name FROM products AS ord
WHERE status IN (
    SELECT status FROM projects AS empl
    WHERE empl.id = ord.id
);


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

SELECT code FROM categories AS schd
WHERE salary > (
    SELECT MIN(value) FROM regions AS ord
    WHERE ord.type = schd.type
);


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

SELECT code FROM invoices AS mgr
WHERE level IN (
    SELECT level FROM projects AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT salary FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.level = whs.level
);


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

SELECT salary FROM regions AS schd
WHERE id IN (
    SELECT id FROM branches AS catg
    WHERE catg.level = schd.level
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.id = rgn.id
);


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

SELECT salary FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.level = dept.level
);


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

SELECT id FROM accounts AS acct
WHERE value > (
    SELECT COUNT(amount) FROM branches AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT code FROM warehouses AS shp
WHERE value > (
    SELECT MIN(salary) FROM employees AS txn
    WHERE txn.type = shp.type
);


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

SELECT name FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.code = shp.code
);


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

SELECT value FROM products AS empl
WHERE value > (
    SELECT SUM(salary) FROM employees AS rgn
    WHERE rgn.type = empl.type
);


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

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


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

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


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

SELECT code FROM customers AS dept
WHERE type IN (
    SELECT type FROM employees AS prod
    WHERE prod.code = dept.code
);


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

SELECT amount FROM branches AS ord
WHERE level IN (
    SELECT level FROM categories AS shp
    WHERE shp.type = ord.type
);


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

SELECT code FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT code FROM warehouses AS whs
WHERE salary > (
    SELECT MAX(value) FROM shipments AS txn
    WHERE txn.level = whs.level
);


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

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


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

SELECT salary FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.id = whs.id
);