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

SELECT value FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.id = cust.id
);


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

SELECT salary FROM categories AS prod
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT id FROM products AS ord
WHERE value > (
    SELECT AVG(salary) FROM projects AS lne
    WHERE lne.type = ord.type
);


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

SELECT salary FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT code FROM branches AS dept
WHERE code IN (
    SELECT code FROM invoices AS ordr
    WHERE ordr.level = dept.level
);


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

SELECT name FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.status = lne.status
);


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

SELECT id FROM customers AS sale
WHERE level IN (
    SELECT level FROM tasks AS lne
    WHERE lne.status = sale.status
);


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

SELECT id FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.status = emp.status
);


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

SELECT salary FROM suppliers AS mgr
WHERE id IN (
    SELECT id FROM branches AS acct
    WHERE acct.type = mgr.type
);


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

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


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

SELECT name FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.id = empl.id
);


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

SELECT salary FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.type = srvc.type
);


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

SELECT code FROM projects AS mgr
WHERE type IN (
    SELECT type FROM accounts AS sale
    WHERE sale.id = mgr.id
);


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

SELECT name FROM shipments AS lne
WHERE code IN (
    SELECT code FROM regions AS emp
    WHERE emp.code = lne.code
);


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

SELECT salary FROM projects AS ordr
WHERE level IN (
    SELECT level FROM categories AS prod
    WHERE prod.type = ordr.type
);


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

SELECT salary FROM warehouses AS txn
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS inv
    WHERE inv.type = txn.type
);


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

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


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

SELECT salary FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.type = schd.type
);


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

SELECT code FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.code = catg.code
);


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

SELECT name FROM warehouses AS sale
WHERE value > (
    SELECT MIN(salary) FROM accounts AS acct
    WHERE acct.status = sale.status
);


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

SELECT value FROM categories AS shp
WHERE type IN (
    SELECT type FROM regions AS whs
    WHERE whs.id = shp.id
);


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

SELECT id FROM transactions AS inv
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS whs
    WHERE whs.type = inv.type
);


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

SELECT id FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT name FROM transactions AS dept
WHERE value > (
    SELECT AVG(value) FROM branches AS txn
    WHERE txn.status = dept.status
);


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

SELECT name FROM suppliers AS dept
WHERE value > (
    SELECT SUM(salary) FROM projects AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT amount FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.level = txn.level
);


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

SELECT name FROM employees AS txn
WHERE status IN (
    SELECT status FROM invoices AS mgr
    WHERE mgr.type = txn.type
);


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

SELECT code FROM customers AS cust
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.type = cust.type
);


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

SELECT amount FROM tasks AS inv
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS catg
    WHERE catg.id = inv.id
);


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

SELECT name FROM projects AS dept
WHERE code IN (
    SELECT code FROM shipments AS prod
    WHERE prod.code = dept.code
);


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

SELECT id FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.status = shp.status
);


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

SELECT id FROM suppliers AS txn
WHERE type IN (
    SELECT type FROM customers AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT value FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.type = sale.type
);


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

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


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

SELECT name FROM accounts AS whs
WHERE type IN (
    SELECT type FROM products AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT salary FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT value FROM invoices AS sale
WHERE type IN (
    SELECT type FROM departments AS whs
    WHERE whs.status = sale.status
);


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

SELECT value FROM shipments AS srvc
WHERE value > (
    SELECT COUNT(value) FROM products AS empl
    WHERE empl.level = srvc.level
);


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

SELECT name FROM departments AS cust
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT amount FROM categories AS ord
WHERE value > (
    SELECT MIN(salary) FROM branches AS dept
    WHERE dept.status = ord.status
);


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

SELECT id FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT id FROM warehouses AS catg
WHERE level IN (
    SELECT level FROM employees AS shp
    WHERE shp.id = catg.id
);


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

SELECT id FROM tasks AS cust
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS empl
    WHERE empl.status = cust.status
);


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

SELECT salary FROM projects AS schd
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS catg
    WHERE catg.id = schd.id
);


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

SELECT id FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.code = cust.code
);


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

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


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

SELECT code FROM tasks AS mgr
WHERE amount > (
    SELECT MIN(amount) FROM orders AS catg
    WHERE catg.id = mgr.id
);


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

SELECT code FROM accounts AS shp
WHERE id IN (
    SELECT id FROM transactions AS srvc
    WHERE srvc.id = shp.id
);


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

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


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

SELECT value FROM regions AS rgn
WHERE status IN (
    SELECT status FROM projects AS ord
    WHERE ord.level = rgn.level
);


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

SELECT amount FROM tasks AS lne
WHERE level IN (
    SELECT level FROM branches AS budg
    WHERE budg.level = lne.level
);


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

SELECT code FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.status = prod.status
);


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

SELECT id FROM products AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS schd
    WHERE schd.status = ord.status
);


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

SELECT name FROM categories AS catg
WHERE code IN (
    SELECT code FROM branches AS acct
    WHERE acct.code = catg.code
);


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

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


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

SELECT amount FROM shipments AS acct
WHERE amount > (
    SELECT SUM(amount) FROM products AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT code FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.status = cust.status
);


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

SELECT salary FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.type = dept.type
);


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

SELECT id FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = dept.id
);


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

SELECT name FROM orders AS catg
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS budg
    WHERE budg.status = catg.status
);


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

SELECT name FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.code = dept.code
);


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

SELECT salary FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.id = emp.id
);


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

SELECT name FROM invoices AS txn
WHERE salary > (
    SELECT MAX(amount) FROM tasks AS schd
    WHERE schd.id = txn.id
);


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

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


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

SELECT salary FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.code = shp.code
);


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

SELECT value FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.level = prod.level
);


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

SELECT value FROM branches AS ordr
WHERE amount > (
    SELECT AVG(value) FROM employees AS txn
    WHERE txn.status = ordr.status
);


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

SELECT name FROM transactions AS dept
WHERE salary > (
    SELECT MIN(value) FROM accounts AS ord
    WHERE ord.level = dept.level
);


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

SELECT salary FROM transactions AS whs
WHERE level IN (
    SELECT level FROM warehouses AS emp
    WHERE emp.id = whs.id
);


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

SELECT salary FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT id FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.status = acct.status
);


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

SELECT salary FROM tasks AS cust
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS emp
    WHERE emp.level = cust.level
);


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

SELECT name FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT amount FROM warehouses AS inv
WHERE level IN (
    SELECT level FROM projects AS prod
    WHERE prod.level = inv.level
);


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

SELECT id FROM warehouses AS sale
WHERE amount > (
    SELECT MIN(value) FROM employees AS inv
    WHERE inv.level = sale.level
);


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

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


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

SELECT id FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT amount FROM employees AS empl
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.code = empl.code
);


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

SELECT code FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.type = mgr.type
);


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

SELECT name FROM invoices AS whs
WHERE value > (
    SELECT MIN(salary) FROM shipments AS empl
    WHERE empl.code = whs.code
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.type = dept.type
);


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

SELECT id FROM invoices AS lne
WHERE code IN (
    SELECT code FROM regions AS inv
    WHERE inv.code = lne.code
);


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

SELECT code FROM tasks AS catg
WHERE value > (
    SELECT SUM(salary) FROM shipments AS prod
    WHERE prod.id = catg.id
);


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

SELECT name FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.status = schd.status
);


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

SELECT id FROM warehouses AS inv
WHERE id IN (
    SELECT id FROM invoices AS lne
    WHERE lne.status = inv.status
);


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

SELECT amount FROM warehouses AS acct
WHERE code IN (
    SELECT code FROM branches AS ord
    WHERE ord.level = acct.level
);


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

SELECT id FROM employees AS catg
WHERE level IN (
    SELECT level FROM departments AS empl
    WHERE empl.level = catg.level
);


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

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


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

SELECT code FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.status = inv.status
);


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

SELECT salary FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT salary FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT name FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.code = schd.code
);


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

SELECT code FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.code = shp.code
);


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

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


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

SELECT amount FROM employees AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM branches AS txn
    WHERE txn.id = ordr.id
);


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

SELECT amount FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.level = ordr.level
);


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

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


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

SELECT name FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.status = ord.status
);


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

SELECT amount FROM customers AS shp
WHERE status IN (
    SELECT status FROM projects AS whs
    WHERE whs.type = shp.type
);


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

SELECT code FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.id = budg.id
);


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

SELECT value FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = lne.level
);


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

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


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

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


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

SELECT name FROM shipments AS prod
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS budg
    WHERE budg.level = prod.level
);


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

SELECT code FROM branches AS acct
WHERE value > (
    SELECT MAX(salary) FROM products AS dept
    WHERE dept.id = acct.id
);


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

SELECT salary FROM accounts AS shp
WHERE status IN (
    SELECT status FROM transactions AS emp
    WHERE emp.status = shp.status
);


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

SELECT code FROM orders AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT name FROM departments AS mgr
WHERE type IN (
    SELECT type FROM suppliers AS txn
    WHERE txn.level = mgr.level
);


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

SELECT code FROM employees AS shp
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS lne
    WHERE lne.status = shp.status
);


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

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


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

SELECT name FROM categories AS ord
WHERE status IN (
    SELECT status FROM shipments AS lne
    WHERE lne.level = ord.level
);


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

SELECT value FROM customers AS emp
WHERE level IN (
    SELECT level FROM transactions AS lne
    WHERE lne.type = emp.type
);


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

SELECT code FROM tasks AS lne
WHERE status IN (
    SELECT status FROM employees AS cust
    WHERE cust.level = lne.level
);


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

SELECT name FROM warehouses AS prod
WHERE amount > (
    SELECT MAX(salary) FROM suppliers AS txn
    WHERE txn.type = prod.type
);


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

SELECT code FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.status = lne.status
);


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

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


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

SELECT value FROM employees AS ord
WHERE value > (
    SELECT MIN(amount) FROM customers AS emp
    WHERE emp.id = ord.id
);


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

SELECT id FROM customers AS dept
WHERE amount > (
    SELECT MAX(salary) FROM suppliers AS empl
    WHERE empl.type = dept.type
);


Prompt:
Schema:
  tasks (alias: dept)(level, name, id, salary)
  projects(level, amount, salary, value)
Task: Retrieve amount from tasks with salary above the AVG(salary) of projects rows sharing the same level.
SQL:

SELECT amount FROM tasks AS dept
WHERE salary > (
    SELECT AVG(salary) FROM projects AS ord
    WHERE ord.level = dept.level
);


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

SELECT id FROM warehouses AS txn
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.status = txn.status
);


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

SELECT value FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT code FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.level = empl.level
);


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

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


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

SELECT code FROM orders AS budg
WHERE status IN (
    SELECT status FROM projects AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT code FROM projects AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT id FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.status = ord.status
);


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

SELECT id FROM products AS cust
WHERE id IN (
    SELECT id FROM shipments AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT value FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.id = cust.id
);


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

SELECT amount FROM projects AS whs
WHERE value > (
    SELECT COUNT(value) FROM tasks AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT value FROM transactions AS whs
WHERE amount > (
    SELECT MAX(salary) FROM accounts AS ord
    WHERE ord.type = whs.type
);


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

SELECT id FROM tasks AS emp
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT code FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.status = acct.status
);


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

SELECT value FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT salary FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.level = inv.level
);


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

SELECT id FROM suppliers AS rgn
WHERE salary > (
    SELECT MAX(amount) FROM employees AS sale
    WHERE sale.type = rgn.type
);


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

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


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

SELECT salary FROM invoices AS sale
WHERE status IN (
    SELECT status FROM suppliers AS ord
    WHERE ord.type = sale.type
);


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

SELECT code FROM shipments AS inv
WHERE salary > (
    SELECT MAX(salary) FROM regions AS schd
    WHERE schd.code = inv.code
);


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

SELECT amount FROM invoices AS srvc
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.type = srvc.type
);


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

SELECT amount FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.level = rgn.level
);


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

SELECT salary FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.code = cust.code
);


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

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


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

SELECT name FROM orders AS sale
WHERE salary > (
    SELECT COUNT(value) FROM customers AS catg
    WHERE catg.level = sale.level
);


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

SELECT amount FROM branches AS txn
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS whs
    WHERE whs.status = txn.status
);


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

SELECT salary FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.status = lne.status
);


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

SELECT value FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.type = catg.type
);


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

SELECT code FROM tasks AS emp
WHERE value > (
    SELECT MAX(amount) FROM customers AS catg
    WHERE catg.level = emp.level
);


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

SELECT amount FROM transactions AS rgn
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS acct
    WHERE acct.type = rgn.type
);


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

SELECT name FROM transactions AS mgr
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS ord
    WHERE ord.type = mgr.type
);


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

SELECT code FROM departments AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS schd
    WHERE schd.id = catg.id
);


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

SELECT value FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.type = dept.type
);


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

SELECT amount FROM projects AS acct
WHERE salary > (
    SELECT SUM(value) FROM shipments AS shp
    WHERE shp.type = acct.type
);


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

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


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.code = catg.code
);


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

SELECT id FROM accounts AS shp
WHERE id IN (
    SELECT id FROM shipments AS prod
    WHERE prod.code = shp.code
);


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

SELECT salary FROM invoices AS emp
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS cust
    WHERE cust.id = emp.id
);


Prompt:
Schema:
  shipments (alias: dept)(id, code, amount, name)
  regions(code, status, date, name)
Task: Retrieve code from shipments with amount above the AVG(amount) of regions rows sharing the same type.
SQL:

SELECT code FROM shipments AS dept
WHERE amount > (
    SELECT AVG(amount) FROM regions AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT id FROM tasks AS shp
WHERE amount > (
    SELECT COUNT(value) FROM categories AS cust
    WHERE cust.level = shp.level
);


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

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


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

SELECT value FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = txn.type
);


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

SELECT amount FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT code FROM regions AS budg
WHERE value > (
    SELECT MAX(amount) FROM products AS schd
    WHERE schd.level = budg.level
);


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

SELECT value FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.id = srvc.id
);


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.type = whs.type
);


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

SELECT code FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.code = ordr.code
);


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

SELECT salary FROM orders AS mgr
WHERE status IN (
    SELECT status FROM customers AS shp
    WHERE shp.status = mgr.status
);


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

SELECT code FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.level = txn.level
);


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

SELECT code FROM departments AS srvc
WHERE status IN (
    SELECT status FROM accounts AS prod
    WHERE prod.level = srvc.level
);


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

SELECT value FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.status = schd.status
);


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

SELECT amount FROM branches AS schd
WHERE value > (
    SELECT AVG(amount) FROM accounts AS rgn
    WHERE rgn.status = schd.status
);


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

SELECT name FROM projects AS acct
WHERE value > (
    SELECT MIN(value) FROM customers AS ord
    WHERE ord.type = acct.type
);


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

SELECT amount FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.id = prod.id
);


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

SELECT id FROM products AS budg
WHERE code IN (
    SELECT code FROM categories AS srvc
    WHERE srvc.level = budg.level
);


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

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


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

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


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

SELECT amount FROM branches AS whs
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT salary FROM transactions AS shp
WHERE id IN (
    SELECT id FROM categories AS lne
    WHERE lne.type = shp.type
);


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

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


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

SELECT code FROM shipments AS schd
WHERE salary > (
    SELECT SUM(amount) FROM categories AS emp
    WHERE emp.type = schd.type
);


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

SELECT value FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.level = ordr.level
);


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

SELECT salary FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = dept.code
);


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

SELECT code FROM shipments AS lne
WHERE amount > (
    SELECT AVG(amount) FROM customers AS budg
    WHERE budg.level = lne.level
);


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

SELECT value FROM departments AS empl
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT salary FROM transactions AS acct
WHERE code IN (
    SELECT code FROM tasks AS budg
    WHERE budg.code = acct.code
);


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

SELECT salary FROM customers AS lne
WHERE code IN (
    SELECT code FROM shipments AS inv
    WHERE inv.level = lne.level
);


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

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


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

SELECT value FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.id = emp.id
);


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

SELECT name FROM projects AS rgn
WHERE level IN (
    SELECT level FROM departments AS inv
    WHERE inv.status = rgn.status
);


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

SELECT value FROM products AS inv
WHERE amount > (
    SELECT MIN(salary) FROM regions AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT salary FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT name FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.level = lne.level
);


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

SELECT name FROM customers AS emp
WHERE code IN (
    SELECT code FROM orders AS whs
    WHERE whs.code = emp.code
);


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

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


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

SELECT salary FROM invoices AS acct
WHERE amount > (
    SELECT AVG(value) FROM projects AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT value FROM accounts AS srvc
WHERE code IN (
    SELECT code FROM warehouses AS prod
    WHERE prod.id = srvc.id
);


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

SELECT code FROM customers AS lne
WHERE amount > (
    SELECT MAX(salary) FROM suppliers AS txn
    WHERE txn.type = lne.type
);


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

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


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

SELECT salary FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.type = schd.type
);


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

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


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

SELECT salary FROM invoices AS catg
WHERE level IN (
    SELECT level FROM categories AS whs
    WHERE whs.id = catg.id
);


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

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


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

SELECT id FROM tasks AS ordr
WHERE value > (
    SELECT MAX(salary) FROM departments AS sale
    WHERE sale.code = ordr.code
);


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

SELECT name FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.type = catg.type
);


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

SELECT salary FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.level = catg.level
);


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

SELECT value FROM categories AS ordr
WHERE level IN (
    SELECT level FROM orders AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT value FROM projects AS shp
WHERE type IN (
    SELECT type FROM customers AS acct
    WHERE acct.id = shp.id
);


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

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


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

SELECT salary FROM customers AS whs
WHERE salary > (
    SELECT MAX(amount) FROM categories AS emp
    WHERE emp.level = whs.level
);


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

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


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

SELECT amount FROM departments AS txn
WHERE code IN (
    SELECT code FROM invoices AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT amount FROM employees AS empl
WHERE amount > (
    SELECT AVG(amount) FROM regions AS schd
    WHERE schd.type = empl.type
);


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

SELECT id FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.status = emp.status
);


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

SELECT code FROM tasks AS sale
WHERE type IN (
    SELECT type FROM projects AS budg
    WHERE budg.level = sale.level
);


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

SELECT code FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.type = srvc.type
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.code = prod.code
);


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

SELECT code FROM orders AS whs
WHERE value > (
    SELECT COUNT(value) FROM projects AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT amount FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.code = rgn.code
);


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

SELECT name FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.level = shp.level
);


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

SELECT name FROM shipments AS budg
WHERE salary > (
    SELECT MIN(value) FROM customers AS inv
    WHERE inv.status = budg.status
);


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

SELECT amount FROM categories AS inv
WHERE level IN (
    SELECT level FROM accounts AS dept
    WHERE dept.level = inv.level
);


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

SELECT id FROM projects AS acct
WHERE status IN (
    SELECT status FROM warehouses AS dept
    WHERE dept.type = acct.type
);


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

SELECT salary FROM regions AS ord
WHERE code IN (
    SELECT code FROM branches AS budg
    WHERE budg.code = ord.code
);


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

SELECT code FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.id = sale.id
);


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

SELECT code FROM customers AS shp
WHERE salary > (
    SELECT AVG(value) FROM projects AS empl
    WHERE empl.level = shp.level
);


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

SELECT id FROM departments AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS catg
    WHERE catg.status = mgr.status
);


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

SELECT value FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.id = inv.id
);


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

SELECT value FROM tasks AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM employees AS txn
    WHERE txn.level = srvc.level
);


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

SELECT value FROM invoices AS ord
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS prod
    WHERE prod.type = ord.type
);


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

SELECT code FROM categories AS emp
WHERE salary > (
    SELECT AVG(amount) FROM customers AS acct
    WHERE acct.id = emp.id
);


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

SELECT code FROM customers AS ordr
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS dept
    WHERE dept.type = ordr.type
);


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

SELECT id FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.level = sale.level
);


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

SELECT value FROM branches AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM employees AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT amount FROM shipments AS dept
WHERE value > (
    SELECT MIN(amount) FROM products AS whs
    WHERE whs.level = dept.level
);


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

SELECT salary FROM suppliers AS shp
WHERE type IN (
    SELECT type FROM employees AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT value FROM warehouses AS shp
WHERE status IN (
    SELECT status FROM orders AS empl
    WHERE empl.type = shp.type
);


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

SELECT value FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT salary FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.level = acct.level
);


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

SELECT salary FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = empl.type
);


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

SELECT amount FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.id = rgn.id
);


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

SELECT salary FROM transactions AS emp
WHERE code IN (
    SELECT code FROM warehouses AS sale
    WHERE sale.level = emp.level
);


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

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


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

SELECT name FROM customers AS catg
WHERE id IN (
    SELECT id FROM warehouses AS txn
    WHERE txn.level = catg.level
);


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

SELECT id FROM branches AS sale
WHERE level IN (
    SELECT level FROM orders AS txn
    WHERE txn.id = sale.id
);


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

SELECT code FROM warehouses AS prod
WHERE type IN (
    SELECT type FROM suppliers AS dept
    WHERE dept.status = prod.status
);


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

SELECT name FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.code = empl.code
);


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

SELECT code FROM suppliers AS ordr
WHERE value > (
    SELECT AVG(amount) FROM projects AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT name FROM projects AS prod
WHERE salary > (
    SELECT COUNT(value) FROM departments AS catg
    WHERE catg.level = prod.level
);


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

SELECT value FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.code = prod.code
);


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

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


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

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


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

SELECT id FROM customers AS catg
WHERE amount > (
    SELECT SUM(amount) FROM invoices AS lne
    WHERE lne.status = catg.status
);


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

SELECT value FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.code = prod.code
);


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

SELECT id FROM employees AS lne
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.code = lne.code
);


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

SELECT value FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.status = budg.status
);


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

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


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

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


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

SELECT salary FROM suppliers AS emp
WHERE salary > (
    SELECT SUM(amount) FROM warehouses AS whs
    WHERE whs.id = emp.id
);


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

SELECT code FROM warehouses AS catg
WHERE type IN (
    SELECT type FROM regions AS ord
    WHERE ord.status = catg.status
);


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

SELECT id FROM tasks AS budg
WHERE value > (
    SELECT MAX(value) FROM employees AS mgr
    WHERE mgr.id = budg.id
);


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

SELECT salary FROM orders AS shp
WHERE value > (
    SELECT COUNT(value) FROM warehouses AS budg
    WHERE budg.id = shp.id
);


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

SELECT code FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.id = txn.id
);


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

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


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

SELECT name FROM branches AS inv
WHERE code IN (
    SELECT code FROM products AS txn
    WHERE txn.level = inv.level
);


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

SELECT value FROM warehouses AS inv
WHERE status IN (
    SELECT status FROM transactions AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT amount FROM accounts AS schd
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS mgr
    WHERE mgr.status = schd.status
);


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

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


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

SELECT value FROM employees AS rgn
WHERE level IN (
    SELECT level FROM orders AS inv
    WHERE inv.level = rgn.level
);


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

SELECT code FROM products AS cust
WHERE type IN (
    SELECT type FROM categories AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT value FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.level = ordr.level
);


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

SELECT amount FROM invoices AS whs
WHERE salary > (
    SELECT AVG(value) FROM branches AS empl
    WHERE empl.type = whs.type
);


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

SELECT value FROM orders AS srvc
WHERE type IN (
    SELECT type FROM departments AS rgn
    WHERE rgn.status = srvc.status
);


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

SELECT value FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.status = srvc.status
);


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

SELECT salary FROM transactions AS srvc
WHERE level IN (
    SELECT level FROM customers AS whs
    WHERE whs.id = srvc.id
);


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

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


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

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


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

SELECT salary FROM projects AS prod
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS txn
    WHERE txn.status = prod.status
);


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

SELECT id FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT code FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.level = schd.level
);


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

SELECT value FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.id = sale.id
);


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

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


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

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


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

SELECT salary FROM shipments AS budg
WHERE status IN (
    SELECT status FROM tasks AS acct
    WHERE acct.id = budg.id
);


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

SELECT salary FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.level = inv.level
);


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

SELECT code FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.type = whs.type
);


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

SELECT id FROM employees AS budg
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS catg
    WHERE catg.level = budg.level
);


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

SELECT id FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.level = sale.level
);


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

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


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

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


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

SELECT value FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT salary FROM regions AS srvc
WHERE id IN (
    SELECT id FROM departments AS inv
    WHERE inv.type = srvc.type
);


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

SELECT id FROM departments AS txn
WHERE value > (
    SELECT MAX(amount) FROM orders AS dept
    WHERE dept.status = txn.status
);


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

SELECT salary FROM warehouses AS budg
WHERE value > (
    SELECT MAX(value) FROM categories AS txn
    WHERE txn.id = budg.id
);


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

SELECT name FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.id = acct.id
);


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

SELECT salary FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.type = schd.type
);


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

SELECT amount FROM categories AS dept
WHERE id IN (
    SELECT id FROM customers AS catg
    WHERE catg.level = dept.level
);