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

SELECT name FROM accounts AS prod
WHERE value > (
    SELECT SUM(value) FROM shipments AS dept
    WHERE dept.type = prod.type
);


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

SELECT id FROM orders AS txn
WHERE type IN (
    SELECT type FROM warehouses AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT salary FROM transactions AS rgn
WHERE id IN (
    SELECT id FROM customers AS schd
    WHERE schd.code = rgn.code
);


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

SELECT name FROM branches AS cust
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.type = cust.type
);


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

SELECT value FROM customers AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS dept
    WHERE dept.code = rgn.code
);


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

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


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

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


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

SELECT code FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT code FROM branches AS whs
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS prod
    WHERE prod.code = whs.code
);


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

SELECT value FROM accounts AS schd
WHERE value > (
    SELECT MAX(salary) FROM orders AS whs
    WHERE whs.type = schd.type
);


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

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


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

SELECT value FROM tasks AS shp
WHERE amount > (
    SELECT MAX(value) FROM branches AS sale
    WHERE sale.code = shp.code
);


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

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


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

SELECT value FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.level = ord.level
);


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

SELECT amount FROM projects AS prod
WHERE id IN (
    SELECT id FROM transactions AS catg
    WHERE catg.status = prod.status
);


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

SELECT amount FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.id = ordr.id
);


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

SELECT id FROM accounts AS dept
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS txn
    WHERE txn.code = dept.code
);


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

SELECT salary FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.id = budg.id
);


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

SELECT code FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.status = inv.status
);


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

SELECT name FROM accounts AS txn
WHERE amount > (
    SELECT MAX(amount) FROM branches AS catg
    WHERE catg.level = txn.level
);


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

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


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

SELECT code FROM shipments AS srvc
WHERE amount > (
    SELECT SUM(value) FROM categories AS emp
    WHERE emp.code = srvc.code
);


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

SELECT value FROM projects AS schd
WHERE amount > (
    SELECT SUM(value) FROM categories AS ord
    WHERE ord.level = schd.level
);


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

SELECT id FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.level = srvc.level
);


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

SELECT name FROM shipments AS cust
WHERE salary > (
    SELECT COUNT(value) FROM regions AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT amount FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.id = txn.id
);


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

SELECT code FROM orders AS ordr
WHERE salary > (
    SELECT MIN(value) FROM projects AS cust
    WHERE cust.level = ordr.level
);


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

SELECT salary FROM branches AS dept
WHERE id IN (
    SELECT id FROM invoices AS schd
    WHERE schd.level = dept.level
);


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

SELECT id FROM projects AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS whs
    WHERE whs.level = txn.level
);


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

SELECT amount FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.status = srvc.status
);


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

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


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

SELECT value FROM warehouses AS inv
WHERE amount > (
    SELECT SUM(salary) FROM regions AS empl
    WHERE empl.level = inv.level
);


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

SELECT salary FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.type = txn.type
);


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

SELECT name FROM categories AS schd
WHERE value > (
    SELECT AVG(amount) FROM products AS srvc
    WHERE srvc.id = schd.id
);


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

SELECT salary FROM warehouses AS emp
WHERE status IN (
    SELECT status FROM orders AS inv
    WHERE inv.type = emp.type
);


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

SELECT id FROM shipments AS inv
WHERE amount > (
    SELECT MIN(value) FROM projects AS dept
    WHERE dept.status = inv.status
);


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

SELECT salary FROM accounts AS emp
WHERE amount > (
    SELECT AVG(salary) FROM departments AS lne
    WHERE lne.code = emp.code
);


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

SELECT name FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.code = acct.code
);


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

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


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

SELECT salary FROM invoices AS empl
WHERE type IN (
    SELECT type FROM projects AS txn
    WHERE txn.code = empl.code
);


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

SELECT value FROM invoices AS inv
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS emp
    WHERE emp.status = inv.status
);


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

SELECT id FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = inv.status
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT value FROM departments AS prod
WHERE value > (
    SELECT MAX(amount) FROM invoices AS catg
    WHERE catg.type = prod.type
);


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

SELECT code FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.type = empl.type
);


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

SELECT salary FROM customers AS schd
WHERE code IN (
    SELECT code FROM shipments AS budg
    WHERE budg.code = schd.code
);


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

SELECT code FROM invoices AS emp
WHERE level IN (
    SELECT level FROM categories AS whs
    WHERE whs.id = emp.id
);


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

SELECT id FROM regions AS lne
WHERE code IN (
    SELECT code FROM shipments AS dept
    WHERE dept.status = lne.status
);


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

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


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

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


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

SELECT id FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT code FROM projects AS ord
WHERE level IN (
    SELECT level FROM invoices AS cust
    WHERE cust.status = ord.status
);


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

SELECT salary FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.code = schd.code
);


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

SELECT amount FROM categories AS shp
WHERE type IN (
    SELECT type FROM invoices AS schd
    WHERE schd.status = shp.status
);


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

SELECT value FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT salary FROM tasks AS emp
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS lne
    WHERE lne.id = emp.id
);


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

SELECT salary FROM employees AS catg
WHERE value > (
    SELECT SUM(value) FROM suppliers AS budg
    WHERE budg.level = catg.level
);


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

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


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

SELECT name FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.id = sale.id
);


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

SELECT value FROM invoices AS inv
WHERE id IN (
    SELECT id FROM branches AS prod
    WHERE prod.code = inv.code
);


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

SELECT value FROM regions AS shp
WHERE status IN (
    SELECT status FROM employees AS whs
    WHERE whs.code = shp.code
);


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

SELECT amount FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.code = ordr.code
);


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

SELECT code FROM suppliers AS inv
WHERE value > (
    SELECT MIN(salary) FROM departments AS cust
    WHERE cust.id = inv.id
);


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

SELECT value FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.code = srvc.code
);


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

SELECT salary FROM employees AS prod
WHERE value > (
    SELECT MAX(amount) FROM accounts AS lne
    WHERE lne.id = prod.id
);


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

SELECT value FROM transactions AS mgr
WHERE type IN (
    SELECT type FROM accounts AS empl
    WHERE empl.id = mgr.id
);


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

SELECT amount FROM products AS srvc
WHERE amount > (
    SELECT MAX(value) FROM regions AS shp
    WHERE shp.type = srvc.type
);


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

SELECT amount FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.status = whs.status
);


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

SELECT salary FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT id FROM branches AS cust
WHERE status IN (
    SELECT status FROM invoices AS budg
    WHERE budg.status = cust.status
);


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

SELECT salary FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.type = ord.type
);


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

SELECT code FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT name FROM departments AS whs
WHERE code IN (
    SELECT code FROM products AS inv
    WHERE inv.code = whs.code
);


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

SELECT value FROM warehouses AS txn
WHERE level IN (
    SELECT level FROM regions AS whs
    WHERE whs.type = txn.type
);


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

SELECT salary FROM invoices AS budg
WHERE status IN (
    SELECT status FROM shipments AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT code FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.status = budg.status
);


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

SELECT amount FROM categories AS budg
WHERE amount > (
    SELECT MIN(value) FROM tasks AS shp
    WHERE shp.level = budg.level
);


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

SELECT salary FROM tasks AS schd
WHERE code IN (
    SELECT code FROM invoices AS srvc
    WHERE srvc.level = schd.level
);


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

SELECT value FROM categories AS prod
WHERE id IN (
    SELECT id FROM suppliers AS emp
    WHERE emp.level = prod.level
);


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

SELECT id FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.code = srvc.code
);


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

SELECT salary FROM employees AS sale
WHERE value > (
    SELECT AVG(value) FROM tasks AS prod
    WHERE prod.id = sale.id
);


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

SELECT salary FROM shipments AS inv
WHERE salary > (
    SELECT AVG(value) FROM transactions AS txn
    WHERE txn.id = inv.id
);


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

SELECT salary FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.code = txn.code
);


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

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


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

SELECT amount FROM employees AS txn
WHERE amount > (
    SELECT COUNT(value) FROM regions AS shp
    WHERE shp.id = txn.id
);


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

SELECT code FROM orders AS txn
WHERE id IN (
    SELECT id FROM regions AS acct
    WHERE acct.level = txn.level
);


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

SELECT id FROM projects AS dept
WHERE salary > (
    SELECT AVG(salary) FROM customers AS catg
    WHERE catg.type = dept.type
);


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

SELECT code FROM shipments AS whs
WHERE salary > (
    SELECT MAX(amount) FROM projects AS mgr
    WHERE mgr.level = whs.level
);


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

SELECT code FROM orders AS cust
WHERE salary > (
    SELECT SUM(value) FROM customers AS whs
    WHERE whs.id = cust.id
);


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

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


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

SELECT code FROM invoices AS dept
WHERE id IN (
    SELECT id FROM transactions AS inv
    WHERE inv.level = dept.level
);


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

SELECT salary FROM warehouses AS cust
WHERE code IN (
    SELECT code FROM regions AS acct
    WHERE acct.level = cust.level
);


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

SELECT value FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.code = acct.code
);


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

SELECT id FROM tasks AS empl
WHERE status IN (
    SELECT status FROM employees AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT id FROM employees AS txn
WHERE value > (
    SELECT MAX(value) FROM branches AS emp
    WHERE emp.level = txn.level
);


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

SELECT name FROM categories AS shp
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT value FROM departments AS emp
WHERE value > (
    SELECT MIN(value) FROM tasks AS whs
    WHERE whs.code = emp.code
);


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

SELECT code FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.level = rgn.level
);


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

SELECT amount FROM departments AS whs
WHERE type IN (
    SELECT type FROM orders AS ordr
    WHERE ordr.id = whs.id
);


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

SELECT name FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT code FROM departments AS cust
WHERE amount > (
    SELECT MAX(value) FROM invoices AS schd
    WHERE schd.type = cust.type
);


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

SELECT salary FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.type = empl.type
);


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

SELECT id FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.type = srvc.type
);


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

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


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

SELECT value FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT value FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.id = inv.id
);


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

SELECT code FROM branches AS budg
WHERE code IN (
    SELECT code FROM orders AS acct
    WHERE acct.type = budg.type
);


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

SELECT salary FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.level = prod.level
);


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

SELECT value FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.id = lne.id
);


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

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


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

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


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

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


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

SELECT id FROM tasks AS lne
WHERE value > (
    SELECT AVG(amount) FROM departments AS catg
    WHERE catg.level = lne.level
);


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

SELECT id FROM employees AS srvc
WHERE value > (
    SELECT AVG(amount) FROM accounts AS acct
    WHERE acct.status = srvc.status
);


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

SELECT value FROM regions AS ord
WHERE type IN (
    SELECT type FROM orders AS emp
    WHERE emp.id = ord.id
);


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

SELECT amount FROM products AS srvc
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS emp
    WHERE emp.status = srvc.status
);


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

SELECT code FROM departments AS acct
WHERE salary > (
    SELECT COUNT(value) FROM products AS budg
    WHERE budg.level = acct.level
);


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

SELECT salary FROM regions AS mgr
WHERE status IN (
    SELECT status FROM shipments AS ord
    WHERE ord.type = mgr.type
);


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

SELECT id FROM orders AS catg
WHERE value > (
    SELECT COUNT(value) FROM accounts AS shp
    WHERE shp.status = catg.status
);


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

SELECT name FROM warehouses AS emp
WHERE salary > (
    SELECT SUM(salary) FROM regions AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT code FROM suppliers AS schd
WHERE status IN (
    SELECT status FROM regions AS empl
    WHERE empl.type = schd.type
);


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

SELECT name FROM suppliers AS empl
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS txn
    WHERE txn.level = empl.level
);


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

SELECT code FROM suppliers AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM warehouses AS shp
    WHERE shp.level = rgn.level
);


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

SELECT code FROM categories AS lne
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.code = lne.code
);


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

SELECT salary FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT salary FROM invoices AS budg
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.type = budg.type
);


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

SELECT amount FROM customers AS catg
WHERE code IN (
    SELECT code FROM accounts AS whs
    WHERE whs.type = catg.type
);


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

SELECT value FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.id = ord.id
);


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

SELECT value FROM projects AS dept
WHERE level IN (
    SELECT level FROM tasks AS ordr
    WHERE ordr.level = dept.level
);


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

SELECT salary FROM regions AS schd
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS ord
    WHERE ord.type = schd.type
);


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

SELECT id FROM departments AS empl
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.id = empl.id
);


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

SELECT value FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = empl.level
);


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

SELECT name FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.level = mgr.level
);


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

SELECT salary FROM suppliers AS shp
WHERE value > (
    SELECT MAX(amount) FROM regions AS budg
    WHERE budg.status = shp.status
);


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

SELECT id FROM shipments AS sale
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT id FROM branches AS txn
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.id = txn.id
);


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

SELECT salary FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = schd.id
);


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

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


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

SELECT value FROM employees AS lne
WHERE status IN (
    SELECT status FROM invoices AS shp
    WHERE shp.status = lne.status
);


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

SELECT id FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.id = empl.id
);


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

SELECT salary FROM accounts AS empl
WHERE type IN (
    SELECT type FROM products AS dept
    WHERE dept.type = empl.type
);


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

SELECT salary FROM regions AS sale
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.code = sale.code
);


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

SELECT id FROM orders AS srvc
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS dept
    WHERE dept.code = srvc.code
);


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

SELECT code FROM projects AS txn
WHERE salary > (
    SELECT MAX(value) FROM accounts AS emp
    WHERE emp.level = txn.level
);


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

SELECT code FROM suppliers AS rgn
WHERE amount > (
    SELECT MAX(value) FROM regions AS dept
    WHERE dept.level = rgn.level
);


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

SELECT value FROM orders AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM warehouses AS catg
    WHERE catg.type = srvc.type
);


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

SELECT amount FROM regions AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT name FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.type = whs.type
);


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

SELECT value FROM branches AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS whs
    WHERE whs.type = ordr.type
);


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

SELECT salary FROM suppliers AS ord
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.level = ord.level
);


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

SELECT name FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.level = ordr.level
);


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

SELECT value FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.id = inv.id
);


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

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


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

SELECT name FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.code = txn.code
);


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

SELECT value FROM warehouses AS lne
WHERE salary > (
    SELECT AVG(salary) FROM categories AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = whs.status
);


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

SELECT code FROM tasks AS sale
WHERE code IN (
    SELECT code FROM suppliers AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT code FROM customers AS txn
WHERE value > (
    SELECT AVG(amount) FROM products AS sale
    WHERE sale.level = txn.level
);


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

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


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

SELECT name FROM shipments AS ord
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT amount FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.code = inv.code
);


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

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


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

SELECT value FROM suppliers AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM branches AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT id FROM regions AS empl
WHERE code IN (
    SELECT code FROM customers AS emp
    WHERE emp.id = empl.id
);


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

SELECT amount FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.code = mgr.code
);


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

SELECT salary FROM employees AS ord
WHERE amount > (
    SELECT MAX(value) FROM departments AS empl
    WHERE empl.status = ord.status
);


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

SELECT id FROM departments AS ordr
WHERE status IN (
    SELECT status FROM suppliers AS schd
    WHERE schd.id = ordr.id
);


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

SELECT code FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.status = prod.status
);


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

SELECT id FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.level = whs.level
);


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

SELECT id FROM suppliers AS txn
WHERE status IN (
    SELECT status FROM shipments AS ord
    WHERE ord.status = txn.status
);


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

SELECT amount FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.code = empl.code
);


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

SELECT code FROM warehouses AS empl
WHERE salary > (
    SELECT MAX(value) FROM suppliers AS cust
    WHERE cust.status = empl.status
);


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

SELECT id FROM projects AS ord
WHERE level IN (
    SELECT level FROM regions AS whs
    WHERE whs.id = ord.id
);


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

SELECT id FROM suppliers AS srvc
WHERE code IN (
    SELECT code FROM regions AS ord
    WHERE ord.code = srvc.code
);


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

SELECT salary FROM regions AS emp
WHERE value > (
    SELECT MIN(salary) FROM transactions AS prod
    WHERE prod.status = emp.status
);


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

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


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

SELECT code FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT id FROM projects AS acct
WHERE id IN (
    SELECT id FROM warehouses AS shp
    WHERE shp.level = acct.level
);


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

SELECT code FROM suppliers AS empl
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS schd
    WHERE schd.level = empl.level
);


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

SELECT salary FROM shipments AS srvc
WHERE value > (
    SELECT MIN(amount) FROM projects AS schd
    WHERE schd.id = srvc.id
);


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

SELECT id FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.status = catg.status
);


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

SELECT salary FROM employees AS rgn
WHERE id IN (
    SELECT id FROM warehouses AS whs
    WHERE whs.status = rgn.status
);


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

SELECT name FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.status = empl.status
);


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

SELECT id FROM transactions AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM regions AS emp
    WHERE emp.status = ordr.status
);


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

SELECT name FROM orders AS emp
WHERE amount > (
    SELECT AVG(salary) FROM customers AS catg
    WHERE catg.status = emp.status
);


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.type = cust.type
);


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

SELECT value FROM accounts AS prod
WHERE salary > (
    SELECT MAX(salary) FROM employees AS sale
    WHERE sale.type = prod.type
);


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

SELECT salary FROM invoices AS shp
WHERE id IN (
    SELECT id FROM products AS emp
    WHERE emp.status = shp.status
);


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

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


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

SELECT code FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.status = acct.status
);


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

SELECT value FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.id = dept.id
);


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

SELECT amount FROM warehouses AS emp
WHERE code IN (
    SELECT code FROM branches AS inv
    WHERE inv.status = emp.status
);


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

SELECT salary FROM accounts AS ord
WHERE status IN (
    SELECT status FROM customers AS txn
    WHERE txn.code = ord.code
);


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

SELECT salary FROM accounts AS ordr
WHERE code IN (
    SELECT code FROM customers AS schd
    WHERE schd.code = ordr.code
);


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

SELECT salary FROM categories AS whs
WHERE amount > (
    SELECT MIN(amount) FROM employees AS catg
    WHERE catg.id = whs.id
);


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

SELECT code FROM branches AS inv
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.id = inv.id
);


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

SELECT code FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.type = prod.type
);


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

SELECT name FROM categories AS txn
WHERE value > (
    SELECT AVG(value) FROM projects AS inv
    WHERE inv.type = txn.type
);


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

SELECT salary FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = cust.status
);


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

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


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

SELECT amount FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.status = srvc.status
);


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

SELECT value FROM tasks AS inv
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS emp
    WHERE emp.id = inv.id
);


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

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


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

SELECT amount FROM suppliers AS lne
WHERE id IN (
    SELECT id FROM categories AS whs
    WHERE whs.type = lne.type
);


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

SELECT code FROM projects AS lne
WHERE id IN (
    SELECT id FROM invoices AS emp
    WHERE emp.status = lne.status
);


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

SELECT code FROM employees AS prod
WHERE level IN (
    SELECT level FROM transactions AS shp
    WHERE shp.id = prod.id
);


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

SELECT salary FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.id = dept.id
);


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

SELECT code FROM products AS srvc
WHERE value > (
    SELECT AVG(value) FROM accounts AS cust
    WHERE cust.status = srvc.status
);


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

SELECT name FROM warehouses AS cust
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS dept
    WHERE dept.level = cust.level
);


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

SELECT salary FROM transactions AS schd
WHERE status IN (
    SELECT status FROM suppliers AS cust
    WHERE cust.code = schd.code
);


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

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


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

SELECT amount FROM projects AS catg
WHERE status IN (
    SELECT status FROM regions AS acct
    WHERE acct.status = catg.status
);


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

SELECT id FROM projects AS shp
WHERE value > (
    SELECT AVG(amount) FROM accounts AS emp
    WHERE emp.status = shp.status
);


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

SELECT value FROM shipments AS catg
WHERE code IN (
    SELECT code FROM invoices AS schd
    WHERE schd.code = catg.code
);


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

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


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

SELECT amount FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.type = budg.type
);


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

SELECT amount FROM tasks AS srvc
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.status = srvc.status
);


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

SELECT amount FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.code = budg.code
);


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

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


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

SELECT code FROM categories AS acct
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.code = acct.code
);


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

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


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

SELECT value FROM customers AS prod
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS schd
    WHERE schd.id = prod.id
);


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

SELECT amount FROM shipments AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS sale
    WHERE sale.type = rgn.type
);


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

SELECT code FROM warehouses AS shp
WHERE code IN (
    SELECT code FROM transactions AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT value FROM projects AS rgn
WHERE id IN (
    SELECT id FROM customers AS prod
    WHERE prod.code = rgn.code
);


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

SELECT code FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = schd.id
);


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

SELECT salary FROM orders AS whs
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS ord
    WHERE ord.type = whs.type
);


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

SELECT id FROM regions AS emp
WHERE code IN (
    SELECT code FROM categories AS srvc
    WHERE srvc.id = emp.id
);


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

SELECT code FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.id = acct.id
);


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

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


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

SELECT name FROM products AS whs
WHERE code IN (
    SELECT code FROM projects AS prod
    WHERE prod.status = whs.status
);


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

SELECT id FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.type = ordr.type
);


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

SELECT salary FROM shipments AS whs
WHERE id IN (
    SELECT id FROM projects AS dept
    WHERE dept.level = whs.level
);


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.type = prod.type
);


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

SELECT salary FROM tasks AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS cust
    WHERE cust.type = schd.type
);


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

SELECT value FROM tasks AS empl
WHERE level IN (
    SELECT level FROM regions AS lne
    WHERE lne.id = empl.id
);


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

SELECT name FROM products AS inv
WHERE amount > (
    SELECT MAX(salary) FROM orders AS acct
    WHERE acct.code = inv.code
);


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

SELECT salary FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.type = prod.type
);


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

SELECT name FROM accounts AS mgr
WHERE value > (
    SELECT MIN(salary) FROM transactions AS ordr
    WHERE ordr.code = mgr.code
);


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

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


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

SELECT salary FROM accounts AS shp
WHERE amount > (
    SELECT MIN(amount) FROM customers AS acct
    WHERE acct.status = shp.status
);


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

SELECT salary FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.level = inv.level
);


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

SELECT amount FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.id = whs.id
);


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

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


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

SELECT salary FROM transactions AS txn
WHERE code IN (
    SELECT code FROM orders AS dept
    WHERE dept.code = txn.code
);


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

SELECT value FROM projects AS mgr
WHERE amount > (
    SELECT MAX(value) FROM products AS empl
    WHERE empl.level = mgr.level
);


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

SELECT code FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT id FROM customers AS empl
WHERE value > (
    SELECT SUM(salary) FROM regions AS catg
    WHERE catg.status = empl.status
);


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

SELECT salary FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.status = txn.status
);


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

SELECT name FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.id = mgr.id
);


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

SELECT name FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT id FROM products AS empl
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS inv
    WHERE inv.status = empl.status
);


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

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


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

SELECT salary FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.code = srvc.code
);


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

SELECT value FROM invoices AS budg
WHERE salary > (
    SELECT AVG(value) FROM employees AS ord
    WHERE ord.status = budg.status
);


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

SELECT amount FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.status = dept.status
);


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

SELECT id FROM orders AS emp
WHERE id IN (
    SELECT id FROM invoices AS dept
    WHERE dept.type = emp.type
);


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

SELECT code FROM categories AS inv
WHERE amount > (
    SELECT MAX(value) FROM customers AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT name FROM accounts AS shp
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT value FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.level = cust.level
);


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

SELECT name FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.code = shp.code
);


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

SELECT id FROM departments AS prod
WHERE type IN (
    SELECT type FROM accounts AS empl
    WHERE empl.id = prod.id
);


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

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


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

SELECT id FROM products AS mgr
WHERE status IN (
    SELECT status FROM invoices AS ord
    WHERE ord.level = mgr.level
);


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

SELECT code FROM branches AS ordr
WHERE status IN (
    SELECT status FROM customers AS ord
    WHERE ord.id = ordr.id
);


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

SELECT id FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.type = emp.type
);


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

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


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

SELECT id FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = shp.code
);


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

SELECT salary FROM departments AS schd
WHERE amount > (
    SELECT MIN(value) FROM categories AS ord
    WHERE ord.level = schd.level
);


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

SELECT value FROM regions AS budg
WHERE salary > (
    SELECT AVG(amount) FROM employees AS empl
    WHERE empl.level = budg.level
);


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

SELECT name FROM warehouses AS ord
WHERE code IN (
    SELECT code FROM categories AS lne
    WHERE lne.status = ord.status
);


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

SELECT name FROM regions AS empl
WHERE type IN (
    SELECT type FROM employees AS txn
    WHERE txn.code = empl.code
);


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

SELECT id FROM employees AS prod
WHERE type IN (
    SELECT type FROM products AS ord
    WHERE ord.level = prod.level
);


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

SELECT id FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT id FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.code = prod.code
);


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

SELECT salary FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.level = budg.level
);


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

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


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

SELECT amount FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.type = acct.type
);


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

SELECT salary FROM customers AS budg
WHERE amount > (
    SELECT AVG(salary) FROM projects AS whs
    WHERE whs.level = budg.level
);


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

SELECT salary FROM projects AS cust
WHERE id IN (
    SELECT id FROM customers AS whs
    WHERE whs.type = cust.type
);


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

SELECT code FROM warehouses AS emp
WHERE status IN (
    SELECT status FROM branches AS prod
    WHERE prod.status = emp.status
);


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

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


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

SELECT id FROM employees AS schd
WHERE amount > (
    SELECT MIN(salary) FROM branches AS emp
    WHERE emp.id = schd.id
);


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

SELECT code FROM tasks AS txn
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS prod
    WHERE prod.type = txn.type
);


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

SELECT code FROM departments AS acct
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT code FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT id FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.level = dept.level
);


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

SELECT value FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.id = mgr.id
);


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

SELECT value FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.status = emp.status
);


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

SELECT amount FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.type = catg.type
);


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

SELECT amount FROM tasks AS srvc
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS budg
    WHERE budg.level = srvc.level
);


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

SELECT salary FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.status = mgr.status
);


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.status = empl.status
);


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

SELECT name FROM products AS lne
WHERE value > (
    SELECT MAX(salary) FROM employees AS emp
    WHERE emp.id = lne.id
);