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

SELECT value FROM tasks AS inv
WHERE amount > (
    SELECT AVG(salary) FROM warehouses AS empl
    WHERE empl.status = inv.status
);


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

SELECT id FROM categories AS dept
WHERE value > (
    SELECT MAX(value) FROM shipments AS empl
    WHERE empl.status = dept.status
);


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

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


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

SELECT code FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.type = ord.type
);


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

SELECT value FROM employees AS inv
WHERE value > (
    SELECT MIN(value) FROM customers AS ord
    WHERE ord.status = inv.status
);


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

SELECT value FROM branches AS emp
WHERE value > (
    SELECT SUM(amount) FROM invoices AS budg
    WHERE budg.id = emp.id
);


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

SELECT id FROM departments AS srvc
WHERE salary > (
    SELECT SUM(value) FROM tasks AS cust
    WHERE cust.type = srvc.type
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT id FROM products AS acct
WHERE amount > (
    SELECT SUM(amount) FROM departments AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT value FROM products AS srvc
WHERE amount > (
    SELECT SUM(value) FROM projects AS acct
    WHERE acct.status = srvc.status
);


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

SELECT id FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = ord.code
);


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

SELECT name FROM categories AS schd
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT value FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT value FROM categories AS inv
WHERE level IN (
    SELECT level FROM branches AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT value FROM accounts AS prod
WHERE amount > (
    SELECT MIN(value) FROM warehouses AS catg
    WHERE catg.id = prod.id
);


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

SELECT id FROM regions AS inv
WHERE salary > (
    SELECT MAX(amount) FROM employees AS shp
    WHERE shp.status = inv.status
);


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

SELECT name FROM accounts AS mgr
WHERE status IN (
    SELECT status FROM customers AS prod
    WHERE prod.code = mgr.code
);


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

SELECT salary FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT salary FROM warehouses AS ord
WHERE code IN (
    SELECT code FROM employees AS lne
    WHERE lne.id = ord.id
);


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

SELECT id FROM projects AS dept
WHERE salary > (
    SELECT AVG(amount) FROM branches AS schd
    WHERE schd.level = dept.level
);


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

SELECT id FROM transactions AS sale
WHERE salary > (
    SELECT AVG(value) FROM customers AS mgr
    WHERE mgr.type = sale.type
);


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

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


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

SELECT code FROM transactions AS lne
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.code = lne.code
);


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

SELECT value FROM invoices AS mgr
WHERE salary > (
    SELECT SUM(value) FROM transactions AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT value FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.code = dept.code
);


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

SELECT id FROM projects AS acct
WHERE value > (
    SELECT COUNT(salary) FROM categories AS txn
    WHERE txn.type = acct.type
);


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

SELECT code FROM departments AS emp
WHERE id IN (
    SELECT id FROM invoices AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT amount FROM departments AS catg
WHERE code IN (
    SELECT code FROM tasks AS schd
    WHERE schd.level = catg.level
);


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

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


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

SELECT code FROM transactions AS cust
WHERE code IN (
    SELECT code FROM regions AS txn
    WHERE txn.code = cust.code
);


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

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


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

SELECT salary FROM accounts AS mgr
WHERE id IN (
    SELECT id FROM suppliers AS inv
    WHERE inv.code = mgr.code
);


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

SELECT value FROM branches AS acct
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.type = acct.type
);


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

SELECT value FROM customers AS shp
WHERE value > (
    SELECT COUNT(value) FROM tasks AS lne
    WHERE lne.status = shp.status
);


Prompt:
Schema:
  accounts (alias: empl)(amount, salary, status, date)
  regions(status, amount, date, name)
Task: Retrieve salary from accounts with salary above the COUNT(amount) of regions rows sharing the same status.
SQL:

SELECT salary FROM accounts AS empl
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS cust
    WHERE cust.status = empl.status
);


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

SELECT value FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.id = schd.id
);


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

SELECT code FROM products AS shp
WHERE value > (
    SELECT SUM(amount) FROM categories AS cust
    WHERE cust.level = shp.level
);


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

SELECT id FROM orders AS sale
WHERE code IN (
    SELECT code FROM categories AS ord
    WHERE ord.type = sale.type
);


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

SELECT id FROM products AS prod
WHERE salary > (
    SELECT MAX(amount) FROM accounts AS ordr
    WHERE ordr.code = prod.code
);


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

SELECT amount FROM warehouses AS catg
WHERE type IN (
    SELECT type FROM employees AS dept
    WHERE dept.id = catg.id
);


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

SELECT salary FROM products AS empl
WHERE type IN (
    SELECT type FROM invoices AS cust
    WHERE cust.level = empl.level
);


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

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


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

SELECT id FROM projects AS budg
WHERE status IN (
    SELECT status FROM products AS cust
    WHERE cust.type = budg.type
);


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

SELECT amount FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.code = empl.code
);


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

SELECT amount FROM warehouses AS shp
WHERE level IN (
    SELECT level FROM orders AS whs
    WHERE whs.status = shp.status
);


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

SELECT code FROM invoices AS txn
WHERE type IN (
    SELECT type FROM accounts AS schd
    WHERE schd.level = txn.level
);


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

SELECT value FROM tasks AS empl
WHERE type IN (
    SELECT type FROM products AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT name FROM projects AS schd
WHERE value > (
    SELECT COUNT(value) FROM products AS cust
    WHERE cust.type = schd.type
);


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

SELECT name FROM suppliers AS ord
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.type = ord.type
);


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

SELECT id FROM accounts AS dept
WHERE status IN (
    SELECT status FROM shipments AS sale
    WHERE sale.level = dept.level
);


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

SELECT code FROM branches AS ordr
WHERE salary > (
    SELECT MAX(value) FROM invoices AS ord
    WHERE ord.level = ordr.level
);


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

SELECT amount FROM regions AS shp
WHERE amount > (
    SELECT MAX(salary) FROM accounts AS prod
    WHERE prod.id = shp.id
);


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

SELECT amount FROM branches AS acct
WHERE type IN (
    SELECT type FROM products AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT salary FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.type = catg.type
);


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

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


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

SELECT amount FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.level = rgn.level
);


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

SELECT amount FROM accounts AS whs
WHERE level IN (
    SELECT level FROM orders AS sale
    WHERE sale.level = whs.level
);


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

SELECT id FROM departments AS ord
WHERE value > (
    SELECT SUM(value) FROM warehouses AS whs
    WHERE whs.status = ord.status
);


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

SELECT salary FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.type = emp.type
);


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

SELECT name FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.status = cust.status
);


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

SELECT salary FROM projects AS shp
WHERE amount > (
    SELECT MAX(amount) FROM orders AS inv
    WHERE inv.code = shp.code
);


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

SELECT code FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.level = srvc.level
);


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

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


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

SELECT id FROM tasks AS lne
WHERE id IN (
    SELECT id FROM customers AS emp
    WHERE emp.id = lne.id
);


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

SELECT amount FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = cust.type
);


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

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


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

SELECT value FROM regions AS sale
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS emp
    WHERE emp.status = sale.status
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT value FROM orders AS catg
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT salary FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.code = srvc.code
);


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

SELECT salary FROM categories AS shp
WHERE id IN (
    SELECT id FROM tasks AS empl
    WHERE empl.status = shp.status
);


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

SELECT code FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.status = mgr.status
);


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

SELECT amount FROM customers AS emp
WHERE id IN (
    SELECT id FROM transactions AS sale
    WHERE sale.status = emp.status
);


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

SELECT amount FROM categories AS acct
WHERE type IN (
    SELECT type FROM transactions AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT code FROM products AS catg
WHERE salary > (
    SELECT SUM(value) FROM employees AS sale
    WHERE sale.type = catg.type
);


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

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


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

SELECT id FROM departments AS cust
WHERE amount > (
    SELECT MIN(salary) FROM branches AS dept
    WHERE dept.type = cust.type
);


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

SELECT id FROM customers AS prod
WHERE level IN (
    SELECT level FROM transactions AS inv
    WHERE inv.level = prod.level
);


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

SELECT salary FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.type = acct.type
);


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

SELECT value FROM regions AS lne
WHERE value > (
    SELECT AVG(salary) FROM shipments AS emp
    WHERE emp.code = lne.code
);


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

SELECT amount FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.type = sale.type
);


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

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


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

SELECT salary FROM warehouses AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM orders AS whs
    WHERE whs.level = ordr.level
);


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

SELECT id FROM products AS empl
WHERE code IN (
    SELECT code FROM accounts AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT id FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT salary FROM orders AS acct
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT id FROM categories AS prod
WHERE amount > (
    SELECT MIN(value) FROM shipments AS ordr
    WHERE ordr.code = prod.code
);


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

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


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

SELECT id FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT salary FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.code = schd.code
);


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

SELECT id FROM invoices AS ord
WHERE status IN (
    SELECT status FROM transactions AS empl
    WHERE empl.level = ord.level
);


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

SELECT value FROM departments AS txn
WHERE salary > (
    SELECT AVG(salary) FROM employees AS lne
    WHERE lne.type = txn.type
);


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

SELECT code FROM departments AS srvc
WHERE amount > (
    SELECT AVG(value) FROM products AS sale
    WHERE sale.id = srvc.id
);


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

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


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

SELECT amount FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.id = prod.id
);


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

SELECT salary FROM categories AS dept
WHERE status IN (
    SELECT status FROM shipments AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT amount FROM projects AS srvc
WHERE type IN (
    SELECT type FROM transactions AS dept
    WHERE dept.status = srvc.status
);


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

SELECT amount FROM invoices AS whs
WHERE status IN (
    SELECT status FROM products AS srvc
    WHERE srvc.id = whs.id
);


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

SELECT name FROM employees AS budg
WHERE amount > (
    SELECT AVG(salary) FROM products AS sale
    WHERE sale.code = budg.code
);


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

SELECT salary FROM departments AS prod
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS empl
    WHERE empl.status = prod.status
);


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

SELECT id FROM invoices AS mgr
WHERE type IN (
    SELECT type FROM tasks AS empl
    WHERE empl.id = mgr.id
);


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

SELECT value FROM products AS ord
WHERE level IN (
    SELECT level FROM suppliers AS budg
    WHERE budg.level = ord.level
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = inv.level
);


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

SELECT id FROM regions AS prod
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS emp
    WHERE emp.code = prod.code
);


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

SELECT salary FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT name FROM tasks AS dept
WHERE type IN (
    SELECT type FROM branches AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT salary FROM employees AS whs
WHERE value > (
    SELECT COUNT(amount) FROM branches AS shp
    WHERE shp.type = whs.type
);


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

SELECT id FROM employees AS catg
WHERE level IN (
    SELECT level FROM products AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT code FROM regions AS sale
WHERE amount > (
    SELECT SUM(value) FROM warehouses AS inv
    WHERE inv.type = sale.type
);


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

SELECT id FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.level = prod.level
);


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

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


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

SELECT salary FROM accounts AS mgr
WHERE id IN (
    SELECT id FROM orders AS inv
    WHERE inv.code = mgr.code
);


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

SELECT name FROM warehouses AS acct
WHERE type IN (
    SELECT type FROM tasks AS txn
    WHERE txn.type = acct.type
);


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

SELECT id FROM products AS schd
WHERE value > (
    SELECT AVG(value) FROM employees AS txn
    WHERE txn.status = schd.status
);


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

SELECT name FROM branches AS dept
WHERE level IN (
    SELECT level FROM warehouses AS empl
    WHERE empl.id = dept.id
);


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

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


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

SELECT name FROM shipments AS txn
WHERE level IN (
    SELECT level FROM customers AS srvc
    WHERE srvc.type = txn.type
);


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

SELECT name FROM warehouses AS budg
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.status = budg.status
);


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

SELECT amount FROM accounts AS shp
WHERE level IN (
    SELECT level FROM branches AS ord
    WHERE ord.status = shp.status
);


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

SELECT salary FROM projects AS txn
WHERE type IN (
    SELECT type FROM tasks AS schd
    WHERE schd.status = txn.status
);


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

SELECT code FROM transactions AS rgn
WHERE value > (
    SELECT AVG(salary) FROM customers AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT id FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT id FROM orders AS budg
WHERE value > (
    SELECT SUM(value) FROM categories AS ordr
    WHERE ordr.level = budg.level
);


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

SELECT amount FROM orders AS srvc
WHERE code IN (
    SELECT code FROM products AS txn
    WHERE txn.level = srvc.level
);


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

SELECT name FROM categories AS dept
WHERE code IN (
    SELECT code FROM customers AS budg
    WHERE budg.id = dept.id
);


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

SELECT amount FROM employees AS dept
WHERE value > (
    SELECT MAX(value) FROM orders AS cust
    WHERE cust.code = dept.code
);


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

SELECT name FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.type = ord.type
);


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

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


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

SELECT value FROM projects AS sale
WHERE type IN (
    SELECT type FROM products AS shp
    WHERE shp.level = sale.level
);


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

SELECT name FROM projects AS budg
WHERE id IN (
    SELECT id FROM warehouses AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT id FROM warehouses AS prod
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS schd
    WHERE schd.level = prod.level
);


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

SELECT amount FROM customers AS mgr
WHERE id IN (
    SELECT id FROM regions AS cust
    WHERE cust.status = mgr.status
);


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

SELECT code FROM branches AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM departments AS acct
    WHERE acct.code = ordr.code
);


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

SELECT salary FROM warehouses AS mgr
WHERE code IN (
    SELECT code FROM suppliers AS acct
    WHERE acct.code = mgr.code
);


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

SELECT code FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.type = budg.type
);


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

SELECT amount FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.status = inv.status
);


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

SELECT name FROM employees AS ord
WHERE id IN (
    SELECT id FROM shipments AS cust
    WHERE cust.type = ord.type
);


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

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


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

SELECT id FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.code = lne.code
);


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

SELECT name FROM warehouses AS txn
WHERE id IN (
    SELECT id FROM transactions AS lne
    WHERE lne.code = txn.code
);


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

SELECT name FROM departments AS whs
WHERE status IN (
    SELECT status FROM categories AS srvc
    WHERE srvc.status = whs.status
);


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

SELECT name FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT code FROM orders AS dept
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS lne
    WHERE lne.code = dept.code
);


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

SELECT amount FROM categories AS ord
WHERE level IN (
    SELECT level FROM employees AS inv
    WHERE inv.status = ord.status
);


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

SELECT code FROM transactions AS shp
WHERE amount > (
    SELECT SUM(salary) FROM categories AS inv
    WHERE inv.id = shp.id
);


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

SELECT code FROM products AS inv
WHERE id IN (
    SELECT id FROM tasks AS ord
    WHERE ord.status = inv.status
);


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

SELECT id FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.code = schd.code
);


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

SELECT value FROM orders AS sale
WHERE status IN (
    SELECT status FROM branches AS txn
    WHERE txn.code = sale.code
);


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

SELECT salary FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM warehouses AS cust
    WHERE cust.level = rgn.level
);


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

SELECT code FROM products AS schd
WHERE type IN (
    SELECT type FROM shipments AS dept
    WHERE dept.code = schd.code
);


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

SELECT id FROM accounts AS prod
WHERE id IN (
    SELECT id FROM transactions AS emp
    WHERE emp.type = prod.type
);


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

SELECT amount FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.type = txn.type
);


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

SELECT salary FROM accounts AS rgn
WHERE value > (
    SELECT SUM(salary) FROM tasks AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT name FROM products AS inv
WHERE value > (
    SELECT MAX(salary) FROM projects AS emp
    WHERE emp.type = inv.type
);


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

SELECT id FROM accounts AS shp
WHERE value > (
    SELECT MIN(value) FROM shipments AS emp
    WHERE emp.type = shp.type
);


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

SELECT salary FROM shipments AS budg
WHERE value > (
    SELECT MAX(amount) FROM transactions AS dept
    WHERE dept.type = budg.type
);


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

SELECT name FROM orders AS rgn
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.type = rgn.type
);


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

SELECT value FROM warehouses AS empl
WHERE level IN (
    SELECT level FROM customers AS prod
    WHERE prod.code = empl.code
);


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

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


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

SELECT salary FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.code = catg.code
);


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

SELECT value FROM warehouses AS catg
WHERE id IN (
    SELECT id FROM categories AS mgr
    WHERE mgr.id = catg.id
);


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

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


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

SELECT salary FROM warehouses AS empl
WHERE level IN (
    SELECT level FROM accounts AS acct
    WHERE acct.type = empl.type
);


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

SELECT salary FROM orders AS empl
WHERE amount > (
    SELECT MIN(value) FROM transactions AS dept
    WHERE dept.type = empl.type
);


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

SELECT name FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = txn.code
);


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

SELECT code FROM shipments AS inv
WHERE level IN (
    SELECT level FROM tasks AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT salary FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.code = catg.code
);


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

SELECT name FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.code = schd.code
);


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

SELECT id FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.level = txn.level
);


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

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


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

SELECT salary FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.status = lne.status
);


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

SELECT value FROM categories AS prod
WHERE status IN (
    SELECT status FROM employees AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT code FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.level = ord.level
);


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

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


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

SELECT salary FROM employees AS ord
WHERE value > (
    SELECT MAX(value) FROM tasks AS cust
    WHERE cust.type = ord.type
);


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

SELECT salary FROM suppliers AS mgr
WHERE level IN (
    SELECT level FROM employees AS txn
    WHERE txn.type = mgr.type
);


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

SELECT id FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.status = prod.status
);


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

SELECT salary FROM orders AS ord
WHERE amount > (
    SELECT SUM(value) FROM shipments AS sale
    WHERE sale.code = ord.code
);


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

SELECT code FROM regions AS cust
WHERE value > (
    SELECT MIN(salary) FROM shipments AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT id FROM regions AS prod
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS catg
    WHERE catg.level = prod.level
);


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

SELECT id FROM shipments AS catg
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS ord
    WHERE ord.code = catg.code
);


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

SELECT salary FROM customers AS txn
WHERE salary > (
    SELECT MAX(amount) FROM departments AS catg
    WHERE catg.level = txn.level
);


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

SELECT value FROM warehouses AS emp
WHERE type IN (
    SELECT type FROM invoices AS budg
    WHERE budg.status = emp.status
);


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

SELECT salary FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = lne.type
);


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

SELECT code FROM products AS schd
WHERE level IN (
    SELECT level FROM transactions AS lne
    WHERE lne.level = schd.level
);


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

SELECT id FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.id = rgn.id
);


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

SELECT code FROM warehouses AS schd
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS txn
    WHERE txn.type = schd.type
);


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

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


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

SELECT name FROM branches AS acct
WHERE amount > (
    SELECT SUM(value) FROM invoices AS dept
    WHERE dept.id = acct.id
);


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

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


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

SELECT value FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.id = inv.id
);


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

SELECT name FROM invoices AS inv
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS schd
    WHERE schd.code = inv.code
);


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

SELECT salary FROM orders AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT salary FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.level = catg.level
);


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

SELECT id FROM invoices AS empl
WHERE salary > (
    SELECT MAX(salary) FROM regions AS shp
    WHERE shp.status = empl.status
);


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

SELECT amount FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.status = inv.status
);


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

SELECT code FROM branches AS dept
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT salary FROM branches AS budg
WHERE level IN (
    SELECT level FROM departments AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT id FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = budg.level
);


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

SELECT id FROM transactions AS cust
WHERE salary > (
    SELECT SUM(salary) FROM orders AS shp
    WHERE shp.status = cust.status
);


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

SELECT value FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = prod.status
);


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

SELECT value FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.level = rgn.level
);


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

SELECT value FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.level = budg.level
);


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

SELECT id FROM projects AS inv
WHERE value > (
    SELECT MAX(amount) FROM branches AS srvc
    WHERE srvc.status = inv.status
);


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

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


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

SELECT id FROM projects AS lne
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT name FROM employees AS ordr
WHERE status IN (
    SELECT status FROM invoices AS budg
    WHERE budg.level = ordr.level
);


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

SELECT amount FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = inv.id
);


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

SELECT salary FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.type = budg.type
);


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

SELECT code FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.type = shp.type
);


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

SELECT amount FROM orders AS srvc
WHERE value > (
    SELECT AVG(amount) FROM projects AS catg
    WHERE catg.code = srvc.code
);


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

SELECT value FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.code = acct.code
);


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

SELECT salary FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.id = ordr.id
);


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

SELECT code FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = schd.status
);


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

SELECT amount FROM warehouses AS ord
WHERE amount > (
    SELECT SUM(amount) FROM projects AS inv
    WHERE inv.id = ord.id
);


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

SELECT code FROM departments AS mgr
WHERE value > (
    SELECT COUNT(amount) FROM projects AS budg
    WHERE budg.id = mgr.id
);


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

SELECT code FROM tasks AS txn
WHERE salary > (
    SELECT SUM(amount) FROM categories AS mgr
    WHERE mgr.code = txn.code
);


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

SELECT name FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = mgr.status
);


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

SELECT amount FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT name FROM departments AS catg
WHERE code IN (
    SELECT code FROM employees AS txn
    WHERE txn.code = catg.code
);


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

SELECT value FROM employees AS ordr
WHERE value > (
    SELECT MIN(amount) FROM tasks AS srvc
    WHERE srvc.status = ordr.status
);


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

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


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

SELECT code FROM departments AS ord
WHERE value > (
    SELECT MAX(value) FROM regions AS emp
    WHERE emp.level = ord.level
);


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

SELECT id FROM departments AS txn
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS acct
    WHERE acct.type = txn.type
);


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

SELECT salary FROM employees AS empl
WHERE level IN (
    SELECT level FROM regions AS txn
    WHERE txn.type = empl.type
);


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

SELECT value FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.type = acct.type
);


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

SELECT id FROM tasks AS budg
WHERE id IN (
    SELECT id FROM departments AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT amount FROM shipments AS budg
WHERE level IN (
    SELECT level FROM transactions AS empl
    WHERE empl.status = budg.status
);


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

SELECT name FROM accounts AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS catg
    WHERE catg.status = srvc.status
);


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

SELECT value FROM departments AS rgn
WHERE value > (
    SELECT MIN(value) FROM shipments AS txn
    WHERE txn.level = rgn.level
);


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

SELECT amount FROM branches AS ord
WHERE code IN (
    SELECT code FROM products AS inv
    WHERE inv.type = ord.type
);


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

SELECT id FROM tasks AS txn
WHERE id IN (
    SELECT id FROM regions AS ordr
    WHERE ordr.code = txn.code
);


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

SELECT name FROM products AS prod
WHERE code IN (
    SELECT code FROM projects AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT name FROM suppliers AS shp
WHERE code IN (
    SELECT code FROM projects AS prod
    WHERE prod.type = shp.type
);


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

SELECT amount FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.code = rgn.code
);


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

SELECT value FROM branches AS inv
WHERE code IN (
    SELECT code FROM regions AS whs
    WHERE whs.code = inv.code
);


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

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


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

SELECT value FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.type = empl.type
);


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

SELECT code FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.code = ordr.code
);


Prompt:
Schema:
  projects (alias: mgr)(status, code, amount, date)
  shipments(value, status, name, code)
Task: Retrieve code from projects with value above the AVG(value) of shipments rows sharing the same level.
SQL:

SELECT code FROM projects AS mgr
WHERE value > (
    SELECT AVG(value) FROM shipments AS rgn
    WHERE rgn.level = mgr.level
);


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

SELECT amount FROM suppliers AS ordr
WHERE code IN (
    SELECT code FROM regions AS inv
    WHERE inv.type = ordr.type
);


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

SELECT code FROM warehouses AS whs
WHERE type IN (
    SELECT type FROM transactions AS dept
    WHERE dept.code = whs.code
);


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

SELECT name FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.level = dept.level
);


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

SELECT value FROM transactions AS cust
WHERE amount > (
    SELECT SUM(amount) FROM projects AS budg
    WHERE budg.id = cust.id
);


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

SELECT salary FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.code = shp.code
);


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

SELECT amount FROM projects AS cust
WHERE level IN (
    SELECT level FROM suppliers AS prod
    WHERE prod.level = cust.level
);


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

SELECT amount FROM categories AS cust
WHERE type IN (
    SELECT type FROM regions AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT salary FROM orders AS shp
WHERE value > (
    SELECT MAX(salary) FROM regions AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT code FROM categories AS lne
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.level = lne.level
);


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

SELECT amount FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.status = emp.status
);


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

SELECT value FROM projects AS sale
WHERE type IN (
    SELECT type FROM tasks AS emp
    WHERE emp.status = sale.status
);


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

SELECT value FROM employees AS budg
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.id = budg.id
);


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

SELECT name FROM warehouses AS ord
WHERE type IN (
    SELECT type FROM accounts AS shp
    WHERE shp.level = ord.level
);


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

SELECT code FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.level = rgn.level
);


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

SELECT salary FROM employees AS txn
WHERE id IN (
    SELECT id FROM branches AS cust
    WHERE cust.level = txn.level
);


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

SELECT code FROM customers AS whs
WHERE id IN (
    SELECT id FROM employees AS acct
    WHERE acct.status = whs.status
);


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

SELECT id FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.status = sale.status
);


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

SELECT salary FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.id = inv.id
);


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

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


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

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


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

SELECT name FROM customers AS rgn
WHERE value > (
    SELECT COUNT(value) FROM accounts AS prod
    WHERE prod.id = rgn.id
);


Prompt:
Schema:
  tasks (alias: budg)(type, value, name, code)
  shipments(type, code, name, value)
Task: Retrieve amount from tasks with value above the MAX(value) of shipments rows sharing the same id.
SQL:

SELECT amount FROM tasks AS budg
WHERE value > (
    SELECT MAX(value) FROM shipments AS shp
    WHERE shp.id = budg.id
);


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

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


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

SELECT value FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.level = mgr.level
);


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

SELECT amount FROM customers AS mgr
WHERE status IN (
    SELECT status FROM tasks AS sale
    WHERE sale.status = mgr.status
);


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

SELECT amount FROM products AS dept
WHERE type IN (
    SELECT type FROM warehouses AS schd
    WHERE schd.status = dept.status
);


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

SELECT id FROM transactions AS srvc
WHERE type IN (
    SELECT type FROM suppliers AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT value FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.id = prod.id
);


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

SELECT code FROM transactions AS inv
WHERE status IN (
    SELECT status FROM branches AS dept
    WHERE dept.id = inv.id
);


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

SELECT amount FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.id = empl.id
);


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

SELECT salary FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.status = budg.status
);


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

SELECT id FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT code FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT amount FROM regions AS sale
WHERE salary > (
    SELECT SUM(value) FROM departments AS schd
    WHERE schd.code = sale.code
);


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

SELECT name FROM accounts AS srvc
WHERE code IN (
    SELECT code FROM departments AS cust
    WHERE cust.status = srvc.status
);


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

SELECT code FROM tasks AS inv
WHERE amount > (
    SELECT SUM(amount) FROM departments AS cust
    WHERE cust.id = inv.id
);


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

SELECT value FROM regions AS srvc
WHERE value > (
    SELECT COUNT(value) FROM suppliers AS shp
    WHERE shp.code = srvc.code
);


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

SELECT name FROM categories AS shp
WHERE value > (
    SELECT COUNT(amount) FROM transactions AS acct
    WHERE acct.code = shp.code
);


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

SELECT id FROM products AS ord
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS sale
    WHERE sale.code = ord.code
);


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

SELECT code FROM warehouses AS schd
WHERE id IN (
    SELECT id FROM customers AS acct
    WHERE acct.status = schd.status
);


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

SELECT amount FROM branches AS dept
WHERE level IN (
    SELECT level FROM warehouses AS emp
    WHERE emp.code = dept.code
);


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

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


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

SELECT amount FROM invoices AS emp
WHERE status IN (
    SELECT status FROM projects AS txn
    WHERE txn.level = emp.level
);


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

SELECT salary FROM regions AS budg
WHERE value > (
    SELECT MAX(amount) FROM orders AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT salary FROM projects AS acct
WHERE status IN (
    SELECT status FROM warehouses AS shp
    WHERE shp.status = acct.status
);


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

SELECT value FROM employees AS shp
WHERE id IN (
    SELECT id FROM suppliers AS mgr
    WHERE mgr.type = shp.type
);


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

SELECT id FROM employees AS whs
WHERE id IN (
    SELECT id FROM warehouses AS dept
    WHERE dept.type = whs.type
);


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

SELECT id FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.level = emp.level
);


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

SELECT name FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.id = ordr.id
);


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

SELECT salary FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.type = shp.type
);


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

SELECT value FROM branches AS sale
WHERE id IN (
    SELECT id FROM transactions AS shp
    WHERE shp.id = sale.id
);


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

SELECT value FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.status = schd.status
);


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

SELECT amount FROM orders AS sale
WHERE level IN (
    SELECT level FROM accounts AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT salary FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.code = whs.code
);