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

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


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

SELECT id FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.level = budg.level
);


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

SELECT salary FROM projects AS inv
WHERE type IN (
    SELECT type FROM suppliers AS dept
    WHERE dept.level = inv.level
);


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

SELECT id FROM departments AS acct
WHERE status IN (
    SELECT status FROM customers AS budg
    WHERE budg.code = acct.code
);


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

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


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

SELECT code FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.status = txn.status
);


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

SELECT code FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.code = srvc.code
);


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

SELECT code FROM branches AS dept
WHERE code IN (
    SELECT code FROM categories AS txn
    WHERE txn.type = dept.type
);


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

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


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

SELECT value FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = acct.level
);


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

SELECT amount FROM projects AS budg
WHERE status IN (
    SELECT status FROM warehouses AS ord
    WHERE ord.status = budg.status
);


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

SELECT salary FROM warehouses AS prod
WHERE salary > (
    SELECT COUNT(value) FROM departments AS budg
    WHERE budg.code = prod.code
);


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

SELECT salary FROM invoices AS sale
WHERE amount > (
    SELECT SUM(amount) FROM categories AS empl
    WHERE empl.status = sale.status
);


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

SELECT name FROM suppliers AS mgr
WHERE id IN (
    SELECT id FROM accounts AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT name FROM suppliers AS whs
WHERE status IN (
    SELECT status FROM projects AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT salary FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT id FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = ordr.level
);


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

SELECT value FROM branches AS empl
WHERE amount > (
    SELECT MAX(salary) FROM projects AS sale
    WHERE sale.code = empl.code
);


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

SELECT id FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.level = ord.level
);


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

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


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

SELECT name FROM employees AS srvc
WHERE level IN (
    SELECT level FROM transactions AS ord
    WHERE ord.type = srvc.type
);


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

SELECT id FROM branches AS txn
WHERE amount > (
    SELECT MIN(amount) FROM employees AS empl
    WHERE empl.status = txn.status
);


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

SELECT name FROM categories AS ordr
WHERE code IN (
    SELECT code FROM invoices AS lne
    WHERE lne.level = ordr.level
);


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

SELECT value FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.level = prod.level
);


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

SELECT name FROM orders AS txn
WHERE status IN (
    SELECT status FROM accounts AS shp
    WHERE shp.code = txn.code
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.type = dept.type
);


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

SELECT id FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.type = rgn.type
);


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

SELECT amount FROM suppliers AS acct
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT id FROM projects AS acct
WHERE amount > (
    SELECT MIN(amount) FROM orders AS cust
    WHERE cust.id = acct.id
);


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

SELECT salary FROM branches AS catg
WHERE code IN (
    SELECT code FROM shipments AS lne
    WHERE lne.level = catg.level
);


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

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


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

SELECT amount FROM branches AS dept
WHERE code IN (
    SELECT code FROM regions AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT name FROM products AS dept
WHERE amount > (
    SELECT SUM(amount) FROM projects AS cust
    WHERE cust.code = dept.code
);


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

SELECT name FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT salary FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.id = mgr.id
);


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

SELECT code FROM regions AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM products AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT id FROM branches AS catg
WHERE code IN (
    SELECT code FROM projects AS dept
    WHERE dept.id = catg.id
);


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

SELECT amount FROM transactions AS txn
WHERE code IN (
    SELECT code FROM warehouses AS srvc
    WHERE srvc.type = txn.type
);


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

SELECT value FROM products AS shp
WHERE value > (
    SELECT MAX(value) FROM transactions AS ordr
    WHERE ordr.code = shp.code
);


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

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


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

SELECT code FROM orders AS srvc
WHERE status IN (
    SELECT status FROM invoices AS sale
    WHERE sale.code = srvc.code
);


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

SELECT salary FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.type = txn.type
);


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

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


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

SELECT name FROM products AS empl
WHERE salary > (
    SELECT MIN(salary) FROM categories AS catg
    WHERE catg.level = empl.level
);


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

SELECT amount FROM suppliers AS shp
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.type = shp.type
);


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

SELECT salary FROM tasks AS whs
WHERE id IN (
    SELECT id FROM accounts AS sale
    WHERE sale.level = whs.level
);


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

SELECT name FROM orders AS empl
WHERE level IN (
    SELECT level FROM accounts AS lne
    WHERE lne.code = empl.code
);


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

SELECT name FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.type = schd.type
);


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

SELECT id FROM regions AS inv
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.level = inv.level
);


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

SELECT value FROM products AS ordr
WHERE code IN (
    SELECT code FROM warehouses AS prod
    WHERE prod.status = ordr.status
);


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

SELECT amount FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.id = dept.id
);


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

SELECT code FROM products AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS catg
    WHERE catg.code = mgr.code
);


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

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


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

SELECT name FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT amount FROM branches AS schd
WHERE id IN (
    SELECT id FROM projects AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT code FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.level = cust.level
);


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

SELECT amount FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.type = prod.type
);


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

SELECT salary FROM employees AS txn
WHERE salary > (
    SELECT AVG(value) FROM projects AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT amount FROM shipments AS srvc
WHERE value > (
    SELECT COUNT(salary) FROM categories AS emp
    WHERE emp.type = srvc.type
);


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

SELECT code FROM tasks AS shp
WHERE level IN (
    SELECT level FROM products AS budg
    WHERE budg.id = shp.id
);


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

SELECT value FROM projects AS emp
WHERE status IN (
    SELECT status FROM customers AS acct
    WHERE acct.status = emp.status
);


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

SELECT amount FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.type = empl.type
);


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

SELECT amount FROM warehouses AS empl
WHERE salary > (
    SELECT MIN(value) FROM invoices AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT value FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.id = sale.id
);


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

SELECT value FROM warehouses AS budg
WHERE salary > (
    SELECT SUM(salary) FROM regions AS empl
    WHERE empl.code = budg.code
);


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

SELECT name FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.level = emp.level
);


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

SELECT amount FROM customers AS whs
WHERE status IN (
    SELECT status FROM regions AS acct
    WHERE acct.id = whs.id
);


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

SELECT code FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.id = budg.id
);


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

SELECT salary FROM products AS ord
WHERE code IN (
    SELECT code FROM accounts AS whs
    WHERE whs.code = ord.code
);


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

SELECT amount FROM projects AS cust
WHERE value > (
    SELECT MIN(value) FROM employees AS mgr
    WHERE mgr.id = cust.id
);


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

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


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

SELECT name FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = lne.code
);


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

SELECT code FROM projects AS shp
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.code = shp.code
);


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

SELECT value FROM projects AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM tasks AS ord
    WHERE ord.status = rgn.status
);


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

SELECT id FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.code = ordr.code
);


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

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


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

SELECT salary FROM suppliers AS dept
WHERE value > (
    SELECT MIN(amount) FROM accounts AS lne
    WHERE lne.code = dept.code
);


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

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


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

SELECT name FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.level = catg.level
);


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

SELECT code FROM branches AS emp
WHERE code IN (
    SELECT code FROM products AS ord
    WHERE ord.status = emp.status
);


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

SELECT salary FROM regions AS schd
WHERE code IN (
    SELECT code FROM tasks AS catg
    WHERE catg.type = schd.type
);


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

SELECT salary FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.code = txn.code
);


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

SELECT value FROM customers AS empl
WHERE value > (
    SELECT MIN(salary) FROM products AS catg
    WHERE catg.code = empl.code
);


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

SELECT value FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.type = acct.type
);


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

SELECT name FROM products AS dept
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS cust
    WHERE cust.id = dept.id
);


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

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


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

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


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

SELECT value FROM tasks AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS dept
    WHERE dept.code = shp.code
);


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

SELECT code FROM tasks AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS rgn
    WHERE rgn.code = ordr.code
);


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

SELECT id FROM transactions AS empl
WHERE status IN (
    SELECT status FROM customers AS shp
    WHERE shp.type = empl.type
);


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

SELECT id FROM warehouses AS cust
WHERE status IN (
    SELECT status FROM invoices AS dept
    WHERE dept.type = cust.type
);


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

SELECT salary FROM products AS srvc
WHERE code IN (
    SELECT code FROM orders AS acct
    WHERE acct.id = srvc.id
);


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

SELECT id FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.code = inv.code
);


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

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


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

SELECT id FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.code = empl.code
);


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

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


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

SELECT name FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.id = ordr.id
);


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

SELECT value FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.id = dept.id
);


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

SELECT value FROM categories AS acct
WHERE value > (
    SELECT COUNT(value) FROM employees AS lne
    WHERE lne.type = acct.type
);


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

SELECT name FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.code = whs.code
);


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

SELECT value FROM categories AS ordr
WHERE id IN (
    SELECT id FROM suppliers AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT value FROM suppliers AS schd
WHERE id IN (
    SELECT id FROM orders AS shp
    WHERE shp.id = schd.id
);


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

SELECT value FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.level = srvc.level
);


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

SELECT code FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT id FROM regions AS emp
WHERE salary > (
    SELECT MIN(value) FROM tasks AS catg
    WHERE catg.status = emp.status
);


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

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


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

SELECT code FROM orders AS ord
WHERE status IN (
    SELECT status FROM products AS lne
    WHERE lne.type = ord.type
);


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

SELECT salary FROM suppliers AS schd
WHERE id IN (
    SELECT id FROM departments AS acct
    WHERE acct.code = schd.code
);


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

SELECT code FROM transactions AS sale
WHERE salary > (
    SELECT MAX(value) FROM projects AS prod
    WHERE prod.level = sale.level
);


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

SELECT salary FROM departments AS rgn
WHERE amount > (
    SELECT AVG(value) FROM employees AS sale
    WHERE sale.code = rgn.code
);


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

SELECT amount FROM projects AS schd
WHERE level IN (
    SELECT level FROM branches AS cust
    WHERE cust.code = schd.code
);


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

SELECT code FROM departments AS cust
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS shp
    WHERE shp.type = cust.type
);


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

SELECT value FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.level = emp.level
);


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

SELECT value FROM projects AS inv
WHERE status IN (
    SELECT status FROM regions AS txn
    WHERE txn.code = inv.code
);


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

SELECT name FROM departments AS schd
WHERE id IN (
    SELECT id FROM warehouses AS dept
    WHERE dept.code = schd.code
);


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

SELECT name FROM regions AS lne
WHERE value > (
    SELECT SUM(value) FROM departments AS cust
    WHERE cust.status = lne.status
);


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

SELECT id FROM transactions AS cust
WHERE status IN (
    SELECT status FROM employees AS whs
    WHERE whs.code = cust.code
);


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

SELECT id FROM products AS srvc
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.status = srvc.status
);


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

SELECT salary FROM projects AS txn
WHERE value > (
    SELECT COUNT(value) FROM orders AS sale
    WHERE sale.id = txn.id
);


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

SELECT salary FROM shipments AS cust
WHERE amount > (
    SELECT AVG(value) FROM invoices AS acct
    WHERE acct.level = cust.level
);


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

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


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

SELECT name FROM projects AS shp
WHERE code IN (
    SELECT code FROM warehouses AS prod
    WHERE prod.status = shp.status
);


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

SELECT value FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.id = ord.id
);


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

SELECT salary FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.id = empl.id
);


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

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


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

SELECT code FROM warehouses AS sale
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS dept
    WHERE dept.id = sale.id
);


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

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


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

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


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

SELECT id FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.id = lne.id
);


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

SELECT code FROM products AS txn
WHERE code IN (
    SELECT code FROM projects AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT value FROM customers AS dept
WHERE level IN (
    SELECT level FROM projects AS txn
    WHERE txn.status = dept.status
);


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

SELECT id FROM shipments AS inv
WHERE salary > (
    SELECT AVG(amount) FROM departments AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT code FROM projects AS empl
WHERE status IN (
    SELECT status FROM tasks AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT id FROM suppliers AS whs
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT value FROM projects AS sale
WHERE type IN (
    SELECT type FROM branches AS catg
    WHERE catg.code = sale.code
);


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

SELECT name FROM departments AS emp
WHERE amount > (
    SELECT AVG(salary) FROM orders AS txn
    WHERE txn.level = emp.level
);


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

SELECT code FROM products AS mgr
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.id = mgr.id
);


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

SELECT salary FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.type = dept.type
);


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

SELECT name FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT code FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.level = empl.level
);


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

SELECT salary FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.id = ord.id
);


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

SELECT amount FROM orders AS dept
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.code = dept.code
);


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

SELECT salary FROM projects AS empl
WHERE status IN (
    SELECT status FROM branches AS lne
    WHERE lne.level = empl.level
);


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

SELECT name FROM branches AS empl
WHERE id IN (
    SELECT id FROM tasks AS catg
    WHERE catg.level = empl.level
);


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

SELECT amount FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.type = sale.type
);


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

SELECT amount FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.code = lne.code
);


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT name FROM employees AS emp
WHERE status IN (
    SELECT status FROM products AS acct
    WHERE acct.code = emp.code
);


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

SELECT code FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.code = budg.code
);


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

SELECT name FROM invoices AS schd
WHERE amount > (
    SELECT SUM(amount) FROM transactions AS emp
    WHERE emp.status = schd.status
);


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

SELECT value FROM customers AS mgr
WHERE status IN (
    SELECT status FROM suppliers AS inv
    WHERE inv.type = mgr.type
);


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

SELECT salary FROM departments AS budg
WHERE value > (
    SELECT MAX(amount) FROM invoices AS inv
    WHERE inv.type = budg.type
);


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

SELECT amount FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT id FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT value FROM products AS srvc
WHERE value > (
    SELECT COUNT(salary) FROM departments AS emp
    WHERE emp.type = srvc.type
);


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

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


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

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


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

SELECT name FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.id = catg.id
);


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

SELECT code FROM transactions AS cust
WHERE value > (
    SELECT MIN(salary) FROM shipments AS sale
    WHERE sale.code = cust.code
);


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

SELECT code FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.id = inv.id
);


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

SELECT amount FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.type = cust.type
);


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

SELECT code FROM invoices AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT value FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.level = acct.level
);


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

SELECT id FROM projects AS inv
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS whs
    WHERE whs.level = inv.level
);


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

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


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

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


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

SELECT salary FROM accounts AS ord
WHERE code IN (
    SELECT code FROM projects AS shp
    WHERE shp.status = ord.status
);


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

SELECT id FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.type = prod.type
);


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

SELECT name FROM invoices AS lne
WHERE salary > (
    SELECT SUM(value) FROM branches AS sale
    WHERE sale.id = lne.id
);


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

SELECT value FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.status = ordr.status
);


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

SELECT code FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.id = acct.id
);


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

SELECT id FROM transactions AS txn
WHERE status IN (
    SELECT status FROM customers AS catg
    WHERE catg.status = txn.status
);


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

SELECT value FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT name FROM projects AS ord
WHERE status IN (
    SELECT status FROM accounts AS whs
    WHERE whs.code = ord.code
);


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

SELECT salary FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = empl.code
);


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

SELECT name FROM orders AS ordr
WHERE value > (
    SELECT MAX(salary) FROM accounts AS prod
    WHERE prod.level = ordr.level
);


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

SELECT name FROM employees AS srvc
WHERE id IN (
    SELECT id FROM accounts AS cust
    WHERE cust.type = srvc.type
);


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

SELECT id FROM transactions AS ordr
WHERE value > (
    SELECT SUM(amount) FROM customers AS schd
    WHERE schd.type = ordr.type
);


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

SELECT salary FROM departments AS lne
WHERE salary > (
    SELECT MIN(value) FROM shipments AS schd
    WHERE schd.level = lne.level
);


Prompt:
Schema:
  branches (alias: dept)(date, amount, id, level)
  transactions(name, amount, id, status)
Task: Retrieve salary from branches with amount above the AVG(amount) of transactions rows sharing the same id.
SQL:

SELECT salary FROM branches AS dept
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS cust
    WHERE cust.id = dept.id
);


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

SELECT salary FROM shipments AS ordr
WHERE level IN (
    SELECT level FROM regions AS schd
    WHERE schd.level = ordr.level
);


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

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


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

SELECT code FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.status = ordr.status
);


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

SELECT salary FROM categories AS inv
WHERE type IN (
    SELECT type FROM accounts AS srvc
    WHERE srvc.code = inv.code
);


Prompt:
Schema:
  customers (alias: prod)(id, name, amount, type)
  shipments(value, status, name, type)
Task: Retrieve name from customers with value above the AVG(value) of shipments rows sharing the same status.
SQL:

SELECT name FROM customers AS prod
WHERE value > (
    SELECT AVG(value) FROM shipments AS sale
    WHERE sale.status = prod.status
);


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

SELECT salary FROM customers AS budg
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS rgn
    WHERE rgn.type = budg.type
);


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

SELECT name FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.code = emp.code
);


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

SELECT salary FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = budg.code
);


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

SELECT value FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.id = emp.id
);


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

SELECT id FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.status = catg.status
);


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

SELECT id FROM products AS rgn
WHERE value > (
    SELECT AVG(amount) FROM orders AS whs
    WHERE whs.type = rgn.type
);


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

SELECT code FROM departments AS ord
WHERE salary > (
    SELECT AVG(value) FROM categories AS lne
    WHERE lne.code = ord.code
);


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

SELECT id FROM warehouses AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS emp
    WHERE emp.id = sale.id
);


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

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


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

SELECT name FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.code = shp.code
);


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

SELECT code FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.status = mgr.status
);


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

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


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

SELECT salary FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.type = schd.type
);


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

SELECT code FROM shipments AS emp
WHERE type IN (
    SELECT type FROM departments AS ord
    WHERE ord.id = emp.id
);


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

SELECT value FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.type = empl.type
);


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

SELECT salary FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.status = srvc.status
);


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

SELECT salary FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.type = lne.type
);


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

SELECT name FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.status = cust.status
);


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

SELECT amount FROM warehouses AS mgr
WHERE status IN (
    SELECT status FROM suppliers AS emp
    WHERE emp.level = mgr.level
);


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

SELECT id FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.type = shp.type
);


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

SELECT id FROM transactions AS catg
WHERE type IN (
    SELECT type FROM accounts AS srvc
    WHERE srvc.type = catg.type
);


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

SELECT name FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT name FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.id = inv.id
);


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

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


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

SELECT value FROM branches AS shp
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS sale
    WHERE sale.status = shp.status
);


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

SELECT code FROM accounts AS schd
WHERE level IN (
    SELECT level FROM categories AS txn
    WHERE txn.status = schd.status
);


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

SELECT name FROM transactions AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM employees AS sale
    WHERE sale.type = srvc.type
);


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

SELECT value FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.code = catg.code
);


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

SELECT id FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.code = prod.code
);


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

SELECT amount FROM suppliers AS acct
WHERE level IN (
    SELECT level FROM orders AS schd
    WHERE schd.code = acct.code
);


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

SELECT amount FROM invoices AS emp
WHERE salary > (
    SELECT SUM(value) FROM accounts AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT value FROM branches AS catg
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS cust
    WHERE cust.status = catg.status
);


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

SELECT code FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.level = srvc.level
);


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

SELECT salary FROM categories AS txn
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.type = txn.type
);


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

SELECT amount FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.status = dept.status
);


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

SELECT amount FROM departments AS budg
WHERE code IN (
    SELECT code FROM customers AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT value FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.code = srvc.code
);


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

SELECT amount FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.code = ordr.code
);


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

SELECT salary FROM branches AS whs
WHERE value > (
    SELECT AVG(value) FROM projects AS dept
    WHERE dept.type = whs.type
);


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

SELECT value FROM employees AS catg
WHERE value > (
    SELECT SUM(value) FROM regions AS ord
    WHERE ord.status = catg.status
);


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

SELECT name FROM accounts AS schd
WHERE amount > (
    SELECT AVG(amount) FROM categories AS whs
    WHERE whs.type = schd.type
);


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

SELECT id FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.status = mgr.status
);


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

SELECT value FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT code FROM products AS schd
WHERE code IN (
    SELECT code FROM categories AS emp
    WHERE emp.type = schd.type
);


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

SELECT id FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = txn.type
);


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

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


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

SELECT name FROM transactions AS rgn
WHERE status IN (
    SELECT status FROM accounts AS srvc
    WHERE srvc.level = rgn.level
);


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

SELECT code FROM orders AS srvc
WHERE code IN (
    SELECT code FROM shipments AS empl
    WHERE empl.type = srvc.type
);


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

SELECT amount FROM customers AS ord
WHERE level IN (
    SELECT level FROM products AS inv
    WHERE inv.level = ord.level
);


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

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


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

SELECT salary FROM categories AS srvc
WHERE code IN (
    SELECT code FROM tasks AS budg
    WHERE budg.level = srvc.level
);


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

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


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

SELECT name FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.type = ord.type
);


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

SELECT value FROM tasks AS emp
WHERE type IN (
    SELECT type FROM customers AS dept
    WHERE dept.code = emp.code
);


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

SELECT name FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.id = budg.id
);


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

SELECT salary FROM transactions AS inv
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS empl
    WHERE empl.id = inv.id
);


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

SELECT code FROM departments AS srvc
WHERE amount > (
    SELECT MAX(value) FROM regions AS empl
    WHERE empl.level = srvc.level
);


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

SELECT value FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.type = mgr.type
);


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

SELECT name FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.id = shp.id
);


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

SELECT value FROM orders AS mgr
WHERE value > (
    SELECT SUM(salary) FROM categories AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT id FROM departments AS catg
WHERE status IN (
    SELECT status FROM regions AS acct
    WHERE acct.level = catg.level
);


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

SELECT amount FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT amount FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.id = acct.id
);


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

SELECT value FROM products AS txn
WHERE value > (
    SELECT SUM(amount) FROM tasks AS empl
    WHERE empl.code = txn.code
);


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

SELECT amount FROM orders AS txn
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS dept
    WHERE dept.level = txn.level
);


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

SELECT id FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.status = txn.status
);


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

SELECT salary FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.status = shp.status
);


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

SELECT value FROM invoices AS cust
WHERE code IN (
    SELECT code FROM tasks AS acct
    WHERE acct.level = cust.level
);


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

SELECT name FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.status = srvc.status
);


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

SELECT id FROM shipments AS lne
WHERE code IN (
    SELECT code FROM categories AS budg
    WHERE budg.type = lne.type
);


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

SELECT salary FROM branches AS budg
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS lne
    WHERE lne.status = budg.status
);


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

SELECT id FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.type = whs.type
);


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

SELECT name FROM branches AS mgr
WHERE code IN (
    SELECT code FROM regions AS acct
    WHERE acct.code = mgr.code
);


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

SELECT amount FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT code FROM orders AS budg
WHERE salary > (
    SELECT SUM(value) FROM branches AS cust
    WHERE cust.code = budg.code
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.code = srvc.code
);


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

SELECT name FROM orders AS rgn
WHERE type IN (
    SELECT type FROM tasks AS dept
    WHERE dept.level = rgn.level
);


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

SELECT name FROM warehouses AS empl
WHERE type IN (
    SELECT type FROM categories AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT name FROM shipments AS budg
WHERE amount > (
    SELECT MAX(amount) FROM projects AS emp
    WHERE emp.status = budg.status
);


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

SELECT salary FROM employees AS empl
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS cust
    WHERE cust.level = empl.level
);


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

SELECT name FROM employees AS txn
WHERE level IN (
    SELECT level FROM products AS whs
    WHERE whs.type = txn.type
);


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

SELECT value FROM accounts AS lne
WHERE code IN (
    SELECT code FROM departments AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT value FROM regions AS prod
WHERE value > (
    SELECT MIN(value) FROM products AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT name FROM suppliers AS emp
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.status = emp.status
);


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

SELECT salary FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.id = txn.id
);


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

SELECT value FROM customers AS budg
WHERE salary > (
    SELECT MIN(salary) FROM regions AS srvc
    WHERE srvc.code = budg.code
);


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

SELECT name FROM orders AS catg
WHERE value > (
    SELECT MAX(value) FROM accounts AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT salary FROM employees AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM categories AS lne
    WHERE lne.type = ordr.type
);


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

SELECT name FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.code = acct.code
);


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

SELECT id FROM branches AS shp
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS txn
    WHERE txn.id = shp.id
);


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

SELECT value FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.id = ord.id
);


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

SELECT name FROM departments AS shp
WHERE level IN (
    SELECT level FROM orders AS txn
    WHERE txn.status = shp.status
);


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

SELECT amount FROM branches AS txn
WHERE type IN (
    SELECT type FROM shipments AS whs
    WHERE whs.type = txn.type
);


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

SELECT salary FROM branches AS srvc
WHERE code IN (
    SELECT code FROM projects AS inv
    WHERE inv.id = srvc.id
);


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

SELECT salary FROM shipments AS sale
WHERE value > (
    SELECT COUNT(amount) FROM transactions AS txn
    WHERE txn.code = sale.code
);


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

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


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

SELECT value FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.level = dept.level
);


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

SELECT id FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.type = ord.type
);


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

SELECT code FROM orders AS acct
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.status = acct.status
);


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

SELECT id FROM tasks AS ordr
WHERE salary > (
    SELECT COUNT(salary) FROM transactions AS ord
    WHERE ord.type = ordr.type
);


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

SELECT amount FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.code = prod.code
);


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

SELECT salary FROM regions AS whs
WHERE value > (
    SELECT SUM(value) FROM branches AS emp
    WHERE emp.level = whs.level
);


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

SELECT id FROM tasks AS emp
WHERE code IN (
    SELECT code FROM shipments AS schd
    WHERE schd.id = emp.id
);


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

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


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

SELECT amount FROM products AS rgn
WHERE code IN (
    SELECT code FROM shipments AS inv
    WHERE inv.code = rgn.code
);


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

SELECT name FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.status = srvc.status
);