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

SELECT amount FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT code FROM transactions AS catg
WHERE amount > (
    SELECT SUM(salary) FROM customers AS mgr
    WHERE mgr.status = catg.status
);


Prompt:
Schema:
  employees (alias: sale)(id, code, type, date)
  suppliers(value, code, id, date)
Task: Find id from employees where code appears in suppliers entries with matching level.
SQL:

SELECT id FROM employees AS sale
WHERE code IN (
    SELECT code FROM suppliers AS emp
    WHERE emp.level = sale.level
);


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

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


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

SELECT value FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT amount FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT id FROM warehouses AS sale
WHERE code IN (
    SELECT code FROM regions AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT name FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT code FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.type = ordr.type
);


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

SELECT name FROM transactions AS acct
WHERE amount > (
    SELECT COUNT(value) FROM departments AS txn
    WHERE txn.type = acct.type
);


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

SELECT code FROM branches AS cust
WHERE type IN (
    SELECT type FROM shipments AS shp
    WHERE shp.id = cust.id
);


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

SELECT code FROM accounts AS inv
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS prod
    WHERE prod.type = inv.type
);


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

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


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

SELECT name FROM projects AS rgn
WHERE id IN (
    SELECT id FROM categories AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT id FROM warehouses AS sale
WHERE value > (
    SELECT SUM(value) FROM transactions AS shp
    WHERE shp.status = sale.status
);


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

SELECT amount FROM tasks AS ord
WHERE type IN (
    SELECT type FROM projects AS emp
    WHERE emp.type = ord.type
);


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

SELECT code FROM invoices AS rgn
WHERE code IN (
    SELECT code FROM accounts AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT name FROM tasks AS txn
WHERE id IN (
    SELECT id FROM categories AS prod
    WHERE prod.level = txn.level
);


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

SELECT amount FROM departments AS cust
WHERE level IN (
    SELECT level FROM accounts AS empl
    WHERE empl.level = cust.level
);


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

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


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

SELECT value FROM products AS ord
WHERE id IN (
    SELECT id FROM accounts AS shp
    WHERE shp.code = ord.code
);


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

SELECT id FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.code = prod.code
);


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

SELECT name FROM regions AS cust
WHERE level IN (
    SELECT level FROM invoices AS ord
    WHERE ord.type = cust.type
);


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

SELECT id FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.level = srvc.level
);


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

SELECT code FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.code = ordr.code
);


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

SELECT salary FROM warehouses AS sale
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.status = sale.status
);


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

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


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

SELECT name FROM departments AS dept
WHERE level IN (
    SELECT level FROM suppliers AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT name FROM accounts AS rgn
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.status = rgn.status
);


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

SELECT value FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.status = dept.status
);


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

SELECT id FROM transactions AS whs
WHERE status IN (
    SELECT status FROM shipments AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT id FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.type = prod.type
);


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

SELECT amount FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.type = shp.type
);


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

SELECT salary FROM shipments AS dept
WHERE code IN (
    SELECT code FROM warehouses AS catg
    WHERE catg.code = dept.code
);


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

SELECT id FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.id = mgr.id
);


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

SELECT salary FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.level = emp.level
);


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

SELECT value FROM tasks AS ordr
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS sale
    WHERE sale.status = ordr.status
);


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

SELECT value FROM categories AS cust
WHERE level IN (
    SELECT level FROM invoices AS acct
    WHERE acct.type = cust.type
);


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

SELECT id FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.code = inv.code
);


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

SELECT code FROM suppliers AS empl
WHERE id IN (
    SELECT id FROM employees AS budg
    WHERE budg.id = empl.id
);


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

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


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

SELECT id FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.type = whs.type
);


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

SELECT id FROM branches AS dept
WHERE type IN (
    SELECT type FROM projects AS prod
    WHERE prod.status = dept.status
);


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

SELECT amount FROM categories AS dept
WHERE level IN (
    SELECT level FROM departments AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT name FROM shipments AS lne
WHERE type IN (
    SELECT type FROM regions AS acct
    WHERE acct.level = lne.level
);


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

SELECT name FROM categories AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS cust
    WHERE cust.status = dept.status
);


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

SELECT amount FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.level = acct.level
);


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

SELECT name FROM products AS empl
WHERE amount > (
    SELECT SUM(value) FROM warehouses AS lne
    WHERE lne.code = empl.code
);


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

SELECT value FROM categories AS ord
WHERE level IN (
    SELECT level FROM orders AS shp
    WHERE shp.type = ord.type
);


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

SELECT code FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = srvc.type
);


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

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


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

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


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.status = prod.status
);


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

SELECT value FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.id = srvc.id
);


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

SELECT value FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.level = mgr.level
);


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

SELECT name FROM orders AS lne
WHERE type IN (
    SELECT type FROM branches AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT name FROM categories AS ordr
WHERE level IN (
    SELECT level FROM customers AS empl
    WHERE empl.type = ordr.type
);


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

SELECT value FROM accounts AS sale
WHERE type IN (
    SELECT type FROM products AS txn
    WHERE txn.type = sale.type
);


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

SELECT code FROM departments AS acct
WHERE salary > (
    SELECT COUNT(value) FROM regions AS sale
    WHERE sale.status = acct.status
);


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

SELECT code FROM employees AS srvc
WHERE amount > (
    SELECT SUM(amount) FROM transactions AS sale
    WHERE sale.type = srvc.type
);


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

SELECT id FROM suppliers AS shp
WHERE level IN (
    SELECT level FROM customers AS sale
    WHERE sale.status = shp.status
);


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

SELECT code FROM projects AS emp
WHERE amount > (
    SELECT AVG(value) FROM orders AS acct
    WHERE acct.code = emp.code
);


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

SELECT amount FROM transactions AS txn
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS prod
    WHERE prod.code = txn.code
);


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

SELECT code FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.code = shp.code
);


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

SELECT amount FROM transactions AS mgr
WHERE code IN (
    SELECT code FROM suppliers AS budg
    WHERE budg.status = mgr.status
);


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

SELECT salary FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.level = prod.level
);


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

SELECT code FROM branches AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS emp
    WHERE emp.status = mgr.status
);


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

SELECT salary FROM accounts AS emp
WHERE id IN (
    SELECT id FROM branches AS empl
    WHERE empl.type = emp.type
);


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

SELECT code FROM suppliers AS shp
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS catg
    WHERE catg.type = shp.type
);


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

SELECT value FROM branches AS rgn
WHERE level IN (
    SELECT level FROM invoices AS prod
    WHERE prod.status = rgn.status
);


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

SELECT salary FROM accounts AS shp
WHERE amount > (
    SELECT MIN(value) FROM transactions AS schd
    WHERE schd.id = shp.id
);


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

SELECT amount FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.level = txn.level
);


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

SELECT code FROM branches AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS schd
    WHERE schd.code = ordr.code
);


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

SELECT id FROM branches AS inv
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS ordr
    WHERE ordr.type = inv.type
);


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

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


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

SELECT salary FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = catg.status
);


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

SELECT id FROM accounts AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS whs
    WHERE whs.code = sale.code
);


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

SELECT name FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.id = whs.id
);


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

SELECT name FROM products AS ordr
WHERE salary > (
    SELECT MIN(value) FROM regions AS whs
    WHERE whs.status = ordr.status
);


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

SELECT code FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.type = budg.type
);


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

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


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

SELECT amount FROM branches AS acct
WHERE level IN (
    SELECT level FROM transactions AS emp
    WHERE emp.status = acct.status
);


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

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


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

SELECT code FROM customers AS inv
WHERE salary > (
    SELECT MIN(value) FROM invoices AS mgr
    WHERE mgr.status = inv.status
);


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

SELECT code FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.status = cust.status
);


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

SELECT value FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.code = srvc.code
);


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

SELECT salary FROM regions AS ord
WHERE salary > (
    SELECT SUM(amount) FROM projects AS schd
    WHERE schd.code = ord.code
);


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

SELECT id FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.type = emp.type
);


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

SELECT code FROM departments AS lne
WHERE level IN (
    SELECT level FROM warehouses AS rgn
    WHERE rgn.code = lne.code
);


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

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


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

SELECT value FROM employees AS lne
WHERE code IN (
    SELECT code FROM projects AS inv
    WHERE inv.level = lne.level
);


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

SELECT salary FROM invoices AS srvc
WHERE code IN (
    SELECT code FROM tasks AS sale
    WHERE sale.id = srvc.id
);


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

SELECT name FROM warehouses AS lne
WHERE amount > (
    SELECT AVG(value) FROM customers AS ord
    WHERE ord.status = lne.status
);


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

SELECT name FROM transactions AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS empl
    WHERE empl.type = dept.type
);


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

SELECT name FROM branches AS budg
WHERE level IN (
    SELECT level FROM employees AS txn
    WHERE txn.code = budg.code
);


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

SELECT amount FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.status = mgr.status
);


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

SELECT name FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.level = acct.level
);


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

SELECT code FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.level = acct.level
);


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

SELECT id FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.code = emp.code
);


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

SELECT salary FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.level = txn.level
);


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

SELECT value FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.type = budg.type
);


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

SELECT salary FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.level = inv.level
);


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

SELECT code FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.code = lne.code
);


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

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


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

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


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

SELECT name FROM projects AS sale
WHERE amount > (
    SELECT MAX(value) FROM branches AS cust
    WHERE cust.status = sale.status
);


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

SELECT code FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.id = sale.id
);


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

SELECT id FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT salary FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.type = prod.type
);


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

SELECT salary FROM employees AS shp
WHERE code IN (
    SELECT code FROM warehouses AS cust
    WHERE cust.status = shp.status
);


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

SELECT amount FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.status = catg.status
);


Prompt:
Schema:
  suppliers (alias: whs)(name, id, status, type)
  warehouses(name, status, amount, date)
Task: Retrieve amount from suppliers with amount above the COUNT(amount) of warehouses rows sharing the same level.
SQL:

SELECT amount FROM suppliers AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM warehouses AS prod
    WHERE prod.level = whs.level
);


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

SELECT value FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.id = ordr.id
);


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

SELECT salary FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.type = ord.type
);


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

SELECT value FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT code FROM transactions AS empl
WHERE type IN (
    SELECT type FROM shipments AS schd
    WHERE schd.type = empl.type
);


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

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


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

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


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

SELECT value FROM products AS emp
WHERE value > (
    SELECT AVG(salary) FROM customers AS budg
    WHERE budg.id = emp.id
);


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

SELECT salary FROM customers AS budg
WHERE code IN (
    SELECT code FROM categories AS cust
    WHERE cust.status = budg.status
);


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

SELECT code FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT value FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.status = sale.status
);


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

SELECT amount FROM transactions AS empl
WHERE level IN (
    SELECT level FROM branches AS cust
    WHERE cust.level = empl.level
);


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

SELECT salary FROM products AS inv
WHERE value > (
    SELECT MAX(salary) FROM departments AS prod
    WHERE prod.code = inv.code
);


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

SELECT salary FROM invoices AS sale
WHERE level IN (
    SELECT level FROM categories AS whs
    WHERE whs.type = sale.type
);


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

SELECT name FROM transactions AS inv
WHERE salary > (
    SELECT SUM(salary) FROM products AS dept
    WHERE dept.id = inv.id
);


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

SELECT salary FROM categories AS srvc
WHERE type IN (
    SELECT type FROM customers AS empl
    WHERE empl.type = srvc.type
);


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

SELECT salary FROM transactions AS budg
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS ord
    WHERE ord.id = budg.id
);


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

SELECT id FROM suppliers AS shp
WHERE salary > (
    SELECT MIN(value) FROM invoices AS cust
    WHERE cust.status = shp.status
);


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

SELECT name FROM employees AS whs
WHERE status IN (
    SELECT status FROM warehouses AS lne
    WHERE lne.level = whs.level
);


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

SELECT id FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT salary FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.level = shp.level
);


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

SELECT salary FROM orders AS inv
WHERE salary > (
    SELECT MAX(value) FROM departments AS budg
    WHERE budg.id = inv.id
);


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

SELECT amount FROM departments AS ordr
WHERE type IN (
    SELECT type FROM transactions AS whs
    WHERE whs.type = ordr.type
);


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

SELECT id FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.type = shp.type
);


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

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


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

SELECT salary FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.level = ordr.level
);


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

SELECT id FROM branches AS whs
WHERE level IN (
    SELECT level FROM employees AS empl
    WHERE empl.level = whs.level
);


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

SELECT amount FROM customers AS schd
WHERE level IN (
    SELECT level FROM warehouses AS cust
    WHERE cust.level = schd.level
);


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

SELECT salary FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.level = lne.level
);


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

SELECT code FROM products AS ord
WHERE status IN (
    SELECT status FROM shipments AS acct
    WHERE acct.type = ord.type
);


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

SELECT code FROM categories AS prod
WHERE value > (
    SELECT MIN(amount) FROM orders AS inv
    WHERE inv.type = prod.type
);


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

SELECT name FROM warehouses AS budg
WHERE code IN (
    SELECT code FROM projects AS emp
    WHERE emp.level = budg.level
);


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

SELECT id FROM categories AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM products AS catg
    WHERE catg.type = srvc.type
);


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

SELECT value FROM branches AS mgr
WHERE id IN (
    SELECT id FROM regions AS schd
    WHERE schd.id = mgr.id
);


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

SELECT code FROM invoices AS prod
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS inv
    WHERE inv.status = prod.status
);


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

SELECT name FROM invoices AS mgr
WHERE level IN (
    SELECT level FROM employees AS cust
    WHERE cust.code = mgr.code
);


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

SELECT value FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.level = acct.level
);


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

SELECT amount FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.type = acct.type
);


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

SELECT value FROM employees AS schd
WHERE id IN (
    SELECT id FROM categories AS dept
    WHERE dept.code = schd.code
);


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT AVG(salary) FROM tasks AS whs
    WHERE whs.level = catg.level
);


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

SELECT id FROM shipments AS empl
WHERE id IN (
    SELECT id FROM warehouses AS sale
    WHERE sale.type = empl.type
);


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

SELECT id FROM shipments AS budg
WHERE amount > (
    SELECT MAX(value) FROM accounts AS shp
    WHERE shp.type = budg.type
);


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

SELECT salary FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT code FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.id = sale.id
);


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

SELECT name FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.type = ord.type
);


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

SELECT value FROM transactions AS txn
WHERE id IN (
    SELECT id FROM accounts AS budg
    WHERE budg.type = txn.type
);


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

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


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

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


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

SELECT code FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = empl.level
);


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

SELECT salary FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = srvc.type
);


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

SELECT salary FROM accounts AS prod
WHERE level IN (
    SELECT level FROM transactions AS ord
    WHERE ord.code = prod.code
);


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.level = empl.level
);


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

SELECT id FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.type = ordr.type
);


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

SELECT code FROM departments AS lne
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS inv
    WHERE inv.status = lne.status
);


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

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


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

SELECT code FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.status = budg.status
);


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

SELECT amount FROM accounts AS budg
WHERE value > (
    SELECT COUNT(value) FROM transactions AS dept
    WHERE dept.code = budg.code
);


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

SELECT amount FROM invoices AS lne
WHERE amount > (
    SELECT SUM(amount) FROM projects AS shp
    WHERE shp.code = lne.code
);


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

SELECT code FROM departments AS sale
WHERE value > (
    SELECT SUM(amount) FROM branches AS inv
    WHERE inv.id = sale.id
);


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

SELECT salary FROM customers AS lne
WHERE amount > (
    SELECT MIN(salary) FROM orders AS acct
    WHERE acct.level = lne.level
);


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

SELECT value FROM tasks AS ord
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS acct
    WHERE acct.id = ord.id
);


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

SELECT name FROM customers AS ord
WHERE salary > (
    SELECT COUNT(value) FROM orders AS emp
    WHERE emp.type = ord.type
);


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

SELECT salary FROM orders AS budg
WHERE id IN (
    SELECT id FROM employees AS sale
    WHERE sale.type = budg.type
);


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

SELECT code FROM invoices AS txn
WHERE code IN (
    SELECT code FROM suppliers AS acct
    WHERE acct.code = txn.code
);


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

SELECT id FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.type = prod.type
);


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

SELECT name FROM accounts AS catg
WHERE salary > (
    SELECT AVG(amount) FROM projects AS sale
    WHERE sale.level = catg.level
);


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT id FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.level = catg.level
);


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

SELECT salary FROM accounts AS catg
WHERE amount > (
    SELECT AVG(salary) FROM orders AS lne
    WHERE lne.status = catg.status
);


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

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


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

SELECT value FROM tasks AS emp
WHERE level IN (
    SELECT level FROM suppliers AS cust
    WHERE cust.code = emp.code
);


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

SELECT amount FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.level = ordr.level
);


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

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


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

SELECT id FROM orders AS cust
WHERE salary > (
    SELECT SUM(value) FROM tasks AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT salary FROM departments AS ordr
WHERE status IN (
    SELECT status FROM employees AS empl
    WHERE empl.type = ordr.type
);


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

SELECT salary FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.id = budg.id
);


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

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


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

SELECT name FROM warehouses AS dept
WHERE type IN (
    SELECT type FROM products AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT name FROM orders AS schd
WHERE id IN (
    SELECT id FROM departments AS acct
    WHERE acct.level = schd.level
);


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

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


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

SELECT code FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.level = srvc.level
);


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

SELECT value FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.status = budg.status
);


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

SELECT amount FROM warehouses AS cust
WHERE value > (
    SELECT AVG(value) FROM invoices AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT value FROM departments AS prod
WHERE type IN (
    SELECT type FROM regions AS catg
    WHERE catg.id = prod.id
);


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

SELECT salary FROM shipments AS budg
WHERE salary > (
    SELECT COUNT(amount) FROM products AS sale
    WHERE sale.level = budg.level
);


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

SELECT name FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.code = lne.code
);


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

SELECT name FROM products AS whs
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS txn
    WHERE txn.type = whs.type
);


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

SELECT id FROM regions AS empl
WHERE value > (
    SELECT MIN(salary) FROM tasks AS whs
    WHERE whs.level = empl.level
);


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

SELECT code FROM categories AS budg
WHERE value > (
    SELECT MIN(salary) FROM suppliers AS prod
    WHERE prod.code = budg.code
);


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

SELECT amount FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.code = inv.code
);


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

SELECT code FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.code = catg.code
);


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

SELECT id FROM branches AS sale
WHERE code IN (
    SELECT code FROM accounts AS budg
    WHERE budg.type = sale.type
);


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

SELECT code FROM regions AS sale
WHERE id IN (
    SELECT id FROM categories AS empl
    WHERE empl.status = sale.status
);


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

SELECT name FROM warehouses AS whs
WHERE salary > (
    SELECT MIN(value) FROM customers AS catg
    WHERE catg.type = whs.type
);


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

SELECT salary FROM tasks AS srvc
WHERE code IN (
    SELECT code FROM branches AS schd
    WHERE schd.code = srvc.code
);


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

SELECT amount FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.level = sale.level
);


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

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


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

SELECT salary FROM categories AS lne
WHERE type IN (
    SELECT type FROM tasks AS emp
    WHERE emp.level = lne.level
);


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

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


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

SELECT id FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = cust.status
);


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

SELECT salary FROM shipments AS rgn
WHERE status IN (
    SELECT status FROM orders AS lne
    WHERE lne.level = rgn.level
);


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

SELECT code FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.status = budg.status
);


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

SELECT code FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.code = budg.code
);


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

SELECT code FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.status = catg.status
);


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

SELECT id FROM suppliers AS mgr
WHERE value > (
    SELECT SUM(value) FROM warehouses AS empl
    WHERE empl.level = mgr.level
);


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

SELECT value FROM tasks AS emp
WHERE amount > (
    SELECT MAX(salary) FROM categories AS prod
    WHERE prod.level = emp.level
);


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

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


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

SELECT code FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.level = mgr.level
);


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

SELECT value FROM categories AS schd
WHERE amount > (
    SELECT COUNT(value) FROM projects AS sale
    WHERE sale.status = schd.status
);


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

SELECT amount FROM suppliers AS shp
WHERE code IN (
    SELECT code FROM transactions AS catg
    WHERE catg.type = shp.type
);


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

SELECT code FROM branches AS shp
WHERE level IN (
    SELECT level FROM shipments AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT code FROM tasks AS ordr
WHERE level IN (
    SELECT level FROM shipments AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT value FROM warehouses AS rgn
WHERE level IN (
    SELECT level FROM departments AS cust
    WHERE cust.code = rgn.code
);


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

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


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

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


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

SELECT value FROM tasks AS inv
WHERE amount > (
    SELECT SUM(value) FROM branches AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT code FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.id = acct.id
);


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

SELECT name FROM orders AS rgn
WHERE id IN (
    SELECT id FROM suppliers AS acct
    WHERE acct.status = rgn.status
);


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

SELECT code FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.code = dept.code
);


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

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


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

SELECT name FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.type = budg.type
);


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

SELECT amount FROM regions AS catg
WHERE salary > (
    SELECT MAX(value) FROM branches AS inv
    WHERE inv.status = catg.status
);


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

SELECT value FROM categories AS empl
WHERE code IN (
    SELECT code FROM employees AS ordr
    WHERE ordr.code = empl.code
);


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

SELECT value FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.id = catg.id
);


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

SELECT name FROM categories AS whs
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS prod
    WHERE prod.id = whs.id
);


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

SELECT name FROM suppliers AS ordr
WHERE id IN (
    SELECT id FROM regions AS inv
    WHERE inv.level = ordr.level
);


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

SELECT amount FROM projects AS whs
WHERE salary > (
    SELECT COUNT(amount) FROM products AS ord
    WHERE ord.id = whs.id
);


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

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


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

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


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

SELECT code FROM categories AS cust
WHERE level IN (
    SELECT level FROM accounts AS catg
    WHERE catg.status = cust.status
);


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

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


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

SELECT value FROM branches AS ordr
WHERE salary > (
    SELECT MIN(value) FROM regions AS acct
    WHERE acct.id = ordr.id
);


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

SELECT id FROM categories AS ord
WHERE salary > (
    SELECT MIN(value) FROM shipments AS sale
    WHERE sale.level = ord.level
);


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

SELECT value FROM invoices AS emp
WHERE id IN (
    SELECT id FROM tasks AS dept
    WHERE dept.status = emp.status
);


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

SELECT value FROM shipments AS budg
WHERE id IN (
    SELECT id FROM warehouses AS schd
    WHERE schd.code = budg.code
);


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

SELECT name FROM departments AS txn
WHERE status IN (
    SELECT status FROM shipments AS ord
    WHERE ord.level = txn.level
);


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

SELECT salary FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.id = acct.id
);


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

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


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

SELECT name FROM tasks AS emp
WHERE value > (
    SELECT MIN(amount) FROM transactions AS lne
    WHERE lne.level = emp.level
);


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

SELECT amount FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT amount FROM shipments AS whs
WHERE level IN (
    SELECT level FROM products AS dept
    WHERE dept.status = whs.status
);


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

SELECT salary FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT salary FROM regions AS rgn
WHERE type IN (
    SELECT type FROM products AS dept
    WHERE dept.status = rgn.status
);


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

SELECT code FROM employees AS budg
WHERE value > (
    SELECT MIN(value) FROM shipments AS sale
    WHERE sale.code = budg.code
);


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

SELECT salary FROM categories AS mgr
WHERE level IN (
    SELECT level FROM regions AS empl
    WHERE empl.code = mgr.code
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.id = emp.id
);


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

SELECT code FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.type = srvc.type
);


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

SELECT value FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = shp.level
);


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

SELECT id FROM products AS lne
WHERE level IN (
    SELECT level FROM transactions AS schd
    WHERE schd.level = lne.level
);


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

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


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

SELECT name FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.id = acct.id
);


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

SELECT code FROM suppliers AS ord
WHERE value > (
    SELECT AVG(salary) FROM projects AS catg
    WHERE catg.level = ord.level
);


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

SELECT value FROM accounts AS txn
WHERE code IN (
    SELECT code FROM departments AS budg
    WHERE budg.code = txn.code
);


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

SELECT salary FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.id = ordr.id
);


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

SELECT name FROM categories AS emp
WHERE id IN (
    SELECT id FROM tasks AS inv
    WHERE inv.id = emp.id
);


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.type = whs.type
);


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

SELECT value FROM accounts AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS sale
    WHERE sale.code = ordr.code
);


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

SELECT amount FROM accounts AS ord
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS schd
    WHERE schd.code = ord.code
);


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

SELECT code FROM warehouses AS whs
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS shp
    WHERE shp.type = whs.type
);


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

SELECT value FROM tasks AS empl
WHERE amount > (
    SELECT SUM(salary) FROM departments AS schd
    WHERE schd.type = empl.type
);


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

SELECT code FROM categories AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM tasks AS shp
    WHERE shp.type = ord.type
);


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

SELECT value FROM branches AS whs
WHERE level IN (
    SELECT level FROM projects AS schd
    WHERE schd.id = whs.id
);


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

SELECT id FROM projects AS shp
WHERE amount > (
    SELECT AVG(salary) FROM categories AS budg
    WHERE budg.type = shp.type
);


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

SELECT amount FROM shipments AS schd
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS catg
    WHERE catg.level = schd.level
);


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

SELECT salary FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT value FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT code FROM transactions AS empl
WHERE status IN (
    SELECT status FROM projects AS budg
    WHERE budg.type = empl.type
);


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

SELECT value FROM orders AS dept
WHERE value > (
    SELECT COUNT(amount) FROM warehouses AS rgn
    WHERE rgn.level = dept.level
);


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

SELECT name FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT amount FROM invoices AS prod
WHERE amount > (
    SELECT SUM(amount) FROM projects AS cust
    WHERE cust.status = prod.status
);


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

SELECT value FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT id FROM transactions AS emp
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS whs
    WHERE whs.id = emp.id
);


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

SELECT name FROM invoices AS mgr
WHERE status IN (
    SELECT status FROM branches AS emp
    WHERE emp.id = mgr.id
);


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

SELECT code FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.type = empl.type
);


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

SELECT id FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.code = lne.code
);


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

SELECT salary FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.status = acct.status
);


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

SELECT code FROM suppliers AS rgn
WHERE code IN (
    SELECT code FROM accounts AS shp
    WHERE shp.id = rgn.id
);


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

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


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

SELECT value FROM transactions AS lne
WHERE status IN (
    SELECT status FROM invoices AS empl
    WHERE empl.level = lne.level
);


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

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


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

SELECT amount FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.id = prod.id
);


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

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