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

SELECT value FROM projects AS emp
WHERE code IN (
    SELECT code FROM shipments AS prod
    WHERE prod.type = emp.type
);


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

SELECT amount FROM tasks AS lne
WHERE value > (
    SELECT COUNT(salary) FROM regions AS empl
    WHERE empl.id = lne.id
);


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

SELECT name FROM departments AS dept
WHERE value > (
    SELECT MAX(amount) FROM products AS txn
    WHERE txn.type = dept.type
);


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

SELECT amount FROM branches AS inv
WHERE level IN (
    SELECT level FROM accounts AS sale
    WHERE sale.type = inv.type
);


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

SELECT id FROM transactions AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS catg
    WHERE catg.code = rgn.code
);


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

SELECT amount FROM categories AS lne
WHERE status IN (
    SELECT status FROM orders AS ord
    WHERE ord.id = lne.id
);


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

SELECT value FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.status = budg.status
);


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

SELECT value FROM shipments AS catg
WHERE value > (
    SELECT MIN(salary) FROM regions AS lne
    WHERE lne.status = catg.status
);


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

SELECT name FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.code = schd.code
);


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

SELECT salary FROM employees AS budg
WHERE amount > (
    SELECT MAX(salary) FROM regions AS emp
    WHERE emp.code = budg.code
);


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

SELECT value FROM customers AS txn
WHERE value > (
    SELECT SUM(value) FROM orders AS inv
    WHERE inv.code = txn.code
);


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

SELECT code FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.id = empl.id
);


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

SELECT name FROM departments AS prod
WHERE level IN (
    SELECT level FROM suppliers AS ord
    WHERE ord.type = prod.type
);


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

SELECT amount FROM accounts AS txn
WHERE type IN (
    SELECT type FROM employees AS rgn
    WHERE rgn.id = txn.id
);


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

SELECT value FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.code = acct.code
);


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

SELECT value FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM projects AS empl
    WHERE empl.level = ordr.level
);


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

SELECT id FROM regions AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS catg
    WHERE catg.type = ordr.type
);


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

SELECT name FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.level = emp.level
);


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

SELECT value FROM products AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS schd
    WHERE schd.status = shp.status
);


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

SELECT name FROM departments AS ord
WHERE level IN (
    SELECT level FROM categories AS dept
    WHERE dept.id = ord.id
);


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

SELECT salary FROM branches AS rgn
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.level = rgn.level
);


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

SELECT id FROM projects AS lne
WHERE status IN (
    SELECT status FROM tasks AS cust
    WHERE cust.level = lne.level
);


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

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


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

SELECT name FROM products AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM shipments AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT salary FROM shipments AS inv
WHERE level IN (
    SELECT level FROM products AS emp
    WHERE emp.type = inv.type
);


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

SELECT name FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.level = lne.level
);


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

SELECT code FROM orders AS dept
WHERE salary > (
    SELECT AVG(salary) FROM branches AS schd
    WHERE schd.type = dept.type
);


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

SELECT code FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.code = ordr.code
);


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

SELECT code FROM products AS catg
WHERE amount > (
    SELECT AVG(salary) FROM warehouses AS budg
    WHERE budg.id = catg.id
);


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

SELECT amount FROM tasks AS budg
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT id FROM customers AS srvc
WHERE amount > (
    SELECT SUM(value) FROM transactions AS cust
    WHERE cust.code = srvc.code
);


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

SELECT salary FROM suppliers AS whs
WHERE type IN (
    SELECT type FROM warehouses AS acct
    WHERE acct.type = whs.type
);


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

SELECT id FROM transactions AS catg
WHERE type IN (
    SELECT type FROM warehouses AS sale
    WHERE sale.id = catg.id
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.level = inv.level
);


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

SELECT amount FROM invoices AS mgr
WHERE value > (
    SELECT MAX(amount) FROM orders AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT name FROM transactions AS mgr
WHERE status IN (
    SELECT status FROM invoices AS ord
    WHERE ord.status = mgr.status
);


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

SELECT salary FROM tasks AS budg
WHERE level IN (
    SELECT level FROM accounts AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT id FROM customers AS whs
WHERE type IN (
    SELECT type FROM orders AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT salary FROM employees AS mgr
WHERE amount > (
    SELECT SUM(amount) FROM categories AS lne
    WHERE lne.status = mgr.status
);


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

SELECT name FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.status = catg.status
);


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

SELECT name FROM projects AS srvc
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS budg
    WHERE budg.level = srvc.level
);


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

SELECT name FROM shipments AS sale
WHERE type IN (
    SELECT type FROM orders AS schd
    WHERE schd.code = sale.code
);


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

SELECT amount FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.type = cust.type
);


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

SELECT salary FROM shipments AS rgn
WHERE amount > (
    SELECT SUM(amount) FROM regions AS acct
    WHERE acct.level = rgn.level
);


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

SELECT name FROM products AS mgr
WHERE level IN (
    SELECT level FROM branches AS cust
    WHERE cust.level = mgr.level
);


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

SELECT code FROM accounts AS ord
WHERE id IN (
    SELECT id FROM shipments AS catg
    WHERE catg.code = ord.code
);


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

SELECT salary FROM transactions AS catg
WHERE id IN (
    SELECT id FROM categories AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT id FROM invoices AS whs
WHERE code IN (
    SELECT code FROM suppliers AS ordr
    WHERE ordr.code = whs.code
);


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

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


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

SELECT amount FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.level = dept.level
);


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

SELECT name FROM warehouses AS empl
WHERE id IN (
    SELECT id FROM tasks AS acct
    WHERE acct.status = empl.status
);


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

SELECT value FROM tasks AS budg
WHERE code IN (
    SELECT code FROM categories AS ordr
    WHERE ordr.level = budg.level
);


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

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


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

SELECT id FROM orders AS srvc
WHERE salary > (
    SELECT SUM(value) FROM regions AS shp
    WHERE shp.code = srvc.code
);


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

SELECT salary FROM shipments AS emp
WHERE id IN (
    SELECT id FROM accounts AS lne
    WHERE lne.level = emp.level
);


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

SELECT id FROM suppliers AS srvc
WHERE type IN (
    SELECT type FROM regions AS prod
    WHERE prod.id = srvc.id
);


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

SELECT code FROM departments AS mgr
WHERE type IN (
    SELECT type FROM categories AS srvc
    WHERE srvc.id = mgr.id
);


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

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


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

SELECT value FROM branches AS txn
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.status = txn.status
);


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

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


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

SELECT amount FROM orders AS budg
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS prod
    WHERE prod.status = budg.status
);


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

SELECT salary FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.type = emp.type
);


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

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


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

SELECT amount FROM suppliers AS prod
WHERE level IN (
    SELECT level FROM accounts AS empl
    WHERE empl.level = prod.level
);


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

SELECT name FROM orders AS ordr
WHERE id IN (
    SELECT id FROM projects AS dept
    WHERE dept.type = ordr.type
);


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

SELECT amount FROM branches AS emp
WHERE status IN (
    SELECT status FROM transactions AS dept
    WHERE dept.type = emp.type
);


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

SELECT name FROM departments AS prod
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS lne
    WHERE lne.level = prod.level
);


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

SELECT value FROM tasks AS lne
WHERE type IN (
    SELECT type FROM shipments AS shp
    WHERE shp.code = lne.code
);


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

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM tasks AS acct
    WHERE acct.id = cust.id
);


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

SELECT name FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.id = catg.id
);


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

SELECT amount FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.level = srvc.level
);


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

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


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

SELECT code FROM projects AS dept
WHERE code IN (
    SELECT code FROM suppliers AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT name FROM branches AS srvc
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.level = srvc.level
);


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

SELECT salary FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.status = lne.status
);


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

SELECT value FROM departments AS schd
WHERE amount > (
    SELECT COUNT(value) FROM regions AS catg
    WHERE catg.id = schd.id
);


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

SELECT salary FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.status = acct.status
);


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

SELECT name FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.status = ord.status
);


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

SELECT id FROM orders AS schd
WHERE id IN (
    SELECT id FROM warehouses AS shp
    WHERE shp.code = schd.code
);


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

SELECT name FROM accounts AS dept
WHERE id IN (
    SELECT id FROM branches AS catg
    WHERE catg.level = dept.level
);


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

SELECT salary FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.code = inv.code
);


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

SELECT code FROM accounts AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM regions AS shp
    WHERE shp.type = ordr.type
);


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

SELECT name FROM categories AS srvc
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.code = srvc.code
);


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

SELECT id FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.level = catg.level
);


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

SELECT salary FROM invoices AS shp
WHERE salary > (
    SELECT MIN(value) FROM branches AS schd
    WHERE schd.type = shp.type
);


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

SELECT id FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT salary FROM regions AS whs
WHERE id IN (
    SELECT id FROM suppliers AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT code FROM warehouses AS whs
WHERE amount > (
    SELECT AVG(amount) FROM categories AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT value FROM invoices AS schd
WHERE salary > (
    SELECT MAX(salary) FROM employees AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT salary FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.level = acct.level
);


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

SELECT code FROM suppliers AS shp
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS prod
    WHERE prod.code = shp.code
);


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

SELECT code FROM customers AS ordr
WHERE status IN (
    SELECT status FROM regions AS budg
    WHERE budg.code = ordr.code
);


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

SELECT id FROM employees AS mgr
WHERE level IN (
    SELECT level FROM transactions AS cust
    WHERE cust.level = mgr.level
);


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

SELECT code FROM customers AS schd
WHERE id IN (
    SELECT id FROM products AS txn
    WHERE txn.code = schd.code
);


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

SELECT code FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.level = ord.level
);


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

SELECT value FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.type = empl.type
);


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

SELECT value FROM orders AS ordr
WHERE level IN (
    SELECT level FROM customers AS acct
    WHERE acct.id = ordr.id
);


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

SELECT id FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.id = shp.id
);


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

SELECT value FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.code = emp.code
);


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

SELECT value FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.level = mgr.level
);


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

SELECT amount FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT salary FROM accounts AS shp
WHERE level IN (
    SELECT level FROM tasks AS whs
    WHERE whs.status = shp.status
);


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

SELECT salary FROM categories AS ordr
WHERE level IN (
    SELECT level FROM products AS empl
    WHERE empl.type = ordr.type
);


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

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


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

SELECT code FROM categories AS budg
WHERE id IN (
    SELECT id FROM products AS whs
    WHERE whs.type = budg.type
);


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

SELECT name FROM departments AS lne
WHERE level IN (
    SELECT level FROM orders AS shp
    WHERE shp.id = lne.id
);


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

SELECT name FROM categories AS dept
WHERE status IN (
    SELECT status FROM suppliers AS budg
    WHERE budg.status = dept.status
);


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

SELECT code FROM accounts AS sale
WHERE code IN (
    SELECT code FROM categories AS inv
    WHERE inv.status = sale.status
);


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

SELECT amount FROM projects AS prod
WHERE id IN (
    SELECT id FROM categories AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT id FROM customers AS txn
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS schd
    WHERE schd.code = txn.code
);


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

SELECT value FROM products AS emp
WHERE status IN (
    SELECT status FROM warehouses AS catg
    WHERE catg.type = emp.type
);


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

SELECT amount FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.status = lne.status
);


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

SELECT code FROM employees AS prod
WHERE type IN (
    SELECT type FROM regions AS lne
    WHERE lne.level = prod.level
);


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

SELECT id FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.level = inv.level
);


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

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


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

SELECT code FROM warehouses AS budg
WHERE salary > (
    SELECT MIN(salary) FROM projects AS whs
    WHERE whs.type = budg.type
);


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

SELECT amount FROM categories AS lne
WHERE value > (
    SELECT AVG(value) FROM departments AS budg
    WHERE budg.id = lne.id
);


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

SELECT salary FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.type = sale.type
);


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

SELECT salary FROM transactions AS rgn
WHERE value > (
    SELECT SUM(value) FROM regions AS inv
    WHERE inv.level = rgn.level
);


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

SELECT code FROM orders AS rgn
WHERE type IN (
    SELECT type FROM shipments AS prod
    WHERE prod.id = rgn.id
);


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

SELECT value FROM branches AS srvc
WHERE value > (
    SELECT SUM(value) FROM suppliers AS lne
    WHERE lne.type = srvc.type
);


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

SELECT amount FROM orders AS sale
WHERE id IN (
    SELECT id FROM employees AS acct
    WHERE acct.level = sale.level
);


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

SELECT name FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.code = ord.code
);


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

SELECT name FROM employees AS mgr
WHERE id IN (
    SELECT id FROM accounts AS shp
    WHERE shp.id = mgr.id
);


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

SELECT salary FROM categories AS catg
WHERE status IN (
    SELECT status FROM suppliers AS schd
    WHERE schd.type = catg.type
);


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

SELECT amount FROM categories AS whs
WHERE salary > (
    SELECT MIN(amount) FROM projects AS prod
    WHERE prod.level = whs.level
);


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

SELECT salary FROM branches AS prod
WHERE level IN (
    SELECT level FROM customers AS budg
    WHERE budg.status = prod.status
);


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

SELECT amount FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM categories AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT amount FROM regions AS inv
WHERE value > (
    SELECT COUNT(salary) FROM branches AS budg
    WHERE budg.id = inv.id
);


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

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


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

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


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

SELECT value FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.code = emp.code
);


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

SELECT value FROM employees AS lne
WHERE level IN (
    SELECT level FROM categories AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT name FROM regions AS ord
WHERE id IN (
    SELECT id FROM warehouses AS budg
    WHERE budg.type = ord.type
);


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

SELECT name FROM regions AS acct
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.level = acct.level
);


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

SELECT name FROM regions AS lne
WHERE code IN (
    SELECT code FROM departments AS schd
    WHERE schd.level = lne.level
);


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

SELECT name FROM shipments AS lne
WHERE code IN (
    SELECT code FROM categories AS sale
    WHERE sale.type = lne.type
);


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

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


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

SELECT value FROM categories AS shp
WHERE id IN (
    SELECT id FROM customers AS dept
    WHERE dept.status = shp.status
);


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

SELECT amount FROM invoices AS prod
WHERE amount > (
    SELECT MIN(value) FROM transactions AS emp
    WHERE emp.level = prod.level
);


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

SELECT amount FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = prod.code
);


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

SELECT value FROM categories AS dept
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS ord
    WHERE ord.id = dept.id
);


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

SELECT value FROM tasks AS lne
WHERE code IN (
    SELECT code FROM shipments AS acct
    WHERE acct.status = lne.status
);


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

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


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

SELECT name FROM orders AS mgr
WHERE id IN (
    SELECT id FROM accounts AS emp
    WHERE emp.status = mgr.status
);


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

SELECT salary FROM projects AS whs
WHERE status IN (
    SELECT status FROM transactions AS budg
    WHERE budg.id = whs.id
);


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

SELECT id FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM transactions AS shp
    WHERE shp.level = ordr.level
);


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

SELECT id FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = emp.code
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.code = acct.code
);


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

SELECT amount FROM regions AS cust
WHERE status IN (
    SELECT status FROM tasks AS txn
    WHERE txn.level = cust.level
);


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

SELECT salary FROM regions AS lne
WHERE status IN (
    SELECT status FROM accounts AS whs
    WHERE whs.status = lne.status
);


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

SELECT amount FROM transactions AS schd
WHERE code IN (
    SELECT code FROM suppliers AS catg
    WHERE catg.status = schd.status
);


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

SELECT code FROM branches AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS cust
    WHERE cust.id = shp.id
);


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

SELECT salary FROM branches AS inv
WHERE amount > (
    SELECT MIN(amount) FROM projects AS prod
    WHERE prod.id = inv.id
);


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

SELECT salary FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.id = schd.id
);


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

SELECT id FROM accounts AS whs
WHERE level IN (
    SELECT level FROM tasks AS cust
    WHERE cust.code = whs.code
);


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

SELECT salary FROM employees AS ord
WHERE salary > (
    SELECT AVG(value) FROM orders AS inv
    WHERE inv.type = ord.type
);


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

SELECT name FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.type = mgr.type
);


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

SELECT name FROM projects AS dept
WHERE salary > (
    SELECT SUM(salary) FROM transactions AS ord
    WHERE ord.status = dept.status
);


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

SELECT name FROM employees AS srvc
WHERE id IN (
    SELECT id FROM orders AS inv
    WHERE inv.code = srvc.code
);


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

SELECT salary FROM branches AS schd
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS mgr
    WHERE mgr.level = schd.level
);


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

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


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

SELECT salary FROM products AS schd
WHERE value > (
    SELECT SUM(amount) FROM orders AS sale
    WHERE sale.status = schd.status
);


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

SELECT id FROM warehouses AS shp
WHERE type IN (
    SELECT type FROM transactions AS emp
    WHERE emp.code = shp.code
);


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

SELECT name FROM projects AS ordr
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.status = ordr.status
);


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

SELECT value FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.id = cust.id
);


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

SELECT amount FROM categories AS inv
WHERE id IN (
    SELECT id FROM invoices AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT name FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.status = catg.status
);


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

SELECT amount FROM tasks AS shp
WHERE type IN (
    SELECT type FROM shipments AS cust
    WHERE cust.type = shp.type
);


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

SELECT salary FROM accounts AS ord
WHERE level IN (
    SELECT level FROM transactions AS inv
    WHERE inv.status = ord.status
);


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

SELECT code FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.status = dept.status
);


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

SELECT amount FROM employees AS shp
WHERE code IN (
    SELECT code FROM regions AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT amount FROM products AS lne
WHERE code IN (
    SELECT code FROM categories AS whs
    WHERE whs.status = lne.status
);


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

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


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

SELECT name FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.code = emp.code
);


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

SELECT id FROM transactions AS dept
WHERE code IN (
    SELECT code FROM orders AS ord
    WHERE ord.status = dept.status
);


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

SELECT salary FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.code = whs.code
);


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

SELECT amount FROM categories AS empl
WHERE salary > (
    SELECT MIN(value) FROM departments AS whs
    WHERE whs.type = empl.type
);


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

SELECT id FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = shp.status
);


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

SELECT code FROM shipments AS empl
WHERE status IN (
    SELECT status FROM tasks AS prod
    WHERE prod.level = empl.level
);


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

SELECT amount FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.status = txn.status
);


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

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


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

SELECT salary FROM products AS lne
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS shp
    WHERE shp.id = lne.id
);


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

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


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

SELECT id FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.level = txn.level
);


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

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


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

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


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

SELECT id FROM customers AS txn
WHERE level IN (
    SELECT level FROM categories AS budg
    WHERE budg.level = txn.level
);


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

SELECT value FROM invoices AS prod
WHERE status IN (
    SELECT status FROM regions AS whs
    WHERE whs.status = prod.status
);


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

SELECT amount FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.type = schd.type
);


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

SELECT amount FROM accounts AS schd
WHERE amount > (
    SELECT COUNT(value) FROM products AS txn
    WHERE txn.level = schd.level
);


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

SELECT id FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.type = txn.type
);


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

SELECT value FROM shipments AS budg
WHERE type IN (
    SELECT type FROM categories AS rgn
    WHERE rgn.level = budg.level
);


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

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


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

SELECT code FROM tasks AS schd
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS sale
    WHERE sale.type = schd.type
);


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

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


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

SELECT code FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.level = dept.level
);


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

SELECT code FROM projects AS srvc
WHERE value > (
    SELECT MIN(amount) FROM products AS ord
    WHERE ord.status = srvc.status
);


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

SELECT salary FROM regions AS mgr
WHERE value > (
    SELECT COUNT(amount) FROM projects AS acct
    WHERE acct.type = mgr.type
);


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

SELECT salary FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT id FROM accounts AS txn
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS inv
    WHERE inv.status = txn.status
);


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

SELECT name FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.code = empl.code
);


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

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


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

SELECT id FROM transactions AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS lne
    WHERE lne.type = srvc.type
);


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

SELECT value FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.id = dept.id
);


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

SELECT id FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.level = ordr.level
);


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

SELECT salary FROM departments AS catg
WHERE type IN (
    SELECT type FROM accounts AS mgr
    WHERE mgr.status = catg.status
);


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

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


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

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


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

SELECT salary FROM suppliers AS cust
WHERE amount > (
    SELECT MIN(salary) FROM branches AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT salary FROM employees AS srvc
WHERE value > (
    SELECT AVG(salary) FROM accounts AS empl
    WHERE empl.code = srvc.code
);


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

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


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

SELECT name FROM branches AS empl
WHERE value > (
    SELECT MIN(value) FROM warehouses AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT amount FROM orders AS emp
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS dept
    WHERE dept.code = emp.code
);


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

SELECT value FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT salary FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.type = srvc.type
);


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

SELECT name FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT value FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.id = shp.id
);


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

SELECT name FROM invoices AS rgn
WHERE value > (
    SELECT AVG(amount) FROM products AS inv
    WHERE inv.type = rgn.type
);


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

SELECT name FROM accounts AS lne
WHERE salary > (
    SELECT COUNT(amount) FROM products AS budg
    WHERE budg.type = lne.type
);


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

SELECT name FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.code = cust.code
);


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

SELECT name FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.id = ord.id
);


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

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


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

SELECT id FROM regions AS shp
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.status = shp.status
);


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

SELECT code FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = shp.level
);


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

SELECT amount FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT amount FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.status = empl.status
);


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

SELECT amount FROM shipments AS empl
WHERE status IN (
    SELECT status FROM orders AS prod
    WHERE prod.id = empl.id
);


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

SELECT name FROM departments AS shp
WHERE level IN (
    SELECT level FROM invoices AS prod
    WHERE prod.id = shp.id
);


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

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


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

SELECT value FROM products AS lne
WHERE type IN (
    SELECT type FROM shipments AS rgn
    WHERE rgn.code = lne.code
);


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

SELECT code FROM orders AS lne
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS shp
    WHERE shp.status = lne.status
);


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

SELECT id FROM departments AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM warehouses AS acct
    WHERE acct.type = rgn.type
);


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

SELECT amount FROM departments AS rgn
WHERE level IN (
    SELECT level FROM orders AS whs
    WHERE whs.level = rgn.level
);


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

SELECT code FROM warehouses AS lne
WHERE type IN (
    SELECT type FROM transactions AS catg
    WHERE catg.type = lne.type
);


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

SELECT value FROM products AS catg
WHERE id IN (
    SELECT id FROM orders AS budg
    WHERE budg.type = catg.type
);


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

SELECT id FROM customers AS cust
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS catg
    WHERE catg.type = cust.type
);


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

SELECT salary FROM accounts AS rgn
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS dept
    WHERE dept.type = rgn.type
);


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

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


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

SELECT code FROM departments AS schd
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.code = schd.code
);


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

SELECT id FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.level = mgr.level
);


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

SELECT amount FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.type = acct.type
);


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

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


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

SELECT name FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.code = sale.code
);


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

SELECT salary FROM employees AS ordr
WHERE status IN (
    SELECT status FROM regions AS txn
    WHERE txn.level = ordr.level
);


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

SELECT id FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.type = catg.type
);


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

SELECT amount FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.status = ordr.status
);


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

SELECT value FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.level = inv.level
);


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

SELECT name FROM tasks AS sale
WHERE level IN (
    SELECT level FROM orders AS catg
    WHERE catg.code = sale.code
);


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

SELECT value FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.code = prod.code
);


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

SELECT code FROM shipments AS budg
WHERE status IN (
    SELECT status FROM products AS whs
    WHERE whs.level = budg.level
);


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

SELECT name FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.status = acct.status
);


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

SELECT amount FROM tasks AS dept
WHERE type IN (
    SELECT type FROM invoices AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT salary FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.level = inv.level
);


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

SELECT salary FROM orders AS catg
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.status = catg.status
);


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

SELECT id FROM projects AS emp
WHERE type IN (
    SELECT type FROM transactions AS shp
    WHERE shp.type = emp.type
);


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

SELECT salary FROM invoices AS srvc
WHERE value > (
    SELECT AVG(value) FROM categories AS schd
    WHERE schd.status = srvc.status
);


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

SELECT name FROM orders AS dept
WHERE type IN (
    SELECT type FROM regions AS ord
    WHERE ord.level = dept.level
);


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

SELECT value FROM departments AS empl
WHERE value > (
    SELECT MIN(amount) FROM employees AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT name FROM branches AS inv
WHERE amount > (
    SELECT AVG(value) FROM products AS budg
    WHERE budg.level = inv.level
);


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

SELECT code FROM suppliers AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM products AS catg
    WHERE catg.code = srvc.code
);


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

SELECT id FROM regions AS srvc
WHERE status IN (
    SELECT status FROM transactions AS prod
    WHERE prod.code = srvc.code
);


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

SELECT code FROM invoices AS acct
WHERE level IN (
    SELECT level FROM tasks AS empl
    WHERE empl.id = acct.id
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.level = dept.level
);


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

SELECT amount FROM tasks AS catg
WHERE status IN (
    SELECT status FROM orders AS budg
    WHERE budg.id = catg.id
);


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

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


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

SELECT code FROM shipments AS srvc
WHERE salary > (
    SELECT AVG(amount) FROM customers AS budg
    WHERE budg.type = srvc.type
);


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

SELECT code FROM tasks AS lne
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS inv
    WHERE inv.id = lne.id
);


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

SELECT value FROM projects AS empl
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS shp
    WHERE shp.code = empl.code
);


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

SELECT amount FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.level = cust.level
);


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

SELECT salary FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT id FROM projects AS empl
WHERE value > (
    SELECT AVG(value) FROM categories AS sale
    WHERE sale.id = empl.id
);


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

SELECT salary FROM warehouses AS schd
WHERE type IN (
    SELECT type FROM categories AS shp
    WHERE shp.level = schd.level
);


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

SELECT id FROM warehouses AS ordr
WHERE salary > (
    SELECT SUM(value) FROM departments AS schd
    WHERE schd.level = ordr.level
);


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

SELECT amount FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.id = cust.id
);


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

SELECT value FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.level = mgr.level
);


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

SELECT id FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.status = catg.status
);


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

SELECT name FROM transactions AS schd
WHERE status IN (
    SELECT status FROM invoices AS shp
    WHERE shp.type = schd.type
);


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

SELECT name FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.id = whs.id
);


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

SELECT value FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.type = mgr.type
);


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

SELECT name FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT id FROM shipments AS shp
WHERE salary > (
    SELECT SUM(value) FROM warehouses AS cust
    WHERE cust.level = shp.level
);


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

SELECT name FROM categories AS schd
WHERE salary > (
    SELECT SUM(salary) FROM regions AS srvc
    WHERE srvc.code = schd.code
);


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

SELECT name FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.id = rgn.id
);


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

SELECT salary FROM employees AS srvc
WHERE status IN (
    SELECT status FROM products AS cust
    WHERE cust.status = srvc.status
);


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

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


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

SELECT name FROM regions AS sale
WHERE value > (
    SELECT MAX(value) FROM categories AS txn
    WHERE txn.status = sale.status
);


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

SELECT name FROM tasks AS cust
WHERE level IN (
    SELECT level FROM employees AS empl
    WHERE empl.status = cust.status
);


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

SELECT id FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.status = emp.status
);


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

SELECT amount FROM departments AS rgn
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS whs
    WHERE whs.level = rgn.level
);


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

SELECT name FROM tasks AS lne
WHERE status IN (
    SELECT status FROM products AS budg
    WHERE budg.id = lne.id
);


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

SELECT amount FROM orders AS mgr
WHERE code IN (
    SELECT code FROM tasks AS acct
    WHERE acct.type = mgr.type
);


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

SELECT code FROM orders AS dept
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT name FROM projects AS cust
WHERE amount > (
    SELECT AVG(salary) FROM products AS budg
    WHERE budg.type = cust.type
);


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

SELECT code FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.status = empl.status
);