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

SELECT salary FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.level = mgr.level
);


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

SELECT amount FROM orders AS catg
WHERE value > (
    SELECT COUNT(amount) FROM customers AS sale
    WHERE sale.code = catg.code
);


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

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


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

SELECT code FROM regions AS txn
WHERE value > (
    SELECT SUM(value) FROM categories AS inv
    WHERE inv.type = txn.type
);


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

SELECT value FROM employees AS inv
WHERE id IN (
    SELECT id FROM suppliers AS lne
    WHERE lne.id = inv.id
);


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

SELECT amount FROM warehouses AS inv
WHERE level IN (
    SELECT level FROM shipments AS schd
    WHERE schd.level = inv.level
);


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

SELECT name FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.type = sale.type
);


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

SELECT salary FROM regions AS lne
WHERE id IN (
    SELECT id FROM invoices AS cust
    WHERE cust.level = lne.level
);


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

SELECT amount FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.code = mgr.code
);


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

SELECT amount FROM categories AS sale
WHERE type IN (
    SELECT type FROM accounts AS srvc
    WHERE srvc.code = sale.code
);


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

SELECT amount FROM products AS dept
WHERE value > (
    SELECT AVG(value) FROM projects AS txn
    WHERE txn.status = dept.status
);


Prompt:
Schema:
  warehouses (alias: acct)(value, amount, type, status)
  transactions(level, date, salary, status)
Task: Retrieve value from warehouses with salary above the SUM(salary) of transactions rows sharing the same type.
SQL:

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


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

SELECT amount FROM regions AS dept
WHERE type IN (
    SELECT type FROM transactions AS acct
    WHERE acct.code = dept.code
);


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

SELECT id FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.status = lne.status
);


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

SELECT name FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.status = ordr.status
);


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

SELECT name FROM transactions AS whs
WHERE amount > (
    SELECT MIN(salary) FROM customers AS ord
    WHERE ord.id = whs.id
);


Prompt:
Schema:
  branches (alias: prod)(name, amount, salary, value)
  transactions(status, salary, amount, date)
Task: Retrieve name from branches with salary above the MIN(salary) of transactions rows sharing the same status.
SQL:

SELECT name FROM branches AS prod
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT code FROM customers AS shp
WHERE value > (
    SELECT SUM(value) FROM transactions AS cust
    WHERE cust.status = shp.status
);


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

SELECT name FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.level = empl.level
);


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

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


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

SELECT value FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.id = budg.id
);


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

SELECT code FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.code = rgn.code
);


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

SELECT value FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.level = txn.level
);


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

SELECT id FROM regions AS emp
WHERE level IN (
    SELECT level FROM customers AS inv
    WHERE inv.level = emp.level
);


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

SELECT id FROM branches AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM warehouses AS empl
    WHERE empl.status = acct.status
);


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

SELECT code FROM projects AS lne
WHERE type IN (
    SELECT type FROM suppliers AS cust
    WHERE cust.status = lne.status
);


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

SELECT amount FROM products AS schd
WHERE salary > (
    SELECT SUM(value) FROM suppliers AS catg
    WHERE catg.level = schd.level
);


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

SELECT salary FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.type = schd.type
);


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

SELECT code FROM warehouses AS schd
WHERE value > (
    SELECT SUM(amount) FROM customers AS shp
    WHERE shp.level = schd.level
);


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

SELECT value FROM tasks AS empl
WHERE id IN (
    SELECT id FROM shipments AS inv
    WHERE inv.id = empl.id
);


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

SELECT name FROM invoices AS whs
WHERE level IN (
    SELECT level FROM departments AS cust
    WHERE cust.type = whs.type
);


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

SELECT name FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.status = txn.status
);


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

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


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

SELECT code FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.id = budg.id
);


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

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


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

SELECT name FROM employees AS whs
WHERE code IN (
    SELECT code FROM accounts AS budg
    WHERE budg.id = whs.id
);


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

SELECT amount FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT id FROM customers AS mgr
WHERE value > (
    SELECT SUM(value) FROM employees AS schd
    WHERE schd.level = mgr.level
);


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

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


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

SELECT id FROM invoices AS shp
WHERE value > (
    SELECT COUNT(amount) FROM accounts AS lne
    WHERE lne.type = shp.type
);


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

SELECT amount FROM transactions AS empl
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS whs
    WHERE whs.status = empl.status
);


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

SELECT salary FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT salary FROM products AS mgr
WHERE amount > (
    SELECT MIN(salary) FROM regions AS inv
    WHERE inv.type = mgr.type
);


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

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


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

SELECT value FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.code = mgr.code
);


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

SELECT value FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT value FROM employees AS schd
WHERE amount > (
    SELECT COUNT(value) FROM categories AS whs
    WHERE whs.id = schd.id
);


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

SELECT amount FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.status = inv.status
);


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

SELECT code FROM products AS whs
WHERE level IN (
    SELECT level FROM departments AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT salary FROM employees AS mgr
WHERE amount > (
    SELECT SUM(amount) FROM projects AS dept
    WHERE dept.status = mgr.status
);


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

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


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

SELECT amount FROM employees AS empl
WHERE type IN (
    SELECT type FROM customers AS srvc
    WHERE srvc.level = empl.level
);


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

SELECT salary FROM orders AS dept
WHERE id IN (
    SELECT id FROM customers AS prod
    WHERE prod.level = dept.level
);


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

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


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

SELECT value FROM employees AS dept
WHERE value > (
    SELECT MAX(salary) FROM tasks AS emp
    WHERE emp.level = dept.level
);


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

SELECT id FROM projects AS acct
WHERE salary > (
    SELECT MIN(value) FROM orders AS schd
    WHERE schd.id = acct.id
);


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.status = ord.status
);


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

SELECT code FROM transactions AS empl
WHERE amount > (
    SELECT SUM(value) FROM branches AS whs
    WHERE whs.id = empl.id
);


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

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


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

SELECT amount FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.level = empl.level
);


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

SELECT salary FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = sale.status
);


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

SELECT value FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.level = inv.level
);


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

SELECT id FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.code = prod.code
);


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

SELECT id FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.type = prod.type
);


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

SELECT value FROM categories AS mgr
WHERE salary > (
    SELECT MIN(value) FROM customers AS lne
    WHERE lne.status = mgr.status
);


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

SELECT value FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.type = ord.type
);


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

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


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

SELECT code FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.id = sale.id
);


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

SELECT id FROM transactions AS prod
WHERE salary > (
    SELECT MIN(value) FROM invoices AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT name FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.type = cust.type
);


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

SELECT amount FROM invoices AS catg
WHERE amount > (
    SELECT MIN(salary) FROM categories AS txn
    WHERE txn.status = catg.status
);


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

SELECT value FROM suppliers AS whs
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS schd
    WHERE schd.type = whs.type
);


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

SELECT code FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT salary FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.level = sale.level
);


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

SELECT code FROM projects AS dept
WHERE status IN (
    SELECT status FROM invoices AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT code FROM employees AS budg
WHERE value > (
    SELECT MAX(salary) FROM products AS dept
    WHERE dept.status = budg.status
);


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

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


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

SELECT code FROM regions AS acct
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.type = acct.type
);


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

SELECT id FROM projects AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM orders AS whs
    WHERE whs.code = ordr.code
);


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

SELECT amount FROM products AS txn
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS catg
    WHERE catg.status = txn.status
);


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

SELECT code FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.id = schd.id
);


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

SELECT name FROM orders AS prod
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS acct
    WHERE acct.id = prod.id
);


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

SELECT id FROM accounts AS rgn
WHERE id IN (
    SELECT id FROM branches AS acct
    WHERE acct.level = rgn.level
);


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

SELECT value FROM suppliers AS inv
WHERE status IN (
    SELECT status FROM orders AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT code FROM suppliers AS empl
WHERE value > (
    SELECT SUM(salary) FROM invoices AS lne
    WHERE lne.type = empl.type
);


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

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


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

SELECT amount FROM branches AS dept
WHERE type IN (
    SELECT type FROM tasks AS schd
    WHERE schd.status = dept.status
);


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

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


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

SELECT amount FROM regions AS mgr
WHERE type IN (
    SELECT type FROM warehouses AS whs
    WHERE whs.status = mgr.status
);


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

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


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

SELECT name FROM employees AS schd
WHERE status IN (
    SELECT status FROM departments AS ord
    WHERE ord.id = schd.id
);


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

SELECT code FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = rgn.type
);


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

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


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

SELECT amount FROM employees AS dept
WHERE amount > (
    SELECT MIN(value) FROM shipments AS budg
    WHERE budg.type = dept.type
);


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

SELECT value FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.code = srvc.code
);


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

SELECT name FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT name FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.type = dept.type
);


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

SELECT amount FROM accounts AS emp
WHERE value > (
    SELECT MAX(value) FROM categories AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT code FROM projects AS dept
WHERE amount > (
    SELECT MIN(amount) FROM branches AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT name FROM accounts AS schd
WHERE salary > (
    SELECT MAX(salary) FROM employees AS prod
    WHERE prod.id = schd.id
);


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

SELECT value FROM projects AS emp
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS schd
    WHERE schd.type = emp.type
);


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

SELECT id FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.level = ordr.level
);


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

SELECT name FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.type = ord.type
);


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

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


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

SELECT amount FROM regions AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS lne
    WHERE lne.type = catg.type
);


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

SELECT salary FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.id = catg.id
);


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

SELECT amount FROM warehouses AS schd
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT code FROM projects AS ordr
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.level = ordr.level
);


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

SELECT name FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.code = lne.code
);


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

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


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

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


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

SELECT salary FROM orders AS prod
WHERE code IN (
    SELECT code FROM employees AS catg
    WHERE catg.id = prod.id
);


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

SELECT id FROM warehouses AS schd
WHERE id IN (
    SELECT id FROM invoices AS prod
    WHERE prod.status = schd.status
);


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

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


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

SELECT id FROM products AS emp
WHERE status IN (
    SELECT status FROM tasks AS ord
    WHERE ord.type = emp.type
);


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

SELECT value FROM suppliers AS sale
WHERE value > (
    SELECT MAX(amount) FROM regions AS prod
    WHERE prod.level = sale.level
);


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

SELECT code FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.status = schd.status
);


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

SELECT code FROM invoices AS rgn
WHERE id IN (
    SELECT id FROM accounts AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT name FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.type = acct.type
);


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

SELECT code FROM categories AS prod
WHERE status IN (
    SELECT status FROM orders AS dept
    WHERE dept.code = prod.code
);


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

SELECT code FROM suppliers AS mgr
WHERE amount > (
    SELECT SUM(amount) FROM projects AS txn
    WHERE txn.code = mgr.code
);


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

SELECT name FROM departments AS dept
WHERE salary > (
    SELECT SUM(value) FROM categories AS acct
    WHERE acct.status = dept.status
);


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

SELECT code FROM shipments AS schd
WHERE level IN (
    SELECT level FROM branches AS budg
    WHERE budg.type = schd.type
);


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

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


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

SELECT salary FROM transactions AS ord
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS schd
    WHERE schd.code = ord.code
);


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

SELECT code FROM orders AS empl
WHERE value > (
    SELECT AVG(value) FROM branches AS inv
    WHERE inv.status = empl.status
);


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

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


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

SELECT value FROM categories AS ordr
WHERE code IN (
    SELECT code FROM shipments AS lne
    WHERE lne.id = ordr.id
);


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

SELECT id FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = whs.status
);


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

SELECT name FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.level = shp.level
);


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

SELECT value FROM departments AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS txn
    WHERE txn.id = mgr.id
);


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

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


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.id = shp.id
);


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

SELECT name FROM products AS lne
WHERE value > (
    SELECT COUNT(value) FROM orders AS ordr
    WHERE ordr.status = lne.status
);


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

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


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

SELECT salary FROM shipments AS catg
WHERE salary > (
    SELECT SUM(amount) FROM customers AS txn
    WHERE txn.status = catg.status
);


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

SELECT salary FROM employees AS ord
WHERE value > (
    SELECT AVG(amount) FROM customers AS budg
    WHERE budg.id = ord.id
);


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

SELECT amount FROM warehouses AS mgr
WHERE id IN (
    SELECT id FROM regions AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT name FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = schd.level
);


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

SELECT salary FROM departments AS srvc
WHERE id IN (
    SELECT id FROM transactions AS emp
    WHERE emp.status = srvc.status
);


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

SELECT id FROM regions AS mgr
WHERE level IN (
    SELECT level FROM orders AS inv
    WHERE inv.code = mgr.code
);


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

SELECT value FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.status = acct.status
);


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

SELECT value FROM employees AS budg
WHERE value > (
    SELECT AVG(salary) FROM orders AS inv
    WHERE inv.level = budg.level
);


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

SELECT code FROM departments AS budg
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.type = budg.type
);


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

SELECT amount FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT amount FROM employees AS ord
WHERE salary > (
    SELECT MIN(salary) FROM customers AS shp
    WHERE shp.code = ord.code
);


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

SELECT salary FROM categories AS ordr
WHERE status IN (
    SELECT status FROM invoices AS budg
    WHERE budg.type = ordr.type
);


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

SELECT id FROM categories AS budg
WHERE level IN (
    SELECT level FROM invoices AS sale
    WHERE sale.level = budg.level
);


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

SELECT amount FROM branches AS schd
WHERE code IN (
    SELECT code FROM employees AS lne
    WHERE lne.type = schd.type
);


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

SELECT name FROM departments AS mgr
WHERE id IN (
    SELECT id FROM employees AS lne
    WHERE lne.status = mgr.status
);


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

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


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

SELECT id FROM orders AS budg
WHERE amount > (
    SELECT SUM(amount) FROM products AS txn
    WHERE txn.status = budg.status
);


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

SELECT id FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.code = acct.code
);


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

SELECT amount FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.id = empl.id
);


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

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


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

SELECT salary FROM invoices AS dept
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.type = dept.type
);


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

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


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

SELECT id FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = rgn.id
);


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

SELECT code FROM accounts AS srvc
WHERE id IN (
    SELECT id FROM invoices AS cust
    WHERE cust.level = srvc.level
);


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

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


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

SELECT name FROM employees AS sale
WHERE value > (
    SELECT COUNT(value) FROM projects AS srvc
    WHERE srvc.code = sale.code
);


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

SELECT name FROM departments AS prod
WHERE id IN (
    SELECT id FROM shipments AS sale
    WHERE sale.code = prod.code
);


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

SELECT name FROM regions AS srvc
WHERE type IN (
    SELECT type FROM warehouses AS whs
    WHERE whs.id = srvc.id
);


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

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


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

SELECT id FROM departments AS inv
WHERE value > (
    SELECT MIN(salary) FROM branches AS dept
    WHERE dept.status = inv.status
);


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

SELECT id FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.type = dept.type
);


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

SELECT value FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.id = prod.id
);


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

SELECT amount FROM products AS prod
WHERE salary > (
    SELECT AVG(value) FROM categories AS budg
    WHERE budg.status = prod.status
);


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

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


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

SELECT value FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT name FROM tasks AS whs
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT amount FROM shipments AS rgn
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.type = rgn.type
);


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

SELECT id FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.type = srvc.type
);


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

SELECT code FROM shipments AS emp
WHERE value > (
    SELECT AVG(value) FROM projects AS dept
    WHERE dept.status = emp.status
);


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

SELECT value FROM accounts AS shp
WHERE value > (
    SELECT MAX(amount) FROM orders AS mgr
    WHERE mgr.code = shp.code
);


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

SELECT id FROM products AS whs
WHERE value > (
    SELECT AVG(salary) FROM orders AS budg
    WHERE budg.status = whs.status
);


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

SELECT name FROM products AS prod
WHERE id IN (
    SELECT id FROM suppliers AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT amount FROM invoices AS prod
WHERE id IN (
    SELECT id FROM accounts AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT value FROM departments AS budg
WHERE level IN (
    SELECT level FROM transactions AS acct
    WHERE acct.id = budg.id
);


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

SELECT name FROM transactions AS cust
WHERE code IN (
    SELECT code FROM customers AS whs
    WHERE whs.status = cust.status
);


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

SELECT code FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.status = rgn.status
);


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

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


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

SELECT code FROM products AS sale
WHERE status IN (
    SELECT status FROM transactions AS whs
    WHERE whs.level = sale.level
);


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

SELECT salary FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.level = ord.level
);


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

SELECT code FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.level = budg.level
);


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

SELECT code FROM suppliers AS empl
WHERE id IN (
    SELECT id FROM orders AS whs
    WHERE whs.level = empl.level
);


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

SELECT salary FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.status = cust.status
);


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

SELECT amount FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.status = ord.status
);


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

SELECT amount FROM products AS ordr
WHERE code IN (
    SELECT code FROM invoices AS catg
    WHERE catg.status = ordr.status
);


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

SELECT code FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.status = srvc.status
);


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

SELECT code FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.code = emp.code
);


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

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


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

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


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

SELECT salary FROM accounts AS acct
WHERE status IN (
    SELECT status FROM projects AS cust
    WHERE cust.id = acct.id
);


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

SELECT amount FROM categories AS inv
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS acct
    WHERE acct.type = inv.type
);


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

SELECT value FROM regions AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM branches AS txn
    WHERE txn.code = acct.code
);


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

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


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

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


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

SELECT name FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.type = txn.type
);


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

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


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

SELECT salary FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.status = sale.status
);


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

SELECT name FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.type = catg.type
);


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

SELECT amount FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM categories AS emp
    WHERE emp.code = ordr.code
);


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

SELECT id FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.level = prod.level
);


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

SELECT value FROM products AS schd
WHERE code IN (
    SELECT code FROM warehouses AS dept
    WHERE dept.status = schd.status
);


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

SELECT name FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.type = sale.type
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = acct.type
);


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

SELECT id FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = sale.type
);


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

SELECT code FROM accounts AS mgr
WHERE amount > (
    SELECT AVG(value) FROM products AS ord
    WHERE ord.code = mgr.code
);


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

SELECT id FROM employees AS mgr
WHERE type IN (
    SELECT type FROM categories AS schd
    WHERE schd.id = mgr.id
);


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

SELECT salary FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.status = txn.status
);


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

SELECT salary FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.level = budg.level
);


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

SELECT id FROM invoices AS acct
WHERE level IN (
    SELECT level FROM regions AS cust
    WHERE cust.code = acct.code
);


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

SELECT amount FROM departments AS txn
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS mgr
    WHERE mgr.code = txn.code
);


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

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


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

SELECT salary FROM orders AS emp
WHERE salary > (
    SELECT SUM(value) FROM customers AS txn
    WHERE txn.level = emp.level
);


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

SELECT amount FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.level = sale.level
);


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

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


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

SELECT amount FROM categories AS schd
WHERE status IN (
    SELECT status FROM regions AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT code FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.status = catg.status
);


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

SELECT amount FROM regions AS shp
WHERE salary > (
    SELECT SUM(value) FROM branches AS whs
    WHERE whs.status = shp.status
);


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

SELECT salary FROM invoices AS shp
WHERE id IN (
    SELECT id FROM suppliers AS budg
    WHERE budg.type = shp.type
);


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

SELECT salary FROM suppliers AS rgn
WHERE type IN (
    SELECT type FROM departments AS acct
    WHERE acct.code = rgn.code
);


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

SELECT salary FROM suppliers AS ordr
WHERE amount > (
    SELECT MIN(value) FROM categories AS sale
    WHERE sale.level = ordr.level
);


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

SELECT name FROM customers AS empl
WHERE id IN (
    SELECT id FROM projects AS shp
    WHERE shp.id = empl.id
);


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

SELECT amount FROM orders AS lne
WHERE amount > (
    SELECT AVG(salary) FROM regions AS dept
    WHERE dept.status = lne.status
);


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

SELECT amount FROM projects AS catg
WHERE value > (
    SELECT COUNT(value) FROM invoices AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT salary FROM employees AS dept
WHERE id IN (
    SELECT id FROM products AS budg
    WHERE budg.id = dept.id
);


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

SELECT code FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.level = ordr.level
);


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

SELECT name FROM categories AS emp
WHERE status IN (
    SELECT status FROM orders AS shp
    WHERE shp.level = emp.level
);


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

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


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

SELECT id FROM projects AS whs
WHERE amount > (
    SELECT SUM(amount) FROM departments AS emp
    WHERE emp.status = whs.status
);


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

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


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

SELECT id FROM regions AS schd
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT code FROM departments AS inv
WHERE level IN (
    SELECT level FROM invoices AS cust
    WHERE cust.id = inv.id
);


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

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


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

SELECT salary FROM shipments AS sale
WHERE value > (
    SELECT MIN(amount) FROM tasks AS rgn
    WHERE rgn.level = sale.level
);


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

SELECT id FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.code = catg.code
);


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

SELECT id FROM customers AS txn
WHERE salary > (
    SELECT MIN(amount) FROM employees AS lne
    WHERE lne.code = txn.code
);


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

SELECT name FROM tasks AS txn
WHERE code IN (
    SELECT code FROM regions AS empl
    WHERE empl.level = txn.level
);


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

SELECT name FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT salary FROM invoices AS budg
WHERE type IN (
    SELECT type FROM orders AS cust
    WHERE cust.type = budg.type
);


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

SELECT salary FROM suppliers AS inv
WHERE code IN (
    SELECT code FROM departments AS sale
    WHERE sale.code = inv.code
);


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

SELECT salary FROM categories AS empl
WHERE value > (
    SELECT SUM(salary) FROM branches AS budg
    WHERE budg.id = empl.id
);


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

SELECT value FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.type = whs.type
);


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

SELECT salary FROM accounts AS lne
WHERE value > (
    SELECT COUNT(salary) FROM invoices AS schd
    WHERE schd.level = lne.level
);


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

SELECT value FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.status = empl.status
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.id = budg.id
);


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

SELECT amount FROM shipments AS lne
WHERE id IN (
    SELECT id FROM employees AS schd
    WHERE schd.level = lne.level
);


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

SELECT amount FROM transactions AS rgn
WHERE code IN (
    SELECT code FROM orders AS ord
    WHERE ord.level = rgn.level
);


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

SELECT name FROM orders AS txn
WHERE type IN (
    SELECT type FROM invoices AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT code FROM invoices AS shp
WHERE code IN (
    SELECT code FROM categories AS schd
    WHERE schd.code = shp.code
);


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

SELECT id FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.id = srvc.id
);


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

SELECT value FROM customers AS ord
WHERE level IN (
    SELECT level FROM warehouses AS txn
    WHERE txn.level = ord.level
);


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

SELECT salary FROM shipments AS cust
WHERE amount > (
    SELECT COUNT(amount) FROM accounts AS sale
    WHERE sale.id = cust.id
);


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

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


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

SELECT salary FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.type = catg.type
);


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

SELECT id FROM orders AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS schd
    WHERE schd.code = mgr.code
);


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

SELECT name FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT code FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM tasks AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT name FROM warehouses AS srvc
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS sale
    WHERE sale.id = srvc.id
);


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

SELECT value FROM warehouses AS dept
WHERE amount > (
    SELECT AVG(salary) FROM orders AS shp
    WHERE shp.type = dept.type
);


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

SELECT amount FROM branches AS whs
WHERE value > (
    SELECT AVG(value) FROM categories AS budg
    WHERE budg.status = whs.status
);


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

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


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

SELECT salary FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT name FROM invoices AS emp
WHERE value > (
    SELECT AVG(salary) FROM customers AS schd
    WHERE schd.code = emp.code
);


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

SELECT code FROM projects AS schd
WHERE level IN (
    SELECT level FROM shipments AS ordr
    WHERE ordr.id = schd.id
);


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

SELECT name FROM categories AS ord
WHERE salary > (
    SELECT COUNT(value) FROM departments AS dept
    WHERE dept.level = ord.level
);


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

SELECT id FROM products AS empl
WHERE value > (
    SELECT COUNT(salary) FROM customers AS dept
    WHERE dept.type = empl.type
);


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

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


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

SELECT name FROM products AS mgr
WHERE type IN (
    SELECT type FROM employees AS dept
    WHERE dept.level = mgr.level
);


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

SELECT id FROM warehouses AS sale
WHERE value > (
    SELECT AVG(value) FROM customers AS schd
    WHERE schd.code = sale.code
);


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

SELECT salary FROM customers AS shp
WHERE value > (
    SELECT COUNT(value) FROM transactions AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT salary FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.status = dept.status
);


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

SELECT salary FROM invoices AS shp
WHERE id IN (
    SELECT id FROM shipments AS txn
    WHERE txn.type = shp.type
);


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

SELECT id FROM suppliers AS acct
WHERE value > (
    SELECT AVG(salary) FROM categories AS whs
    WHERE whs.code = acct.code
);


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

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


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

SELECT amount FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.id = lne.id
);


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

SELECT id FROM suppliers AS dept
WHERE amount > (
    SELECT MIN(salary) FROM transactions AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT id FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.status = catg.status
);


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

SELECT code FROM suppliers AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS txn
    WHERE txn.code = catg.code
);


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

SELECT id FROM tasks AS ord
WHERE amount > (
    SELECT SUM(amount) FROM employees AS empl
    WHERE empl.level = ord.level
);


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

SELECT name FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.code = srvc.code
);


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

SELECT code FROM categories AS lne
WHERE type IN (
    SELECT type FROM products AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT amount FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT code FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.status = schd.status
);


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

SELECT amount FROM warehouses AS acct
WHERE id IN (
    SELECT id FROM suppliers AS rgn
    WHERE rgn.code = acct.code
);


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

SELECT code FROM categories AS mgr
WHERE value > (
    SELECT MAX(value) FROM customers AS cust
    WHERE cust.level = mgr.level
);


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

SELECT code FROM warehouses AS catg
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT code FROM departments AS sale
WHERE type IN (
    SELECT type FROM regions AS empl
    WHERE empl.level = sale.level
);


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

SELECT salary FROM shipments AS rgn
WHERE code IN (
    SELECT code FROM transactions AS emp
    WHERE emp.id = rgn.id
);


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

SELECT code FROM products AS acct
WHERE value > (
    SELECT MIN(amount) FROM shipments AS prod
    WHERE prod.type = acct.type
);


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

SELECT name FROM departments AS srvc
WHERE amount > (
    SELECT SUM(salary) FROM orders AS ordr
    WHERE ordr.status = srvc.status
);