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

SELECT name FROM branches AS cust
WHERE type IN (
    SELECT type FROM shipments AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT salary FROM employees AS budg
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT code FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.type = cust.type
);


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

SELECT name FROM departments AS acct
WHERE salary > (
    SELECT SUM(amount) FROM branches AS budg
    WHERE budg.code = acct.code
);


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

SELECT value FROM customers AS acct
WHERE status IN (
    SELECT status FROM suppliers AS ord
    WHERE ord.status = acct.status
);


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

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


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

SELECT value FROM warehouses AS empl
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.code = empl.code
);


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

SELECT id FROM employees AS shp
WHERE level IN (
    SELECT level FROM orders AS cust
    WHERE cust.code = shp.code
);


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

SELECT salary FROM warehouses AS txn
WHERE level IN (
    SELECT level FROM departments AS rgn
    WHERE rgn.id = txn.id
);


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

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


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

SELECT id FROM shipments AS budg
WHERE salary > (
    SELECT MIN(value) FROM orders AS empl
    WHERE empl.type = budg.type
);


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

SELECT code FROM transactions AS dept
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS srvc
    WHERE srvc.id = dept.id
);


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

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


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

SELECT salary FROM shipments AS ordr
WHERE level IN (
    SELECT level FROM products AS shp
    WHERE shp.code = ordr.code
);


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

SELECT name FROM employees AS sale
WHERE status IN (
    SELECT status FROM warehouses AS inv
    WHERE inv.id = sale.id
);


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

SELECT name FROM customers AS dept
WHERE value > (
    SELECT COUNT(amount) FROM invoices AS catg
    WHERE catg.status = dept.status
);


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

SELECT salary FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.id = mgr.id
);


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

SELECT code FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.status = catg.status
);


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

SELECT value FROM suppliers AS whs
WHERE type IN (
    SELECT type FROM projects AS shp
    WHERE shp.status = whs.status
);


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

SELECT amount FROM invoices AS shp
WHERE code IN (
    SELECT code FROM employees AS catg
    WHERE catg.id = shp.id
);


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

SELECT name FROM tasks AS ord
WHERE value > (
    SELECT SUM(amount) FROM employees AS budg
    WHERE budg.code = ord.code
);


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

SELECT amount FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.level = ordr.level
);


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

SELECT id FROM warehouses AS catg
WHERE code IN (
    SELECT code FROM orders AS inv
    WHERE inv.id = catg.id
);


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

SELECT salary FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.code = empl.code
);


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

SELECT value FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.type = lne.type
);


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

SELECT id FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = sale.status
);


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

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


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

SELECT code FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.code = lne.code
);


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

SELECT code FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.type = catg.type
);


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

SELECT name FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.level = catg.level
);


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

SELECT name FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = empl.type
);


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

SELECT code FROM invoices AS acct
WHERE salary > (
    SELECT MAX(value) FROM categories AS sale
    WHERE sale.id = acct.id
);


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

SELECT name FROM customers AS ord
WHERE code IN (
    SELECT code FROM projects AS inv
    WHERE inv.level = ord.level
);


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

SELECT amount FROM projects AS catg
WHERE status IN (
    SELECT status FROM orders AS acct
    WHERE acct.id = catg.id
);


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

SELECT id FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.id = emp.id
);


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

SELECT amount FROM departments AS lne
WHERE salary > (
    SELECT AVG(value) FROM regions AS budg
    WHERE budg.status = lne.status
);


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

SELECT id FROM shipments AS srvc
WHERE value > (
    SELECT MIN(salary) FROM invoices AS acct
    WHERE acct.code = srvc.code
);


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

SELECT salary FROM categories AS whs
WHERE code IN (
    SELECT code FROM tasks AS prod
    WHERE prod.status = whs.status
);


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

SELECT value FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.level = empl.level
);


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

SELECT amount FROM invoices AS whs
WHERE amount > (
    SELECT MIN(value) FROM tasks AS lne
    WHERE lne.code = whs.code
);


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

SELECT amount FROM accounts AS emp
WHERE salary > (
    SELECT MAX(salary) FROM customers AS cust
    WHERE cust.type = emp.type
);


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

SELECT code FROM customers AS shp
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS mgr
    WHERE mgr.level = shp.level
);


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

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


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

SELECT salary FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.level = emp.level
);


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

SELECT value FROM departments AS prod
WHERE salary > (
    SELECT MAX(value) FROM accounts AS acct
    WHERE acct.id = prod.id
);


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

SELECT salary FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.level = sale.level
);


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

SELECT amount FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.level = lne.level
);


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

SELECT amount FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.type = inv.type
);


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

SELECT value FROM departments AS shp
WHERE level IN (
    SELECT level FROM projects AS catg
    WHERE catg.status = shp.status
);


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

SELECT salary FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.status = inv.status
);


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

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


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

SELECT id FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT salary FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT salary FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT name FROM orders AS ord
WHERE code IN (
    SELECT code FROM projects AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT code FROM branches AS sale
WHERE value > (
    SELECT COUNT(value) FROM regions AS shp
    WHERE shp.code = sale.code
);


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

SELECT salary FROM products AS inv
WHERE status IN (
    SELECT status FROM customers AS empl
    WHERE empl.status = inv.status
);


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

SELECT name FROM transactions AS sale
WHERE amount > (
    SELECT AVG(value) FROM departments AS catg
    WHERE catg.id = sale.id
);


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

SELECT salary FROM shipments AS mgr
WHERE id IN (
    SELECT id FROM customers AS budg
    WHERE budg.status = mgr.status
);


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

SELECT code FROM departments AS shp
WHERE value > (
    SELECT COUNT(salary) FROM categories AS budg
    WHERE budg.level = shp.level
);


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

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


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

SELECT salary FROM invoices AS empl
WHERE amount > (
    SELECT AVG(value) FROM accounts AS shp
    WHERE shp.code = empl.code
);


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

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


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

SELECT value FROM suppliers AS txn
WHERE code IN (
    SELECT code FROM branches AS sale
    WHERE sale.type = txn.type
);


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

SELECT salary FROM employees AS mgr
WHERE id IN (
    SELECT id FROM projects AS catg
    WHERE catg.code = mgr.code
);


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

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


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

SELECT id FROM departments AS rgn
WHERE id IN (
    SELECT id FROM shipments AS sale
    WHERE sale.level = rgn.level
);


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

SELECT amount FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.code = shp.code
);


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

SELECT name FROM regions AS prod
WHERE code IN (
    SELECT code FROM projects AS lne
    WHERE lne.id = prod.id
);


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

SELECT id FROM shipments AS sale
WHERE id IN (
    SELECT id FROM warehouses AS cust
    WHERE cust.code = sale.code
);


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

SELECT value FROM invoices AS prod
WHERE value > (
    SELECT SUM(amount) FROM tasks AS inv
    WHERE inv.status = prod.status
);


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

SELECT amount FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.type = rgn.type
);


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

SELECT id FROM accounts AS rgn
WHERE type IN (
    SELECT type FROM transactions AS acct
    WHERE acct.id = rgn.id
);


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

SELECT salary FROM warehouses AS emp
WHERE id IN (
    SELECT id FROM employees AS lne
    WHERE lne.level = emp.level
);


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

SELECT amount FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.id = ord.id
);


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

SELECT salary FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.level = budg.level
);


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

SELECT name FROM warehouses AS lne
WHERE amount > (
    SELECT COUNT(salary) FROM departments AS shp
    WHERE shp.level = lne.level
);


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

SELECT id FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.type = lne.type
);


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

SELECT id FROM accounts AS whs
WHERE amount > (
    SELECT MIN(value) FROM warehouses AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT value FROM suppliers AS txn
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.code = txn.code
);


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

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


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

SELECT value FROM projects AS cust
WHERE salary > (
    SELECT MAX(salary) FROM branches AS prod
    WHERE prod.status = cust.status
);


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

SELECT id FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.type = sale.type
);


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

SELECT value FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.code = empl.code
);


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

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


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

SELECT amount FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.status = schd.status
);


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

SELECT salary FROM shipments AS srvc
WHERE value > (
    SELECT MAX(value) FROM orders AS budg
    WHERE budg.type = srvc.type
);


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

SELECT code FROM employees AS dept
WHERE type IN (
    SELECT type FROM tasks AS whs
    WHERE whs.status = dept.status
);


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

SELECT amount FROM products AS acct
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS schd
    WHERE schd.type = acct.type
);


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

SELECT salary FROM suppliers AS cust
WHERE salary > (
    SELECT AVG(salary) FROM departments AS ord
    WHERE ord.code = cust.code
);


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

SELECT code FROM tasks AS rgn
WHERE salary > (
    SELECT MAX(value) FROM customers AS acct
    WHERE acct.level = rgn.level
);


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

SELECT id FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.level = acct.level
);


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

SELECT code FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT name FROM accounts AS acct
WHERE amount > (
    SELECT MAX(value) FROM products AS inv
    WHERE inv.status = acct.status
);


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

SELECT name FROM warehouses AS lne
WHERE code IN (
    SELECT code FROM invoices AS whs
    WHERE whs.code = lne.code
);


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

SELECT code FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.level = budg.level
);


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

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


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

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


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

SELECT name FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.status = ordr.status
);


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

SELECT name FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.id = txn.id
);


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

SELECT amount FROM warehouses AS lne
WHERE status IN (
    SELECT status FROM branches AS catg
    WHERE catg.level = lne.level
);


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

SELECT code FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = txn.id
);


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

SELECT id FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.type = srvc.type
);


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

SELECT id FROM suppliers AS empl
WHERE salary > (
    SELECT COUNT(value) FROM transactions AS sale
    WHERE sale.status = empl.status
);


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

SELECT code FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.code = ordr.code
);


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

SELECT id FROM suppliers AS schd
WHERE type IN (
    SELECT type FROM tasks AS prod
    WHERE prod.type = schd.type
);


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

SELECT name FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.code = mgr.code
);


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

SELECT code FROM products AS ord
WHERE code IN (
    SELECT code FROM warehouses AS dept
    WHERE dept.type = ord.type
);


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

SELECT value FROM regions AS whs
WHERE value > (
    SELECT COUNT(salary) FROM departments AS cust
    WHERE cust.type = whs.type
);


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

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


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

SELECT amount FROM warehouses AS txn
WHERE level IN (
    SELECT level FROM categories AS schd
    WHERE schd.level = txn.level
);


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

SELECT amount FROM tasks AS cust
WHERE type IN (
    SELECT type FROM orders AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT amount FROM departments AS sale
WHERE value > (
    SELECT AVG(value) FROM categories AS catg
    WHERE catg.type = sale.type
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT amount FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.type = prod.type
);


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

SELECT name FROM suppliers AS txn
WHERE level IN (
    SELECT level FROM warehouses AS shp
    WHERE shp.status = txn.status
);


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

SELECT code FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.status = empl.status
);


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

SELECT code FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.id = catg.id
);


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

SELECT name FROM warehouses AS cust
WHERE amount > (
    SELECT MAX(amount) FROM products AS dept
    WHERE dept.id = cust.id
);


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

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


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

SELECT id FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT code FROM shipments AS ordr
WHERE level IN (
    SELECT level FROM invoices AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT salary FROM orders AS emp
WHERE salary > (
    SELECT SUM(value) FROM transactions AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT code FROM accounts AS catg
WHERE status IN (
    SELECT status FROM suppliers AS cust
    WHERE cust.type = catg.type
);


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

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


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

SELECT amount FROM departments AS shp
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.id = shp.id
);


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

SELECT amount FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT name FROM projects AS schd
WHERE status IN (
    SELECT status FROM warehouses AS txn
    WHERE txn.type = schd.type
);


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

SELECT name FROM tasks AS shp
WHERE level IN (
    SELECT level FROM orders AS cust
    WHERE cust.type = shp.type
);


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

SELECT code FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.code = budg.code
);


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

SELECT salary FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = prod.code
);


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

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


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

SELECT value FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.id = catg.id
);


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

SELECT name FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.level = inv.level
);


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

SELECT id FROM categories AS txn
WHERE value > (
    SELECT MIN(salary) FROM suppliers AS empl
    WHERE empl.level = txn.level
);


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

SELECT id FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.code = shp.code
);


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

SELECT code FROM warehouses AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS dept
    WHERE dept.id = schd.id
);


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

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


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

SELECT amount FROM employees AS emp
WHERE type IN (
    SELECT type FROM transactions AS sale
    WHERE sale.id = emp.id
);


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

SELECT amount FROM employees AS sale
WHERE value > (
    SELECT MAX(value) FROM shipments AS ord
    WHERE ord.status = sale.status
);


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

SELECT id FROM categories AS budg
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.type = budg.type
);


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

SELECT name FROM products AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM customers AS lne
    WHERE lne.level = rgn.level
);


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

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


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

SELECT id FROM shipments AS dept
WHERE value > (
    SELECT COUNT(salary) FROM invoices AS catg
    WHERE catg.type = dept.type
);


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

SELECT salary FROM departments AS schd
WHERE status IN (
    SELECT status FROM categories AS ord
    WHERE ord.type = schd.type
);


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

SELECT id FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.code = inv.code
);


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

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


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

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


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

SELECT name FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.level = inv.level
);


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

SELECT value FROM employees AS schd
WHERE amount > (
    SELECT SUM(value) FROM shipments AS txn
    WHERE txn.status = schd.status
);


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

SELECT amount FROM regions AS catg
WHERE amount > (
    SELECT SUM(value) FROM projects AS prod
    WHERE prod.status = catg.status
);


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

SELECT amount FROM shipments AS txn
WHERE status IN (
    SELECT status FROM transactions AS inv
    WHERE inv.level = txn.level
);


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

SELECT code FROM orders AS acct
WHERE type IN (
    SELECT type FROM regions AS cust
    WHERE cust.type = acct.type
);


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

SELECT name FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.id = schd.id
);


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

SELECT salary FROM branches AS mgr
WHERE id IN (
    SELECT id FROM shipments AS cust
    WHERE cust.level = mgr.level
);


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

SELECT id FROM regions AS lne
WHERE status IN (
    SELECT status FROM branches AS ord
    WHERE ord.code = lne.code
);


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

SELECT value FROM categories AS schd
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS budg
    WHERE budg.status = schd.status
);


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

SELECT name FROM employees AS dept
WHERE type IN (
    SELECT type FROM suppliers AS rgn
    WHERE rgn.id = dept.id
);


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

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


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

SELECT id FROM shipments AS inv
WHERE level IN (
    SELECT level FROM orders AS prod
    WHERE prod.type = inv.type
);


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

SELECT code FROM suppliers AS shp
WHERE amount > (
    SELECT SUM(value) FROM transactions AS dept
    WHERE dept.level = shp.level
);


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

SELECT value FROM shipments AS ord
WHERE status IN (
    SELECT status FROM regions AS lne
    WHERE lne.id = ord.id
);


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

SELECT name FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.level = inv.level
);


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

SELECT name FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.type = ordr.type
);


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

SELECT name FROM regions AS lne
WHERE type IN (
    SELECT type FROM warehouses AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT salary FROM orders AS txn
WHERE status IN (
    SELECT status FROM warehouses AS sale
    WHERE sale.status = txn.status
);


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

SELECT id FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT value FROM warehouses AS ord
WHERE level IN (
    SELECT level FROM suppliers AS acct
    WHERE acct.id = ord.id
);


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

SELECT name FROM projects AS acct
WHERE value > (
    SELECT SUM(value) FROM customers AS dept
    WHERE dept.code = acct.code
);


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

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


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

SELECT code FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.type = txn.type
);


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

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


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

SELECT salary FROM categories AS budg
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS schd
    WHERE schd.level = budg.level
);


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

SELECT code FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = txn.status
);


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

SELECT id FROM transactions AS rgn
WHERE id IN (
    SELECT id FROM customers AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT code FROM suppliers AS inv
WHERE status IN (
    SELECT status FROM accounts AS budg
    WHERE budg.code = inv.code
);


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

SELECT salary FROM invoices AS schd
WHERE type IN (
    SELECT type FROM suppliers AS emp
    WHERE emp.type = schd.type
);


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

SELECT salary FROM orders AS emp
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.id = emp.id
);


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

SELECT code FROM projects AS catg
WHERE type IN (
    SELECT type FROM suppliers AS inv
    WHERE inv.type = catg.type
);


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

SELECT code FROM orders AS sale
WHERE type IN (
    SELECT type FROM tasks AS cust
    WHERE cust.code = sale.code
);


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

SELECT salary FROM transactions AS prod
WHERE value > (
    SELECT COUNT(salary) FROM projects AS cust
    WHERE cust.status = prod.status
);


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

SELECT id FROM orders AS emp
WHERE value > (
    SELECT COUNT(value) FROM branches AS shp
    WHERE shp.code = emp.code
);


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

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


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

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


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

SELECT value FROM orders AS cust
WHERE code IN (
    SELECT code FROM projects AS dept
    WHERE dept.level = cust.level
);


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

SELECT salary FROM tasks AS budg
WHERE value > (
    SELECT AVG(salary) FROM orders AS dept
    WHERE dept.id = budg.id
);


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

SELECT value FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.type = acct.type
);


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

SELECT salary FROM invoices AS prod
WHERE salary > (
    SELECT SUM(value) FROM suppliers AS emp
    WHERE emp.level = prod.level
);


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

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


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

SELECT value FROM branches AS lne
WHERE level IN (
    SELECT level FROM orders AS cust
    WHERE cust.status = lne.status
);


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

SELECT amount FROM invoices AS whs
WHERE status IN (
    SELECT status FROM accounts AS txn
    WHERE txn.status = whs.status
);


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

SELECT salary FROM branches AS empl
WHERE salary > (
    SELECT MIN(salary) FROM orders AS acct
    WHERE acct.id = empl.id
);


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

SELECT id FROM projects AS acct
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.id = acct.id
);


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

SELECT name FROM accounts AS budg
WHERE value > (
    SELECT MAX(value) FROM regions AS inv
    WHERE inv.level = budg.level
);


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

SELECT amount FROM customers AS acct
WHERE value > (
    SELECT MIN(value) FROM invoices AS txn
    WHERE txn.type = acct.type
);


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

SELECT id FROM suppliers AS ord
WHERE amount > (
    SELECT MAX(amount) FROM projects AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT name FROM products AS txn
WHERE id IN (
    SELECT id FROM branches AS catg
    WHERE catg.id = txn.id
);


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

SELECT code FROM orders AS prod
WHERE level IN (
    SELECT level FROM categories AS budg
    WHERE budg.id = prod.id
);


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

SELECT amount FROM products AS schd
WHERE type IN (
    SELECT type FROM branches AS dept
    WHERE dept.level = schd.level
);


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

SELECT id FROM invoices AS schd
WHERE value > (
    SELECT AVG(amount) FROM departments AS acct
    WHERE acct.type = schd.type
);


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS lne
    WHERE lne.type = shp.type
);


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

SELECT amount FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.id = ord.id
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.id = shp.id
);


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

SELECT salary FROM employees AS rgn
WHERE status IN (
    SELECT status FROM orders AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT salary FROM orders AS shp
WHERE level IN (
    SELECT level FROM transactions AS empl
    WHERE empl.level = shp.level
);


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

SELECT id FROM departments AS emp
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS schd
    WHERE schd.level = emp.level
);


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

SELECT id FROM products AS ord
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.code = ord.code
);


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

SELECT name FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.level = shp.level
);


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

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


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

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


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

SELECT code FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.level = ordr.level
);


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

SELECT salary FROM regions AS cust
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS prod
    WHERE prod.code = cust.code
);


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

SELECT id FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.id = mgr.id
);


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

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


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

SELECT value FROM customers AS sale
WHERE amount > (
    SELECT MAX(value) FROM invoices AS shp
    WHERE shp.level = sale.level
);


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

SELECT code FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.level = empl.level
);


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

SELECT name FROM employees AS inv
WHERE code IN (
    SELECT code FROM invoices AS dept
    WHERE dept.code = inv.code
);


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

SELECT code FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.code = srvc.code
);


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

SELECT code FROM employees AS acct
WHERE salary > (
    SELECT AVG(value) FROM invoices AS txn
    WHERE txn.status = acct.status
);


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

SELECT name FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.level = acct.level
);


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

SELECT name FROM suppliers AS mgr
WHERE type IN (
    SELECT type FROM branches AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT amount FROM orders AS empl
WHERE code IN (
    SELECT code FROM departments AS catg
    WHERE catg.level = empl.level
);


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

SELECT name FROM employees AS dept
WHERE status IN (
    SELECT status FROM warehouses AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT amount FROM accounts AS whs
WHERE level IN (
    SELECT level FROM customers AS ord
    WHERE ord.type = whs.type
);


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

SELECT value FROM regions AS lne
WHERE salary > (
    SELECT MAX(value) FROM tasks AS emp
    WHERE emp.type = lne.type
);


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

SELECT value FROM invoices AS schd
WHERE salary > (
    SELECT SUM(value) FROM tasks AS ord
    WHERE ord.id = schd.id
);


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

SELECT amount FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT amount FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.level = ord.level
);


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

SELECT salary FROM projects AS cust
WHERE type IN (
    SELECT type FROM invoices AS schd
    WHERE schd.type = cust.type
);


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

SELECT name FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = budg.id
);


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

SELECT salary FROM products AS schd
WHERE level IN (
    SELECT level FROM orders AS sale
    WHERE sale.status = schd.status
);


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

SELECT name FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT id FROM customers AS lne
WHERE id IN (
    SELECT id FROM regions AS ord
    WHERE ord.id = lne.id
);


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

SELECT value FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.level = srvc.level
);


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

SELECT salary FROM invoices AS catg
WHERE id IN (
    SELECT id FROM orders AS budg
    WHERE budg.status = catg.status
);


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

SELECT salary FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.status = ordr.status
);


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

SELECT value FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.code = dept.code
);


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

SELECT value FROM products AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS ord
    WHERE ord.code = mgr.code
);


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

SELECT value FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.level = shp.level
);


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

SELECT value FROM customers AS schd
WHERE id IN (
    SELECT id FROM tasks AS cust
    WHERE cust.status = schd.status
);


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

SELECT code FROM invoices AS cust
WHERE value > (
    SELECT MAX(amount) FROM transactions AS whs
    WHERE whs.code = cust.code
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.level = prod.level
);


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

SELECT code FROM regions AS schd
WHERE type IN (
    SELECT type FROM employees AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT code FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.status = mgr.status
);


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

SELECT value FROM customers AS shp
WHERE level IN (
    SELECT level FROM warehouses AS inv
    WHERE inv.id = shp.id
);


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

SELECT name FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.level = catg.level
);


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.status = cust.status
);


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

SELECT id FROM suppliers AS whs
WHERE code IN (
    SELECT code FROM departments AS shp
    WHERE shp.id = whs.id
);


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

SELECT salary FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.code = inv.code
);


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

SELECT amount FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.code = mgr.code
);


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

SELECT salary FROM regions AS catg
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.id = catg.id
);


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

SELECT name FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.id = emp.id
);


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

SELECT id FROM employees AS ordr
WHERE amount > (
    SELECT SUM(value) FROM invoices AS shp
    WHERE shp.status = ordr.status
);


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

SELECT salary FROM suppliers AS ordr
WHERE value > (
    SELECT MAX(amount) FROM accounts AS cust
    WHERE cust.id = ordr.id
);


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

SELECT value FROM regions AS empl
WHERE code IN (
    SELECT code FROM projects AS schd
    WHERE schd.type = empl.type
);


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

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


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

SELECT id FROM suppliers AS acct
WHERE amount > (
    SELECT SUM(value) FROM invoices AS cust
    WHERE cust.id = acct.id
);


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

SELECT amount FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.status = cust.status
);


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

SELECT id FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.status = empl.status
);


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

SELECT id FROM tasks AS inv
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT amount FROM categories AS rgn
WHERE value > (
    SELECT MAX(value) FROM customers AS empl
    WHERE empl.level = rgn.level
);


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

SELECT value FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.status = acct.status
);


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

SELECT amount FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.status = emp.status
);


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

SELECT value FROM categories AS inv
WHERE amount > (
    SELECT MAX(amount) FROM suppliers AS dept
    WHERE dept.type = inv.type
);


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

SELECT code FROM categories AS ord
WHERE status IN (
    SELECT status FROM departments AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT code FROM suppliers AS shp
WHERE code IN (
    SELECT code FROM products AS inv
    WHERE inv.code = shp.code
);


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

SELECT name FROM departments AS schd
WHERE id IN (
    SELECT id FROM products AS empl
    WHERE empl.id = schd.id
);


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

SELECT name FROM regions AS inv
WHERE value > (
    SELECT COUNT(amount) FROM transactions AS txn
    WHERE txn.code = inv.code
);


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

SELECT amount FROM tasks AS ordr
WHERE status IN (
    SELECT status FROM employees AS empl
    WHERE empl.id = ordr.id
);


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

SELECT value FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.type = rgn.type
);


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

SELECT amount FROM categories AS schd
WHERE status IN (
    SELECT status FROM tasks AS sale
    WHERE sale.code = schd.code
);


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

SELECT id FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.level = cust.level
);


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

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


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

SELECT salary FROM suppliers AS lne
WHERE id IN (
    SELECT id FROM projects AS budg
    WHERE budg.code = lne.code
);


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

SELECT amount FROM transactions AS mgr
WHERE id IN (
    SELECT id FROM invoices AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.type = srvc.type
);


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

SELECT amount FROM departments AS sale
WHERE type IN (
    SELECT type FROM employees AS txn
    WHERE txn.status = sale.status
);


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

SELECT amount FROM employees AS srvc
WHERE value > (
    SELECT SUM(value) FROM invoices AS txn
    WHERE txn.status = srvc.status
);


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

SELECT salary FROM employees AS sale
WHERE value > (
    SELECT COUNT(amount) FROM orders AS lne
    WHERE lne.type = sale.type
);


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

SELECT amount FROM departments AS sale
WHERE value > (
    SELECT MIN(value) FROM orders AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT code FROM categories AS cust
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS prod
    WHERE prod.status = cust.status
);


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

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


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

SELECT id FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.status = whs.status
);


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

SELECT value FROM invoices AS dept
WHERE id IN (
    SELECT id FROM branches AS rgn
    WHERE rgn.level = dept.level
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.type = ord.type
);


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

SELECT name FROM orders AS ord
WHERE value > (
    SELECT COUNT(amount) FROM categories AS inv
    WHERE inv.type = ord.type
);


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

SELECT name FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT salary FROM tasks AS budg
WHERE type IN (
    SELECT type FROM customers AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT value FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT amount FROM categories AS schd
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS inv
    WHERE inv.level = schd.level
);


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

SELECT name FROM shipments AS cust
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.id = cust.id
);


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

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


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

SELECT name FROM categories AS schd
WHERE id IN (
    SELECT id FROM branches AS whs
    WHERE whs.status = schd.status
);


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

SELECT salary FROM departments AS dept
WHERE amount > (
    SELECT COUNT(salary) FROM categories AS empl
    WHERE empl.type = dept.type
);


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

SELECT value FROM projects AS rgn
WHERE id IN (
    SELECT id FROM warehouses AS dept
    WHERE dept.code = rgn.code
);