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

SELECT name FROM accounts AS prod
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.status = prod.status
);


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

SELECT salary FROM employees AS mgr
WHERE id IN (
    SELECT id FROM warehouses AS prod
    WHERE prod.status = mgr.status
);


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

SELECT id FROM branches AS inv
WHERE id IN (
    SELECT id FROM categories AS whs
    WHERE whs.id = inv.id
);


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

SELECT code FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.level = dept.level
);


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

SELECT name FROM regions AS acct
WHERE salary > (
    SELECT AVG(salary) FROM projects AS dept
    WHERE dept.id = acct.id
);


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

SELECT salary FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.code = txn.code
);


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

SELECT id FROM shipments AS srvc
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.id = srvc.id
);


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

SELECT salary FROM shipments AS schd
WHERE type IN (
    SELECT type FROM categories AS rgn
    WHERE rgn.id = schd.id
);


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

SELECT code FROM customers AS dept
WHERE level IN (
    SELECT level FROM transactions AS rgn
    WHERE rgn.type = dept.type
);


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

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


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

SELECT amount FROM projects AS acct
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.level = acct.level
);


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

SELECT salary FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.id = prod.id
);


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

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


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

SELECT amount FROM products AS catg
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.status = catg.status
);


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

SELECT salary FROM employees AS acct
WHERE value > (
    SELECT COUNT(value) FROM accounts AS catg
    WHERE catg.type = acct.type
);


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

SELECT name FROM accounts AS rgn
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS txn
    WHERE txn.type = rgn.type
);


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

SELECT salary FROM projects AS ordr
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS acct
    WHERE acct.status = ordr.status
);


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

SELECT code FROM invoices AS ord
WHERE type IN (
    SELECT type FROM employees AS whs
    WHERE whs.type = ord.type
);


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

SELECT amount FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.type = whs.type
);


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

SELECT amount FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.id = prod.id
);


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

SELECT code FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT code FROM branches AS catg
WHERE code IN (
    SELECT code FROM departments AS sale
    WHERE sale.level = catg.level
);


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

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


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

SELECT id FROM departments AS empl
WHERE salary > (
    SELECT COUNT(value) FROM suppliers AS ord
    WHERE ord.id = empl.id
);


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

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


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

SELECT id FROM orders AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM products AS ord
    WHERE ord.status = lne.status
);


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

SELECT name FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.code = prod.code
);


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

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


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

SELECT code FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.status = dept.status
);


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

SELECT salary FROM projects AS schd
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.code = schd.code
);


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

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


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

SELECT id FROM accounts AS dept
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.code = dept.code
);


Prompt:
Schema:
  transactions (alias: ordr)(id, level, amount, salary)
  tasks(type, amount, salary, id)
Task: Retrieve id from transactions with amount above the AVG(salary) of tasks rows sharing the same code.
SQL:

SELECT id FROM transactions AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS inv
    WHERE inv.code = ordr.code
);


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

SELECT value FROM warehouses AS ord
WHERE amount > (
    SELECT SUM(value) FROM branches AS emp
    WHERE emp.status = ord.status
);


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

SELECT value FROM regions AS ord
WHERE id IN (
    SELECT id FROM employees AS inv
    WHERE inv.status = ord.status
);


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

SELECT amount FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.type = rgn.type
);


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

SELECT salary FROM invoices AS prod
WHERE code IN (
    SELECT code FROM regions AS ord
    WHERE ord.id = prod.id
);


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

SELECT amount FROM warehouses AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS cust
    WHERE cust.code = schd.code
);


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

SELECT amount FROM accounts AS schd
WHERE code IN (
    SELECT code FROM departments AS cust
    WHERE cust.status = schd.status
);


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

SELECT value FROM orders AS srvc
WHERE type IN (
    SELECT type FROM suppliers AS acct
    WHERE acct.level = srvc.level
);


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

SELECT code FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT amount FROM orders AS emp
WHERE value > (
    SELECT AVG(amount) FROM shipments AS shp
    WHERE shp.type = emp.type
);


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

SELECT amount FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT id FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.code = mgr.code
);


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

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


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

SELECT salary FROM projects AS lne
WHERE level IN (
    SELECT level FROM categories AS shp
    WHERE shp.code = lne.code
);


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

SELECT name FROM projects AS whs
WHERE value > (
    SELECT AVG(amount) FROM tasks AS inv
    WHERE inv.id = whs.id
);


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

SELECT name FROM employees AS inv
WHERE id IN (
    SELECT id FROM projects AS txn
    WHERE txn.code = inv.code
);


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

SELECT code FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.code = sale.code
);


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

SELECT salary FROM shipments AS inv
WHERE code IN (
    SELECT code FROM regions AS budg
    WHERE budg.code = inv.code
);


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

SELECT value FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT value FROM customers AS shp
WHERE value > (
    SELECT AVG(value) FROM departments AS acct
    WHERE acct.status = shp.status
);


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

SELECT value FROM shipments AS cust
WHERE type IN (
    SELECT type FROM branches AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT id FROM suppliers AS rgn
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT amount FROM branches AS rgn
WHERE value > (
    SELECT MIN(value) FROM transactions AS cust
    WHERE cust.type = rgn.type
);


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

SELECT value FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.level = cust.level
);


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

SELECT value FROM products AS budg
WHERE amount > (
    SELECT SUM(salary) FROM branches AS cust
    WHERE cust.status = budg.status
);


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

SELECT amount FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT salary FROM employees AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS sale
    WHERE sale.code = ordr.code
);


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

SELECT name FROM projects AS dept
WHERE amount > (
    SELECT MIN(amount) FROM customers AS sale
    WHERE sale.type = dept.type
);


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

SELECT name FROM suppliers AS whs
WHERE level IN (
    SELECT level FROM employees AS sale
    WHERE sale.code = whs.code
);


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

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


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

SELECT salary FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.id = shp.id
);


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

SELECT id FROM employees AS whs
WHERE type IN (
    SELECT type FROM departments AS rgn
    WHERE rgn.code = whs.code
);


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

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


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

SELECT code FROM accounts AS txn
WHERE value > (
    SELECT AVG(amount) FROM projects AS dept
    WHERE dept.id = txn.id
);


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

SELECT salary FROM categories AS prod
WHERE code IN (
    SELECT code FROM warehouses AS txn
    WHERE txn.code = prod.code
);


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

SELECT code FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.type = ord.type
);


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

SELECT name FROM employees AS budg
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS lne
    WHERE lne.status = budg.status
);


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT name FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.type = prod.type
);


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

SELECT amount FROM departments AS schd
WHERE salary > (
    SELECT MAX(amount) FROM employees AS inv
    WHERE inv.level = schd.level
);


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

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


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

SELECT value FROM branches AS txn
WHERE amount > (
    SELECT SUM(salary) FROM projects AS lne
    WHERE lne.status = txn.status
);


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

SELECT value FROM regions AS emp
WHERE code IN (
    SELECT code FROM suppliers AS whs
    WHERE whs.type = emp.type
);


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

SELECT name FROM categories AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS cust
    WHERE cust.type = sale.type
);


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

SELECT name FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = emp.level
);


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

SELECT salary FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.code = sale.code
);


Prompt:
Schema:
  invoices (alias: cust)(id, amount, salary, status)
  branches(id, value, type, code)
Task: Retrieve value from invoices with value above the MIN(value) of branches rows sharing the same type.
SQL:

SELECT value FROM invoices AS cust
WHERE value > (
    SELECT MIN(value) FROM branches AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT name FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.code = cust.code
);


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

SELECT id FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.status = ord.status
);


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

SELECT value FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.status = inv.status
);


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

SELECT name FROM departments AS budg
WHERE level IN (
    SELECT level FROM suppliers AS shp
    WHERE shp.status = budg.status
);


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

SELECT amount FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT id FROM accounts AS rgn
WHERE type IN (
    SELECT type FROM customers AS budg
    WHERE budg.type = rgn.type
);


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

SELECT name FROM orders AS acct
WHERE status IN (
    SELECT status FROM employees AS budg
    WHERE budg.id = acct.id
);


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

SELECT name FROM transactions AS inv
WHERE amount > (
    SELECT SUM(amount) FROM employees AS catg
    WHERE catg.id = inv.id
);


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

SELECT value FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.status = catg.status
);


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

SELECT amount FROM orders AS srvc
WHERE value > (
    SELECT SUM(amount) FROM invoices AS cust
    WHERE cust.level = srvc.level
);


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

SELECT name FROM regions AS mgr
WHERE id IN (
    SELECT id FROM warehouses AS inv
    WHERE inv.type = mgr.type
);


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

SELECT id FROM products AS shp
WHERE code IN (
    SELECT code FROM warehouses AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT id FROM categories AS cust
WHERE type IN (
    SELECT type FROM warehouses AS acct
    WHERE acct.id = cust.id
);


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

SELECT name FROM departments AS schd
WHERE status IN (
    SELECT status FROM regions AS cust
    WHERE cust.level = schd.level
);


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

SELECT amount FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT value FROM tasks AS cust
WHERE status IN (
    SELECT status FROM transactions AS acct
    WHERE acct.id = cust.id
);


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

SELECT salary FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.code = prod.code
);


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

SELECT amount FROM products AS budg
WHERE value > (
    SELECT AVG(value) FROM shipments AS ordr
    WHERE ordr.level = budg.level
);


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

SELECT id FROM products AS whs
WHERE value > (
    SELECT MIN(salary) FROM categories AS inv
    WHERE inv.level = whs.level
);


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

SELECT name FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.type = shp.type
);


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

SELECT code FROM departments AS inv
WHERE type IN (
    SELECT type FROM customers AS empl
    WHERE empl.level = inv.level
);


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

SELECT name FROM categories AS mgr
WHERE value > (
    SELECT MAX(value) FROM accounts AS dept
    WHERE dept.id = mgr.id
);


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

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


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

SELECT amount FROM categories AS inv
WHERE id IN (
    SELECT id FROM transactions AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT amount FROM categories AS dept
WHERE id IN (
    SELECT id FROM branches AS ordr
    WHERE ordr.code = dept.code
);


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

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


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

SELECT salary FROM projects AS mgr
WHERE amount > (
    SELECT MIN(value) FROM branches AS sale
    WHERE sale.type = mgr.type
);


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

SELECT salary FROM customers AS ordr
WHERE value > (
    SELECT SUM(value) FROM products AS txn
    WHERE txn.type = ordr.type
);


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

SELECT value FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.status = ordr.status
);


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

SELECT amount FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.id = budg.id
);


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

SELECT name FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.code = rgn.code
);


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

SELECT salary FROM invoices AS empl
WHERE salary > (
    SELECT MAX(value) FROM orders AS lne
    WHERE lne.type = empl.type
);


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

SELECT salary FROM products AS budg
WHERE value > (
    SELECT MAX(value) FROM regions AS whs
    WHERE whs.code = budg.code
);


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

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


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

SELECT value FROM customers AS budg
WHERE id IN (
    SELECT id FROM regions AS txn
    WHERE txn.type = budg.type
);


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

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


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

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


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

SELECT code FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.level = shp.level
);


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

SELECT id FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.level = rgn.level
);


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

SELECT code FROM products AS rgn
WHERE code IN (
    SELECT code FROM projects AS ord
    WHERE ord.level = rgn.level
);


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

SELECT value FROM departments AS dept
WHERE value > (
    SELECT COUNT(salary) FROM orders AS inv
    WHERE inv.code = dept.code
);


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

SELECT amount FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT name FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.status = rgn.status
);


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

SELECT code FROM departments AS empl
WHERE code IN (
    SELECT code FROM shipments AS dept
    WHERE dept.status = empl.status
);


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

SELECT id FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.code = sale.code
);


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

SELECT id FROM warehouses AS txn
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.status = txn.status
);


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

SELECT amount FROM shipments AS sale
WHERE value > (
    SELECT SUM(value) FROM branches AS schd
    WHERE schd.type = sale.type
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT id FROM suppliers AS rgn
WHERE type IN (
    SELECT type FROM categories AS ord
    WHERE ord.type = rgn.type
);


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

SELECT amount FROM projects AS srvc
WHERE value > (
    SELECT MAX(amount) FROM accounts AS cust
    WHERE cust.type = srvc.type
);


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

SELECT name FROM departments AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT id FROM orders AS budg
WHERE value > (
    SELECT MIN(amount) FROM categories AS inv
    WHERE inv.id = budg.id
);


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

SELECT name FROM warehouses AS shp
WHERE level IN (
    SELECT level FROM products AS catg
    WHERE catg.level = shp.level
);


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

SELECT salary FROM categories AS cust
WHERE type IN (
    SELECT type FROM regions AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT id FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT code FROM customers AS srvc
WHERE id IN (
    SELECT id FROM projects AS ordr
    WHERE ordr.code = srvc.code
);


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

SELECT name FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = inv.id
);


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

SELECT salary FROM invoices AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM transactions AS lne
    WHERE lne.status = ordr.status
);


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

SELECT code FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.status = whs.status
);


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

SELECT amount FROM transactions AS emp
WHERE amount > (
    SELECT MIN(value) FROM branches AS dept
    WHERE dept.status = emp.status
);


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

SELECT amount FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.id = catg.id
);


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

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


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

SELECT salary FROM suppliers AS ord
WHERE id IN (
    SELECT id FROM regions AS cust
    WHERE cust.type = ord.type
);


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

SELECT value FROM projects AS mgr
WHERE status IN (
    SELECT status FROM regions AS acct
    WHERE acct.level = mgr.level
);


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

SELECT code FROM shipments AS ordr
WHERE type IN (
    SELECT type FROM projects AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT id FROM departments AS budg
WHERE code IN (
    SELECT code FROM transactions AS schd
    WHERE schd.level = budg.level
);


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

SELECT id FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.type = prod.type
);


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

SELECT amount FROM orders AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM departments AS txn
    WHERE txn.code = srvc.code
);


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

SELECT amount FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.id = mgr.id
);


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

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


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

SELECT amount FROM tasks AS ordr
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS schd
    WHERE schd.id = ordr.id
);


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

SELECT salary FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT salary FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.id = catg.id
);


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

SELECT amount FROM employees AS inv
WHERE type IN (
    SELECT type FROM categories AS sale
    WHERE sale.type = inv.type
);


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

SELECT name FROM projects AS rgn
WHERE level IN (
    SELECT level FROM departments AS txn
    WHERE txn.code = rgn.code
);


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

SELECT name FROM products AS inv
WHERE type IN (
    SELECT type FROM customers AS shp
    WHERE shp.id = inv.id
);


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

SELECT code FROM suppliers AS rgn
WHERE level IN (
    SELECT level FROM employees AS ord
    WHERE ord.level = rgn.level
);


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

SELECT value FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.type = srvc.type
);


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

SELECT salary FROM invoices AS mgr
WHERE id IN (
    SELECT id FROM customers AS txn
    WHERE txn.level = mgr.level
);


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

SELECT name FROM categories AS empl
WHERE type IN (
    SELECT type FROM regions AS acct
    WHERE acct.level = empl.level
);


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.level = dept.level
);


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

SELECT name FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT id FROM invoices AS inv
WHERE salary > (
    SELECT MAX(amount) FROM orders AS rgn
    WHERE rgn.code = inv.code
);


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

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


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

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


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

SELECT code FROM shipments AS txn
WHERE value > (
    SELECT COUNT(salary) FROM suppliers AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT code FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.type = txn.type
);


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

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


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

SELECT salary FROM customers AS dept
WHERE value > (
    SELECT SUM(salary) FROM accounts AS acct
    WHERE acct.id = dept.id
);


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

SELECT code FROM transactions AS txn
WHERE type IN (
    SELECT type FROM categories AS shp
    WHERE shp.id = txn.id
);


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

SELECT salary FROM warehouses AS ordr
WHERE code IN (
    SELECT code FROM orders AS lne
    WHERE lne.code = ordr.code
);


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

SELECT salary FROM shipments AS acct
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS inv
    WHERE inv.type = acct.type
);


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

SELECT id FROM tasks AS budg
WHERE amount > (
    SELECT MAX(value) FROM orders AS cust
    WHERE cust.type = budg.type
);


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

SELECT id FROM projects AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM departments AS catg
    WHERE catg.code = rgn.code
);


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

SELECT code FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.status = ord.status
);


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

SELECT code FROM transactions AS prod
WHERE status IN (
    SELECT status FROM warehouses AS txn
    WHERE txn.id = prod.id
);


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

SELECT value FROM branches AS mgr
WHERE id IN (
    SELECT id FROM regions AS schd
    WHERE schd.status = mgr.status
);


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

SELECT code FROM projects AS empl
WHERE status IN (
    SELECT status FROM invoices AS whs
    WHERE whs.level = empl.level
);


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

SELECT code FROM employees AS rgn
WHERE value > (
    SELECT SUM(value) FROM regions AS acct
    WHERE acct.level = rgn.level
);


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

SELECT amount FROM invoices AS schd
WHERE code IN (
    SELECT code FROM shipments AS sale
    WHERE sale.level = schd.level
);


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

SELECT id FROM transactions AS txn
WHERE status IN (
    SELECT status FROM branches AS empl
    WHERE empl.id = txn.id
);


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

SELECT id FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.code = emp.code
);


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

SELECT value FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.code = acct.code
);


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

SELECT amount FROM branches AS dept
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS prod
    WHERE prod.id = dept.id
);


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

SELECT amount FROM invoices AS inv
WHERE code IN (
    SELECT code FROM projects AS txn
    WHERE txn.level = inv.level
);


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

SELECT name FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.status = emp.status
);


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

SELECT salary FROM employees AS sale
WHERE code IN (
    SELECT code FROM suppliers AS cust
    WHERE cust.level = sale.level
);


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

SELECT name FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.code = empl.code
);


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

SELECT code FROM products AS mgr
WHERE type IN (
    SELECT type FROM suppliers AS prod
    WHERE prod.code = mgr.code
);


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

SELECT salary FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.code = prod.code
);


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

SELECT id FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.code = inv.code
);


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

SELECT value FROM suppliers AS whs
WHERE salary > (
    SELECT SUM(value) FROM tasks AS catg
    WHERE catg.code = whs.code
);


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

SELECT salary FROM invoices AS schd
WHERE status IN (
    SELECT status FROM shipments AS inv
    WHERE inv.id = schd.id
);


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

SELECT name FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.id = shp.id
);


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

SELECT amount FROM suppliers AS emp
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT id FROM suppliers AS lne
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS acct
    WHERE acct.id = lne.id
);


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

SELECT salary FROM products AS srvc
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS emp
    WHERE emp.status = srvc.status
);


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

SELECT code FROM transactions AS inv
WHERE value > (
    SELECT AVG(salary) FROM tasks AS srvc
    WHERE srvc.id = inv.id
);


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

SELECT code FROM categories AS dept
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS shp
    WHERE shp.code = dept.code
);


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

SELECT name FROM products AS cust
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT value FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.type = schd.type
);


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

SELECT name FROM tasks AS txn
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS schd
    WHERE schd.type = txn.type
);


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

SELECT value FROM projects AS catg
WHERE level IN (
    SELECT level FROM departments AS acct
    WHERE acct.code = catg.code
);


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

SELECT value FROM invoices AS srvc
WHERE level IN (
    SELECT level FROM customers AS sale
    WHERE sale.level = srvc.level
);


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

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


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

SELECT amount FROM transactions AS ord
WHERE amount > (
    SELECT MIN(amount) FROM orders AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT value FROM suppliers AS srvc
WHERE type IN (
    SELECT type FROM products AS inv
    WHERE inv.type = srvc.type
);


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

SELECT name FROM customers AS schd
WHERE value > (
    SELECT SUM(salary) FROM departments AS shp
    WHERE shp.status = schd.status
);


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

SELECT code FROM products AS lne
WHERE amount > (
    SELECT MAX(amount) FROM employees AS prod
    WHERE prod.level = lne.level
);


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

SELECT id FROM customers AS empl
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS catg
    WHERE catg.status = empl.status
);


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

SELECT id FROM products AS acct
WHERE amount > (
    SELECT SUM(amount) FROM categories AS lne
    WHERE lne.type = acct.type
);


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

SELECT value FROM accounts AS catg
WHERE code IN (
    SELECT code FROM customers AS dept
    WHERE dept.code = catg.code
);


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

SELECT id FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.status = catg.status
);


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

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


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

SELECT id FROM categories AS shp
WHERE value > (
    SELECT AVG(value) FROM suppliers AS whs
    WHERE whs.level = shp.level
);


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

SELECT amount FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.status = catg.status
);


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

SELECT name FROM projects AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM warehouses AS ord
    WHERE ord.type = mgr.type
);


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

SELECT id FROM regions AS budg
WHERE status IN (
    SELECT status FROM suppliers AS prod
    WHERE prod.status = budg.status
);


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

SELECT code FROM departments AS budg
WHERE type IN (
    SELECT type FROM transactions AS prod
    WHERE prod.type = budg.type
);


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

SELECT salary FROM transactions AS catg
WHERE type IN (
    SELECT type FROM accounts AS schd
    WHERE schd.code = catg.code
);


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

SELECT amount FROM transactions AS budg
WHERE id IN (
    SELECT id FROM suppliers AS lne
    WHERE lne.level = budg.level
);


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

SELECT salary FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.level = rgn.level
);


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

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


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

SELECT id FROM shipments AS prod
WHERE status IN (
    SELECT status FROM departments AS ordr
    WHERE ordr.status = prod.status
);


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

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


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

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


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

SELECT salary FROM regions AS srvc
WHERE code IN (
    SELECT code FROM categories AS whs
    WHERE whs.code = srvc.code
);


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

SELECT code FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.level = ord.level
);


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

SELECT value FROM warehouses AS prod
WHERE salary > (
    SELECT AVG(value) FROM tasks AS cust
    WHERE cust.type = prod.type
);


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

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


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

SELECT id FROM tasks AS catg
WHERE type IN (
    SELECT type FROM warehouses AS schd
    WHERE schd.status = catg.status
);


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

SELECT amount FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.code = catg.code
);


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

SELECT amount FROM invoices AS schd
WHERE status IN (
    SELECT status FROM shipments AS empl
    WHERE empl.level = schd.level
);


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

SELECT id FROM departments AS acct
WHERE type IN (
    SELECT type FROM tasks AS sale
    WHERE sale.id = acct.id
);


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

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


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

SELECT value FROM accounts AS dept
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT value FROM categories AS budg
WHERE status IN (
    SELECT status FROM accounts AS srvc
    WHERE srvc.level = budg.level
);


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

SELECT name FROM warehouses AS txn
WHERE amount > (
    SELECT SUM(value) FROM suppliers AS catg
    WHERE catg.status = txn.status
);


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

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


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

SELECT id FROM customers AS emp
WHERE type IN (
    SELECT type FROM regions AS acct
    WHERE acct.id = emp.id
);


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

SELECT name FROM orders AS emp
WHERE value > (
    SELECT SUM(value) FROM products AS budg
    WHERE budg.code = emp.code
);


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

SELECT amount FROM transactions AS ord
WHERE amount > (
    SELECT COUNT(value) FROM customers AS inv
    WHERE inv.type = ord.type
);


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

SELECT value FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.type = emp.type
);


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

SELECT id FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.type = rgn.type
);


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

SELECT name FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.type = budg.type
);


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

SELECT id FROM categories AS dept
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS acct
    WHERE acct.type = dept.type
);


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

SELECT salary FROM customers AS catg
WHERE value > (
    SELECT COUNT(value) FROM warehouses AS srvc
    WHERE srvc.status = catg.status
);


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

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


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

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


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

SELECT code FROM accounts AS shp
WHERE value > (
    SELECT AVG(value) FROM categories AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT id FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.status = mgr.status
);


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

SELECT value FROM orders AS dept
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS acct
    WHERE acct.status = dept.status
);


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

SELECT code FROM accounts AS rgn
WHERE level IN (
    SELECT level FROM shipments AS cust
    WHERE cust.type = rgn.type
);


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

SELECT salary FROM tasks AS prod
WHERE code IN (
    SELECT code FROM categories AS sale
    WHERE sale.type = prod.type
);


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

SELECT salary FROM accounts AS mgr
WHERE amount > (
    SELECT AVG(value) FROM products AS budg
    WHERE budg.id = mgr.id
);


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

SELECT salary FROM categories AS cust
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS inv
    WHERE inv.code = cust.code
);


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

SELECT salary FROM suppliers AS whs
WHERE salary > (
    SELECT MAX(amount) FROM departments AS schd
    WHERE schd.status = whs.status
);


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

SELECT salary FROM projects AS srvc
WHERE code IN (
    SELECT code FROM warehouses AS cust
    WHERE cust.level = srvc.level
);


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

SELECT amount FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.type = txn.type
);


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

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


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

SELECT name FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.level = cust.level
);


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

SELECT amount FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.id = emp.id
);


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

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


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

SELECT value FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.type = mgr.type
);


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

SELECT salary FROM branches AS emp
WHERE status IN (
    SELECT status FROM shipments AS schd
    WHERE schd.status = emp.status
);


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

SELECT id FROM transactions AS dept
WHERE status IN (
    SELECT status FROM categories AS sale
    WHERE sale.id = dept.id
);


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

SELECT amount FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.level = acct.level
);


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

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


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

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


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

SELECT salary FROM branches AS catg
WHERE level IN (
    SELECT level FROM departments AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT id FROM projects AS ordr
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.status = ordr.status
);


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

SELECT amount FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = srvc.id
);


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

SELECT value FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.status = dept.status
);


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

SELECT name FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.code = prod.code
);


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

SELECT amount FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.status = txn.status
);


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

SELECT name FROM departments AS emp
WHERE value > (
    SELECT MAX(amount) FROM transactions AS budg
    WHERE budg.code = emp.code
);


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

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


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

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


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

SELECT salary FROM branches AS acct
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.type = acct.type
);


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

SELECT value FROM transactions AS inv
WHERE id IN (
    SELECT id FROM orders AS prod
    WHERE prod.code = inv.code
);


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

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


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

SELECT salary FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.id = mgr.id
);


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

SELECT code FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.status = txn.status
);


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

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


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

SELECT salary FROM warehouses AS mgr
WHERE value > (
    SELECT COUNT(value) FROM tasks AS empl
    WHERE empl.status = mgr.status
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.code = cust.code
);


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

SELECT value FROM categories AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS dept
    WHERE dept.status = mgr.status
);


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

SELECT name FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM employees AS txn
    WHERE txn.status = mgr.status
);


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

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


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

SELECT id FROM shipments AS sale
WHERE amount > (
    SELECT MAX(salary) FROM categories AS catg
    WHERE catg.code = sale.code
);


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

SELECT code FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = empl.type
);


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

SELECT code FROM departments AS mgr
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS schd
    WHERE schd.type = mgr.type
);


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

SELECT id FROM products AS prod
WHERE id IN (
    SELECT id FROM categories AS sale
    WHERE sale.status = prod.status
);