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

SELECT code FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT amount FROM projects AS txn
WHERE salary > (
    SELECT MAX(amount) FROM accounts AS mgr
    WHERE mgr.code = txn.code
);


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

SELECT code FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.code = rgn.code
);


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

SELECT salary FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.code = prod.code
);


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

SELECT id FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT value FROM categories AS srvc
WHERE id IN (
    SELECT id FROM orders AS lne
    WHERE lne.status = srvc.status
);


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

SELECT id FROM employees AS srvc
WHERE id IN (
    SELECT id FROM branches AS dept
    WHERE dept.status = srvc.status
);


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

SELECT value FROM categories AS empl
WHERE value > (
    SELECT SUM(salary) FROM projects AS dept
    WHERE dept.status = empl.status
);


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

SELECT value FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.status = sale.status
);


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

SELECT amount FROM employees AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM products AS acct
    WHERE acct.status = srvc.status
);


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

SELECT name FROM regions AS dept
WHERE type IN (
    SELECT type FROM departments AS cust
    WHERE cust.level = dept.level
);


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

SELECT id FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.id = dept.id
);


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

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


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

SELECT value FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.type = srvc.type
);


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

SELECT code FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.status = inv.status
);


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

SELECT name FROM employees AS catg
WHERE type IN (
    SELECT type FROM transactions AS dept
    WHERE dept.level = catg.level
);


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

SELECT name FROM invoices AS ord
WHERE salary > (
    SELECT MAX(salary) FROM orders AS txn
    WHERE txn.code = ord.code
);


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

SELECT value FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.id = acct.id
);


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

SELECT name FROM accounts AS rgn
WHERE value > (
    SELECT MIN(salary) FROM invoices AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT id FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.type = empl.type
);


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

SELECT code FROM invoices AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS ordr
    WHERE ordr.id = rgn.id
);


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

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


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

SELECT name FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.level = txn.level
);


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

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


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

SELECT salary FROM employees AS empl
WHERE value > (
    SELECT MIN(value) FROM tasks AS catg
    WHERE catg.status = empl.status
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.level = cust.level
);


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

SELECT amount FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = prod.level
);


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

SELECT salary FROM customers AS budg
WHERE amount > (
    SELECT COUNT(value) FROM warehouses AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT value FROM projects AS dept
WHERE value > (
    SELECT MIN(salary) FROM invoices AS schd
    WHERE schd.level = dept.level
);


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

SELECT value FROM branches AS emp
WHERE type IN (
    SELECT type FROM orders AS empl
    WHERE empl.level = emp.level
);


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

SELECT value FROM customers AS emp
WHERE type IN (
    SELECT type FROM departments AS budg
    WHERE budg.code = emp.code
);


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

SELECT name FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.status = sale.status
);


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

SELECT code FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.id = empl.id
);


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

SELECT code FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.level = ordr.level
);


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

SELECT salary FROM departments AS ordr
WHERE amount > (
    SELECT SUM(salary) FROM employees AS cust
    WHERE cust.type = ordr.type
);


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

SELECT id FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.code = ord.code
);


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

SELECT amount FROM employees AS dept
WHERE value > (
    SELECT MAX(amount) FROM categories AS acct
    WHERE acct.id = dept.id
);


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

SELECT code FROM projects AS lne
WHERE value > (
    SELECT MAX(salary) FROM orders AS shp
    WHERE shp.level = lne.level
);


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

SELECT amount FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.type = inv.type
);


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

SELECT code FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.code = rgn.code
);


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

SELECT name FROM invoices AS txn
WHERE type IN (
    SELECT type FROM products AS shp
    WHERE shp.id = txn.id
);


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

SELECT name FROM warehouses AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM customers AS rgn
    WHERE rgn.status = srvc.status
);


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

SELECT id FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.type = srvc.type
);


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

SELECT id FROM regions AS sale
WHERE value > (
    SELECT MIN(value) FROM suppliers AS acct
    WHERE acct.code = sale.code
);


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

SELECT amount FROM warehouses AS rgn
WHERE type IN (
    SELECT type FROM orders AS sale
    WHERE sale.status = rgn.status
);


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

SELECT amount FROM accounts AS emp
WHERE level IN (
    SELECT level FROM tasks AS dept
    WHERE dept.type = emp.type
);


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

SELECT value FROM accounts AS lne
WHERE amount > (
    SELECT SUM(salary) FROM regions AS prod
    WHERE prod.type = lne.type
);


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

SELECT amount FROM suppliers AS acct
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT salary FROM customers AS acct
WHERE type IN (
    SELECT type FROM branches AS inv
    WHERE inv.type = acct.type
);


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

SELECT value FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.status = ordr.status
);


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

SELECT code FROM products AS empl
WHERE id IN (
    SELECT id FROM customers AS dept
    WHERE dept.id = empl.id
);


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

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


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

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


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

SELECT name FROM orders AS lne
WHERE value > (
    SELECT MAX(value) FROM warehouses AS sale
    WHERE sale.code = lne.code
);


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

SELECT salary FROM tasks AS srvc
WHERE type IN (
    SELECT type FROM branches AS ordr
    WHERE ordr.status = srvc.status
);


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

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


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

SELECT value FROM accounts AS shp
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS prod
    WHERE prod.level = shp.level
);


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

SELECT amount FROM shipments AS txn
WHERE code IN (
    SELECT code FROM products AS ord
    WHERE ord.status = txn.status
);


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

SELECT salary FROM transactions AS rgn
WHERE amount > (
    SELECT COUNT(salary) FROM warehouses AS whs
    WHERE whs.level = rgn.level
);


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

SELECT salary FROM accounts AS schd
WHERE level IN (
    SELECT level FROM projects AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT value FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.id = schd.id
);


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

SELECT name FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.id = lne.id
);


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

SELECT code FROM shipments AS acct
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS prod
    WHERE prod.status = acct.status
);


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

SELECT salary FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.code = emp.code
);


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

SELECT code FROM accounts AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS empl
    WHERE empl.type = sale.type
);


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

SELECT salary FROM customers AS catg
WHERE type IN (
    SELECT type FROM suppliers AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT value FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.status = dept.status
);


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

SELECT name FROM transactions AS ordr
WHERE value > (
    SELECT MIN(salary) FROM employees AS empl
    WHERE empl.level = ordr.level
);


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

SELECT code FROM orders AS acct
WHERE code IN (
    SELECT code FROM branches AS srvc
    WHERE srvc.code = acct.code
);


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

SELECT amount FROM tasks AS ord
WHERE code IN (
    SELECT code FROM shipments AS schd
    WHERE schd.level = ord.level
);


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

SELECT salary FROM tasks AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS emp
    WHERE emp.status = mgr.status
);


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

SELECT salary FROM products AS mgr
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS shp
    WHERE shp.status = mgr.status
);


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

SELECT amount FROM invoices AS inv
WHERE value > (
    SELECT SUM(salary) FROM customers AS emp
    WHERE emp.code = inv.code
);


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

SELECT value FROM branches AS ordr
WHERE value > (
    SELECT MAX(amount) FROM departments AS inv
    WHERE inv.level = ordr.level
);


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

SELECT name FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.level = rgn.level
);


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

SELECT name FROM shipments AS mgr
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.type = mgr.type
);


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

SELECT id FROM transactions AS mgr
WHERE code IN (
    SELECT code FROM warehouses AS schd
    WHERE schd.status = mgr.status
);


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

SELECT id FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.type = lne.type
);


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

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


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

SELECT amount FROM departments AS empl
WHERE level IN (
    SELECT level FROM regions AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT name FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.code = catg.code
);


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

SELECT id FROM categories AS lne
WHERE status IN (
    SELECT status FROM projects AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT amount FROM customers AS budg
WHERE status IN (
    SELECT status FROM warehouses AS sale
    WHERE sale.type = budg.type
);


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

SELECT amount FROM products AS lne
WHERE id IN (
    SELECT id FROM customers AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT name FROM departments AS sale
WHERE value > (
    SELECT SUM(amount) FROM employees AS emp
    WHERE emp.status = sale.status
);


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

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


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

SELECT code FROM accounts AS rgn
WHERE type IN (
    SELECT type FROM warehouses AS lne
    WHERE lne.type = rgn.type
);


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

SELECT id FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.level = srvc.level
);


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

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


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

SELECT code FROM shipments AS catg
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.status = catg.status
);


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

SELECT salary FROM shipments AS schd
WHERE code IN (
    SELECT code FROM suppliers AS budg
    WHERE budg.level = schd.level
);


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

SELECT amount FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.level = rgn.level
);


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

SELECT amount FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.code = mgr.code
);


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

SELECT code FROM categories AS acct
WHERE amount > (
    SELECT COUNT(salary) FROM warehouses AS cust
    WHERE cust.status = acct.status
);


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

SELECT value FROM warehouses AS prod
WHERE code IN (
    SELECT code FROM departments AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT id FROM branches AS catg
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS sale
    WHERE sale.level = catg.level
);


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

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


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

SELECT salary FROM projects AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM employees AS empl
    WHERE empl.id = sale.id
);


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

SELECT salary FROM categories AS schd
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.code = schd.code
);


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

SELECT amount FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.status = lne.status
);


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

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


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

SELECT amount FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT id FROM tasks AS sale
WHERE value > (
    SELECT MIN(amount) FROM orders AS whs
    WHERE whs.code = sale.code
);


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

SELECT value FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = mgr.code
);


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

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


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

SELECT name FROM categories AS ordr
WHERE type IN (
    SELECT type FROM transactions AS emp
    WHERE emp.type = ordr.type
);


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

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


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

SELECT value FROM warehouses AS empl
WHERE value > (
    SELECT SUM(value) FROM shipments AS budg
    WHERE budg.level = empl.level
);


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

SELECT value FROM projects AS dept
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.code = dept.code
);


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

SELECT name FROM shipments AS inv
WHERE value > (
    SELECT COUNT(value) FROM accounts AS txn
    WHERE txn.status = inv.status
);


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

SELECT salary FROM customers AS catg
WHERE level IN (
    SELECT level FROM orders AS sale
    WHERE sale.code = catg.code
);


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

SELECT code FROM employees AS inv
WHERE value > (
    SELECT MAX(value) FROM tasks AS cust
    WHERE cust.level = inv.level
);


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

SELECT value FROM departments AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM suppliers AS acct
    WHERE acct.type = mgr.type
);


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

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


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

SELECT value FROM transactions AS emp
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.status = emp.status
);


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

SELECT name FROM invoices AS acct
WHERE amount > (
    SELECT SUM(value) FROM shipments AS empl
    WHERE empl.code = acct.code
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.id = cust.id
);


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

SELECT amount FROM regions AS ord
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT id FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.status = prod.status
);


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

SELECT name FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.id = dept.id
);


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

SELECT name FROM orders AS catg
WHERE status IN (
    SELECT status FROM products AS emp
    WHERE emp.type = catg.type
);


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

SELECT value FROM products AS txn
WHERE value > (
    SELECT MAX(value) FROM regions AS whs
    WHERE whs.id = txn.id
);


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

SELECT value FROM shipments AS empl
WHERE type IN (
    SELECT type FROM products AS acct
    WHERE acct.code = empl.code
);


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

SELECT name FROM categories AS schd
WHERE amount > (
    SELECT MAX(value) FROM accounts AS empl
    WHERE empl.type = schd.type
);


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

SELECT name FROM employees AS budg
WHERE value > (
    SELECT MIN(value) FROM regions AS catg
    WHERE catg.id = budg.id
);


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

SELECT salary FROM orders AS schd
WHERE amount > (
    SELECT SUM(amount) FROM employees AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT name FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.type = whs.type
);


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

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


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

SELECT id FROM shipments AS txn
WHERE level IN (
    SELECT level FROM transactions AS lne
    WHERE lne.code = txn.code
);


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

SELECT id FROM projects AS catg
WHERE type IN (
    SELECT type FROM warehouses AS dept
    WHERE dept.level = catg.level
);


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

SELECT id FROM shipments AS mgr
WHERE id IN (
    SELECT id FROM accounts AS rgn
    WHERE rgn.level = mgr.level
);


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

SELECT value FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.status = catg.status
);


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

SELECT value FROM categories AS ord
WHERE code IN (
    SELECT code FROM employees AS inv
    WHERE inv.level = ord.level
);


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

SELECT value FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.code = cust.code
);


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

SELECT amount FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.id = ord.id
);


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

SELECT amount FROM warehouses AS catg
WHERE status IN (
    SELECT status FROM branches AS txn
    WHERE txn.id = catg.id
);


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

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


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

SELECT id FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT id FROM categories AS catg
WHERE level IN (
    SELECT level FROM invoices AS shp
    WHERE shp.status = catg.status
);


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

SELECT id FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.code = srvc.code
);


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

SELECT id FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.status = emp.status
);


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

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


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

SELECT value FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.id = sale.id
);


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

SELECT salary FROM warehouses AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS whs
    WHERE whs.level = ord.level
);


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

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


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

SELECT code FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.status = srvc.status
);


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

SELECT amount FROM tasks AS empl
WHERE code IN (
    SELECT code FROM suppliers AS emp
    WHERE emp.code = empl.code
);


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

SELECT code FROM branches AS prod
WHERE salary > (
    SELECT AVG(salary) FROM shipments AS acct
    WHERE acct.type = prod.type
);


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

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


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

SELECT code FROM projects AS txn
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.code = txn.code
);


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

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


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

SELECT value FROM accounts AS ordr
WHERE id IN (
    SELECT id FROM transactions AS ord
    WHERE ord.id = ordr.id
);


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

SELECT code FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.id = catg.id
);


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

SELECT salary FROM products AS dept
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT code FROM categories AS sale
WHERE amount > (
    SELECT SUM(amount) FROM employees AS prod
    WHERE prod.level = sale.level
);


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

SELECT id FROM accounts AS whs
WHERE value > (
    SELECT MIN(value) FROM projects AS empl
    WHERE empl.status = whs.status
);


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

SELECT name FROM regions AS cust
WHERE id IN (
    SELECT id FROM orders AS whs
    WHERE whs.type = cust.type
);


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

SELECT value FROM categories AS acct
WHERE salary > (
    SELECT MAX(salary) FROM regions AS cust
    WHERE cust.type = acct.type
);


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

SELECT amount FROM projects AS inv
WHERE salary > (
    SELECT MIN(value) FROM employees AS shp
    WHERE shp.level = inv.level
);


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

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


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

SELECT id FROM regions AS sale
WHERE level IN (
    SELECT level FROM customers AS mgr
    WHERE mgr.id = sale.id
);


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

SELECT value FROM invoices AS dept
WHERE type IN (
    SELECT type FROM projects AS ord
    WHERE ord.code = dept.code
);


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

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


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

SELECT value FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.id = schd.id
);


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

SELECT value FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.type = catg.type
);


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

SELECT value FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.level = schd.level
);


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

SELECT value FROM products AS sale
WHERE amount > (
    SELECT MIN(value) FROM transactions AS schd
    WHERE schd.code = sale.code
);


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

SELECT code FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.status = shp.status
);


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

SELECT code FROM tasks AS srvc
WHERE code IN (
    SELECT code FROM transactions AS acct
    WHERE acct.level = srvc.level
);


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

SELECT value FROM products AS whs
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.level = whs.level
);


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

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


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

SELECT code FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT name FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.code = inv.code
);


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

SELECT salary FROM regions AS ord
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT name FROM categories AS acct
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS sale
    WHERE sale.level = acct.level
);


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

SELECT amount FROM customers AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM suppliers AS prod
    WHERE prod.level = catg.level
);


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

SELECT salary FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = acct.level
);


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

SELECT value FROM shipments AS mgr
WHERE type IN (
    SELECT type FROM accounts AS sale
    WHERE sale.type = mgr.type
);


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

SELECT salary FROM invoices AS ordr
WHERE type IN (
    SELECT type FROM warehouses AS txn
    WHERE txn.code = ordr.code
);


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

SELECT name FROM employees AS inv
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS srvc
    WHERE srvc.id = inv.id
);


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

SELECT id FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.level = rgn.level
);


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

SELECT name FROM tasks AS lne
WHERE value > (
    SELECT COUNT(salary) FROM suppliers AS acct
    WHERE acct.level = lne.level
);


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

SELECT salary FROM transactions AS schd
WHERE value > (
    SELECT MIN(amount) FROM employees AS ord
    WHERE ord.status = schd.status
);


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

SELECT value FROM categories AS shp
WHERE salary > (
    SELECT AVG(salary) FROM customers AS whs
    WHERE whs.status = shp.status
);


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

SELECT amount FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.status = txn.status
);


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

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


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

SELECT amount FROM invoices AS cust
WHERE id IN (
    SELECT id FROM products AS ord
    WHERE ord.code = cust.code
);


Prompt:
Schema:
  invoices (alias: empl)(status, value, name, salary)
  departments(name, salary, id, type)
Task: Retrieve name from invoices with salary above the SUM(value) of departments rows sharing the same type.
SQL:

SELECT name FROM invoices AS empl
WHERE salary > (
    SELECT SUM(value) FROM departments AS budg
    WHERE budg.type = empl.type
);


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

SELECT salary FROM projects AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM customers AS dept
    WHERE dept.status = ordr.status
);


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

SELECT id FROM employees AS mgr
WHERE value > (
    SELECT MAX(salary) FROM invoices AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT name FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.type = sale.type
);


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

SELECT name FROM tasks AS inv
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS budg
    WHERE budg.code = inv.code
);


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

SELECT name FROM suppliers AS sale
WHERE type IN (
    SELECT type FROM tasks AS lne
    WHERE lne.code = sale.code
);


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

SELECT id FROM employees AS schd
WHERE value > (
    SELECT SUM(salary) FROM customers AS budg
    WHERE budg.code = schd.code
);


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

SELECT id FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT value FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = mgr.type
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.level = inv.level
);


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

SELECT name FROM products AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM departments AS lne
    WHERE lne.type = mgr.type
);


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

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


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

SELECT value FROM products AS emp
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS whs
    WHERE whs.level = emp.level
);


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

SELECT value FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.code = ord.code
);


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

SELECT amount FROM accounts AS srvc
WHERE status IN (
    SELECT status FROM customers AS ord
    WHERE ord.type = srvc.type
);


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

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


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

SELECT code FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.type = schd.type
);


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

SELECT salary FROM suppliers AS catg
WHERE level IN (
    SELECT level FROM shipments AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT value FROM warehouses AS rgn
WHERE id IN (
    SELECT id FROM shipments AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT code FROM transactions AS budg
WHERE type IN (
    SELECT type FROM branches AS txn
    WHERE txn.code = budg.code
);


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

SELECT id FROM warehouses AS empl
WHERE status IN (
    SELECT status FROM categories AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT value FROM accounts AS ord
WHERE amount > (
    SELECT MIN(value) FROM categories AS whs
    WHERE whs.level = ord.level
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.type = shp.type
);


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

SELECT amount FROM customers AS prod
WHERE value > (
    SELECT COUNT(amount) FROM departments AS inv
    WHERE inv.status = prod.status
);


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

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


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

SELECT name FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.level = budg.level
);


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

SELECT value FROM departments AS budg
WHERE value > (
    SELECT COUNT(amount) FROM employees AS prod
    WHERE prod.status = budg.status
);


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

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


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

SELECT code FROM invoices AS txn
WHERE salary > (
    SELECT MAX(value) FROM customers AS shp
    WHERE shp.type = txn.type
);


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

SELECT id FROM invoices AS shp
WHERE salary > (
    SELECT MAX(value) FROM regions AS lne
    WHERE lne.level = shp.level
);


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

SELECT code FROM warehouses AS mgr
WHERE code IN (
    SELECT code FROM shipments AS inv
    WHERE inv.type = mgr.type
);


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

SELECT salary FROM invoices AS rgn
WHERE id IN (
    SELECT id FROM regions AS txn
    WHERE txn.level = rgn.level
);


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

SELECT name FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.status = schd.status
);


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

SELECT salary FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.status = prod.status
);


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

SELECT amount FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.type = budg.type
);


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

SELECT code FROM categories AS budg
WHERE id IN (
    SELECT id FROM regions AS schd
    WHERE schd.code = budg.code
);


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

SELECT amount FROM transactions AS mgr
WHERE code IN (
    SELECT code FROM customers AS acct
    WHERE acct.code = mgr.code
);


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

SELECT value FROM tasks AS ord
WHERE status IN (
    SELECT status FROM orders AS schd
    WHERE schd.status = ord.status
);


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

SELECT name FROM products AS empl
WHERE level IN (
    SELECT level FROM customers AS ord
    WHERE ord.id = empl.id
);


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

SELECT salary FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = budg.status
);


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

SELECT salary FROM accounts AS whs
WHERE amount > (
    SELECT AVG(value) FROM categories AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT name FROM branches AS cust
WHERE status IN (
    SELECT status FROM projects AS prod
    WHERE prod.code = cust.code
);


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

SELECT salary FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.status = mgr.status
);


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

SELECT name FROM categories AS dept
WHERE code IN (
    SELECT code FROM employees AS sale
    WHERE sale.code = dept.code
);


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

SELECT id FROM invoices AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM customers AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT amount FROM tasks AS lne
WHERE value > (
    SELECT MIN(salary) FROM categories AS schd
    WHERE schd.status = lne.status
);


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

SELECT value FROM tasks AS ordr
WHERE type IN (
    SELECT type FROM warehouses AS catg
    WHERE catg.id = ordr.id
);


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

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


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

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


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

SELECT value FROM orders AS rgn
WHERE value > (
    SELECT MIN(amount) FROM projects AS dept
    WHERE dept.id = rgn.id
);


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

SELECT salary FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.type = empl.type
);


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

SELECT name FROM projects AS lne
WHERE status IN (
    SELECT status FROM departments AS catg
    WHERE catg.id = lne.id
);


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

SELECT id FROM suppliers AS sale
WHERE level IN (
    SELECT level FROM orders AS schd
    WHERE schd.id = sale.id
);


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

SELECT value FROM products AS shp
WHERE value > (
    SELECT AVG(salary) FROM tasks AS schd
    WHERE schd.type = shp.type
);


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

SELECT salary FROM employees AS schd
WHERE amount > (
    SELECT AVG(amount) FROM branches AS acct
    WHERE acct.level = schd.level
);


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

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


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

SELECT code FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.type = empl.type
);


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

SELECT amount FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.level = whs.level
);


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

SELECT code FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.code = lne.code
);


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

SELECT value FROM products AS inv
WHERE code IN (
    SELECT code FROM orders AS schd
    WHERE schd.level = inv.level
);


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

SELECT name FROM orders AS sale
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.status = sale.status
);


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

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


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

SELECT salary FROM warehouses AS prod
WHERE level IN (
    SELECT level FROM transactions AS schd
    WHERE schd.code = prod.code
);


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

SELECT value FROM transactions AS lne
WHERE amount > (
    SELECT MIN(salary) FROM suppliers AS emp
    WHERE emp.status = lne.status
);


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

SELECT amount FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.code = shp.code
);


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

SELECT id FROM shipments AS dept
WHERE code IN (
    SELECT code FROM warehouses AS shp
    WHERE shp.level = dept.level
);


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

SELECT value FROM invoices AS mgr
WHERE amount > (
    SELECT MIN(value) FROM projects AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT value FROM departments AS prod
WHERE value > (
    SELECT MIN(value) FROM accounts AS lne
    WHERE lne.type = prod.type
);


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

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


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

SELECT code FROM departments AS txn
WHERE type IN (
    SELECT type FROM tasks AS empl
    WHERE empl.level = txn.level
);


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

SELECT salary FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT amount FROM employees AS shp
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT amount FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.status = cust.status
);


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

SELECT code FROM suppliers AS txn
WHERE type IN (
    SELECT type FROM warehouses AS schd
    WHERE schd.status = txn.status
);


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

SELECT amount FROM employees AS prod
WHERE salary > (
    SELECT MIN(amount) FROM tasks AS schd
    WHERE schd.id = prod.id
);


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

SELECT code FROM shipments AS mgr
WHERE level IN (
    SELECT level FROM departments AS prod
    WHERE prod.id = mgr.id
);


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

SELECT code FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM products AS budg
    WHERE budg.status = rgn.status
);


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

SELECT name FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.code = txn.code
);


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

SELECT value FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.level = prod.level
);


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

SELECT salary FROM invoices AS mgr
WHERE id IN (
    SELECT id FROM transactions AS lne
    WHERE lne.level = mgr.level
);


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

SELECT code FROM customers AS whs
WHERE code IN (
    SELECT code FROM invoices AS mgr
    WHERE mgr.code = whs.code
);


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

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


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

SELECT salary FROM categories AS inv
WHERE type IN (
    SELECT type FROM orders AS acct
    WHERE acct.id = inv.id
);


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

SELECT name FROM employees AS sale
WHERE type IN (
    SELECT type FROM branches AS txn
    WHERE txn.level = sale.level
);


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

SELECT code FROM orders AS srvc
WHERE value > (
    SELECT COUNT(value) FROM transactions AS dept
    WHERE dept.type = srvc.type
);


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

SELECT salary FROM employees AS txn
WHERE id IN (
    SELECT id FROM accounts AS mgr
    WHERE mgr.id = txn.id
);


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

SELECT name FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.type = ord.type
);


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

SELECT value FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.code = ord.code
);


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

SELECT salary FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.id = sale.id
);


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

SELECT code FROM employees AS catg
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS prod
    WHERE prod.level = catg.level
);


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

SELECT id FROM customers AS emp
WHERE id IN (
    SELECT id FROM products AS srvc
    WHERE srvc.id = emp.id
);


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

SELECT amount FROM warehouses AS cust
WHERE value > (
    SELECT MAX(value) FROM invoices AS inv
    WHERE inv.type = cust.type
);


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

SELECT id FROM accounts AS shp
WHERE amount > (
    SELECT COUNT(value) FROM regions AS emp
    WHERE emp.id = shp.id
);


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

SELECT value FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.type = emp.type
);


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

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


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

SELECT name FROM tasks AS cust
WHERE value > (
    SELECT SUM(value) FROM projects AS budg
    WHERE budg.type = cust.type
);


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

SELECT value FROM categories AS inv
WHERE id IN (
    SELECT id FROM accounts AS srvc
    WHERE srvc.type = inv.type
);


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

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


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

SELECT id FROM warehouses AS budg
WHERE value > (
    SELECT MAX(value) FROM products AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT code FROM regions AS mgr
WHERE value > (
    SELECT MIN(salary) FROM transactions AS inv
    WHERE inv.level = mgr.level
);


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

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


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

SELECT code FROM warehouses AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM categories AS sale
    WHERE sale.id = ordr.id
);


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

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


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

SELECT code FROM departments AS emp
WHERE amount > (
    SELECT MAX(value) FROM projects AS ord
    WHERE ord.status = emp.status
);


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

SELECT value FROM transactions AS prod
WHERE id IN (
    SELECT id FROM products AS schd
    WHERE schd.status = prod.status
);


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

SELECT amount FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.level = inv.level
);