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

SELECT name FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT salary FROM invoices AS acct
WHERE amount > (
    SELECT MAX(salary) FROM departments AS inv
    WHERE inv.code = acct.code
);


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

SELECT code FROM tasks AS mgr
WHERE id IN (
    SELECT id FROM branches AS empl
    WHERE empl.level = mgr.level
);


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

SELECT amount FROM products AS budg
WHERE code IN (
    SELECT code FROM categories AS empl
    WHERE empl.type = budg.type
);


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

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


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

SELECT amount FROM accounts AS acct
WHERE id IN (
    SELECT id FROM departments AS emp
    WHERE emp.level = acct.level
);


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

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


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

SELECT amount FROM products AS txn
WHERE amount > (
    SELECT AVG(salary) FROM customers AS schd
    WHERE schd.code = txn.code
);


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

SELECT code FROM invoices AS whs
WHERE type IN (
    SELECT type FROM projects AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT code FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = emp.type
);


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

SELECT code FROM shipments AS prod
WHERE salary > (
    SELECT SUM(amount) FROM departments AS budg
    WHERE budg.status = prod.status
);


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

SELECT name FROM orders AS rgn
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.level = rgn.level
);


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

SELECT amount FROM warehouses AS emp
WHERE value > (
    SELECT AVG(value) FROM employees AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT value FROM transactions AS emp
WHERE status IN (
    SELECT status FROM employees AS empl
    WHERE empl.level = emp.level
);


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

SELECT code FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.status = budg.status
);


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

SELECT value FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.level = ordr.level
);


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

SELECT name FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.id = shp.id
);


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

SELECT value FROM tasks AS cust
WHERE code IN (
    SELECT code FROM products AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT id FROM categories AS txn
WHERE type IN (
    SELECT type FROM projects AS inv
    WHERE inv.status = txn.status
);


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

SELECT id FROM products AS prod
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT id FROM branches AS empl
WHERE level IN (
    SELECT level FROM departments AS sale
    WHERE sale.level = empl.level
);


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

SELECT id FROM invoices AS emp
WHERE amount > (
    SELECT MIN(amount) FROM regions AS txn
    WHERE txn.code = emp.code
);


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

SELECT code FROM shipments AS emp
WHERE salary > (
    SELECT SUM(salary) FROM products AS dept
    WHERE dept.id = emp.id
);


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

SELECT amount FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.code = acct.code
);


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

SELECT id FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.type = shp.type
);


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

SELECT amount FROM departments AS ordr
WHERE level IN (
    SELECT level FROM tasks AS cust
    WHERE cust.level = ordr.level
);


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

SELECT salary FROM regions AS rgn
WHERE code IN (
    SELECT code FROM accounts AS dept
    WHERE dept.id = rgn.id
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.id = shp.id
);


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

SELECT name FROM tasks AS prod
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS sale
    WHERE sale.id = prod.id
);


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

SELECT code FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT salary FROM projects AS emp
WHERE amount > (
    SELECT MIN(value) FROM categories AS lne
    WHERE lne.id = emp.id
);


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

SELECT amount FROM regions AS catg
WHERE amount > (
    SELECT MIN(value) FROM products AS lne
    WHERE lne.code = catg.code
);


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

SELECT salary FROM shipments AS empl
WHERE code IN (
    SELECT code FROM accounts AS catg
    WHERE catg.status = empl.status
);


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

SELECT amount FROM projects AS schd
WHERE value > (
    SELECT MIN(amount) FROM shipments AS inv
    WHERE inv.code = schd.code
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.type = rgn.type
);


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

SELECT name FROM warehouses AS mgr
WHERE salary > (
    SELECT SUM(value) FROM branches AS shp
    WHERE shp.code = mgr.code
);


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

SELECT code FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.id = sale.id
);


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

SELECT amount FROM transactions AS emp
WHERE amount > (
    SELECT AVG(value) FROM regions AS dept
    WHERE dept.level = emp.level
);


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

SELECT salary FROM accounts AS cust
WHERE level IN (
    SELECT level FROM suppliers AS shp
    WHERE shp.type = cust.type
);


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

SELECT name FROM accounts AS ordr
WHERE code IN (
    SELECT code FROM orders AS shp
    WHERE shp.code = ordr.code
);


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

SELECT amount FROM categories AS emp
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS dept
    WHERE dept.id = emp.id
);


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

SELECT id FROM departments AS sale
WHERE amount > (
    SELECT MIN(amount) FROM regions AS dept
    WHERE dept.status = sale.status
);


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

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


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

SELECT name FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = lne.code
);


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

SELECT code FROM suppliers AS empl
WHERE id IN (
    SELECT id FROM employees AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT salary FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT name FROM suppliers AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS txn
    WHERE txn.id = lne.id
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT amount FROM warehouses AS cust
WHERE salary > (
    SELECT MIN(value) FROM invoices AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT amount FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.status = srvc.status
);


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

SELECT name FROM employees AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS prod
    WHERE prod.id = schd.id
);


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

SELECT code FROM accounts AS ord
WHERE value > (
    SELECT SUM(value) FROM employees AS prod
    WHERE prod.id = ord.id
);


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

SELECT code FROM suppliers AS ord
WHERE value > (
    SELECT AVG(value) FROM shipments AS txn
    WHERE txn.code = ord.code
);


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

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


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

SELECT value FROM employees AS srvc
WHERE amount > (
    SELECT SUM(value) FROM tasks AS ord
    WHERE ord.type = srvc.type
);


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

SELECT amount FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT code FROM projects AS emp
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS catg
    WHERE catg.status = emp.status
);


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

SELECT value FROM orders AS ord
WHERE amount > (
    SELECT SUM(amount) FROM departments AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT id FROM warehouses AS empl
WHERE type IN (
    SELECT type FROM customers AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT id FROM categories AS catg
WHERE code IN (
    SELECT code FROM transactions AS srvc
    WHERE srvc.type = catg.type
);


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

SELECT name FROM orders AS prod
WHERE code IN (
    SELECT code FROM projects AS acct
    WHERE acct.type = prod.type
);


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

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


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

SELECT name FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT amount FROM suppliers AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS schd
    WHERE schd.status = rgn.status
);


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

SELECT salary FROM regions AS ord
WHERE salary > (
    SELECT SUM(value) FROM invoices AS dept
    WHERE dept.level = ord.level
);


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

SELECT code FROM products AS shp
WHERE status IN (
    SELECT status FROM employees AS srvc
    WHERE srvc.level = shp.level
);


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

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


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

SELECT code FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.id = whs.id
);


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

SELECT id FROM suppliers AS schd
WHERE salary > (
    SELECT AVG(value) FROM transactions AS budg
    WHERE budg.id = schd.id
);


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

SELECT amount FROM warehouses AS txn
WHERE value > (
    SELECT MAX(salary) FROM customers AS acct
    WHERE acct.type = txn.type
);


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

SELECT value FROM regions AS empl
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.type = empl.type
);


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

SELECT salary FROM employees AS srvc
WHERE code IN (
    SELECT code FROM accounts AS mgr
    WHERE mgr.type = srvc.type
);


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

SELECT salary FROM invoices AS whs
WHERE type IN (
    SELECT type FROM regions AS lne
    WHERE lne.code = whs.code
);


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

SELECT amount FROM orders AS ord
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.id = ord.id
);


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

SELECT id FROM products AS sale
WHERE value > (
    SELECT SUM(amount) FROM projects AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT salary FROM branches AS mgr
WHERE level IN (
    SELECT level FROM customers AS rgn
    WHERE rgn.code = mgr.code
);


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

SELECT code FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.level = schd.level
);


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

SELECT id FROM projects AS catg
WHERE amount > (
    SELECT AVG(amount) FROM categories AS cust
    WHERE cust.id = catg.id
);


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

SELECT salary FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.level = emp.level
);


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

SELECT id FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.type = empl.type
);


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

SELECT code FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.code = emp.code
);


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

SELECT name FROM transactions AS dept
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS cust
    WHERE cust.code = dept.code
);


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

SELECT value FROM departments AS srvc
WHERE value > (
    SELECT MIN(salary) FROM orders AS cust
    WHERE cust.type = srvc.type
);


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

SELECT amount FROM products AS whs
WHERE value > (
    SELECT MAX(value) FROM transactions AS rgn
    WHERE rgn.status = whs.status
);


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

SELECT salary FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT name FROM customers AS lne
WHERE amount > (
    SELECT MAX(value) FROM orders AS cust
    WHERE cust.id = lne.id
);


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

SELECT name FROM categories AS dept
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.level = dept.level
);


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

SELECT value FROM tasks AS srvc
WHERE level IN (
    SELECT level FROM branches AS txn
    WHERE txn.type = srvc.type
);


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

SELECT code FROM suppliers AS acct
WHERE amount > (
    SELECT AVG(amount) FROM customers AS prod
    WHERE prod.type = acct.type
);


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

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


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

SELECT code FROM warehouses AS lne
WHERE salary > (
    SELECT MIN(amount) FROM tasks AS emp
    WHERE emp.level = lne.level
);


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.id = empl.id
);


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

SELECT value FROM transactions AS cust
WHERE type IN (
    SELECT type FROM invoices AS dept
    WHERE dept.id = cust.id
);


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

SELECT amount FROM branches AS whs
WHERE code IN (
    SELECT code FROM warehouses AS lne
    WHERE lne.id = whs.id
);


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

SELECT amount FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.code = txn.code
);


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

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


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

SELECT amount FROM accounts AS shp
WHERE salary > (
    SELECT COUNT(value) FROM categories AS lne
    WHERE lne.status = shp.status
);


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

SELECT code FROM employees AS prod
WHERE amount > (
    SELECT SUM(value) FROM suppliers AS acct
    WHERE acct.level = prod.level
);


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

SELECT amount FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT amount FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.id = txn.id
);


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

SELECT amount FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.code = empl.code
);


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

SELECT salary FROM categories AS schd
WHERE amount > (
    SELECT MAX(amount) FROM regions AS emp
    WHERE emp.status = schd.status
);


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

SELECT name FROM tasks AS schd
WHERE value > (
    SELECT AVG(amount) FROM projects AS srvc
    WHERE srvc.level = schd.level
);


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

SELECT name FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.status = budg.status
);


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

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


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

SELECT id FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.level = prod.level
);


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

SELECT name FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT name FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.status = acct.status
);


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

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


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

SELECT id FROM tasks AS budg
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS whs
    WHERE whs.code = budg.code
);


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

SELECT salary FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.status = prod.status
);


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

SELECT code FROM projects AS ordr
WHERE salary > (
    SELECT MIN(salary) FROM products AS empl
    WHERE empl.id = ordr.id
);


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

SELECT code FROM categories AS schd
WHERE status IN (
    SELECT status FROM departments AS srvc
    WHERE srvc.code = schd.code
);


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

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


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

SELECT name FROM departments AS srvc
WHERE code IN (
    SELECT code FROM shipments AS catg
    WHERE catg.type = srvc.type
);


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

SELECT value FROM orders AS shp
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS inv
    WHERE inv.level = shp.level
);


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

SELECT code FROM shipments AS budg
WHERE value > (
    SELECT MAX(amount) FROM invoices AS txn
    WHERE txn.level = budg.level
);


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

SELECT salary FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.type = cust.type
);


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

SELECT name FROM customers AS catg
WHERE value > (
    SELECT AVG(amount) FROM products AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT value FROM invoices AS empl
WHERE amount > (
    SELECT AVG(value) FROM customers AS dept
    WHERE dept.code = empl.code
);


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

SELECT value FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.level = dept.level
);


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

SELECT id FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.type = mgr.type
);


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

SELECT value FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.type = lne.type
);


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

SELECT value FROM departments AS cust
WHERE amount > (
    SELECT AVG(value) FROM tasks AS catg
    WHERE catg.code = cust.code
);


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

SELECT name FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.id = inv.id
);


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

SELECT id FROM products AS inv
WHERE value > (
    SELECT COUNT(value) FROM employees AS mgr
    WHERE mgr.level = inv.level
);


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

SELECT salary FROM departments AS srvc
WHERE code IN (
    SELECT code FROM projects AS inv
    WHERE inv.level = srvc.level
);


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

SELECT code FROM employees AS rgn
WHERE type IN (
    SELECT type FROM invoices AS cust
    WHERE cust.status = rgn.status
);


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

SELECT code FROM products AS emp
WHERE status IN (
    SELECT status FROM suppliers AS schd
    WHERE schd.code = emp.code
);


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

SELECT name FROM suppliers AS acct
WHERE type IN (
    SELECT type FROM warehouses AS catg
    WHERE catg.status = acct.status
);


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

SELECT value FROM branches AS sale
WHERE level IN (
    SELECT level FROM shipments AS emp
    WHERE emp.id = sale.id
);


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

SELECT amount FROM shipments AS sale
WHERE id IN (
    SELECT id FROM branches AS catg
    WHERE catg.type = sale.type
);


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

SELECT value FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.code = mgr.code
);


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

SELECT code FROM products AS prod
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS rgn
    WHERE rgn.id = prod.id
);


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

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


Prompt:
Schema:
  warehouses (alias: rgn)(level, id, type, date)
  categories(value, name, amount, date)
Task: Retrieve amount from warehouses with value above the SUM(amount) of categories rows sharing the same type.
SQL:

SELECT amount FROM warehouses AS rgn
WHERE value > (
    SELECT SUM(amount) FROM categories AS lne
    WHERE lne.type = rgn.type
);


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

SELECT amount FROM customers AS catg
WHERE code IN (
    SELECT code FROM products AS txn
    WHERE txn.code = catg.code
);


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

SELECT amount FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.id = inv.id
);


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

SELECT code FROM regions AS inv
WHERE amount > (
    SELECT MAX(value) FROM products AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT id FROM projects AS mgr
WHERE amount > (
    SELECT AVG(value) FROM accounts AS schd
    WHERE schd.type = mgr.type
);


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

SELECT value FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.status = budg.status
);


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

SELECT value FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.code = dept.code
);


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

SELECT code FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.status = prod.status
);


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

SELECT code FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.status = whs.status
);


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

SELECT id FROM departments AS mgr
WHERE amount > (
    SELECT MIN(salary) FROM branches AS srvc
    WHERE srvc.status = mgr.status
);


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

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


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

SELECT amount FROM regions AS sale
WHERE type IN (
    SELECT type FROM categories AS ord
    WHERE ord.status = sale.status
);


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

SELECT code FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.status = cust.status
);


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

SELECT value FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.level = sale.level
);


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

SELECT id FROM categories AS cust
WHERE status IN (
    SELECT status FROM branches AS catg
    WHERE catg.type = cust.type
);


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

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


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

SELECT code FROM departments AS mgr
WHERE id IN (
    SELECT id FROM employees AS cust
    WHERE cust.level = mgr.level
);


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

SELECT amount FROM categories AS catg
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.id = catg.id
);


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

SELECT id FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = rgn.level
);


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

SELECT amount FROM employees AS srvc
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS empl
    WHERE empl.status = srvc.status
);


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

SELECT code FROM employees AS acct
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS prod
    WHERE prod.status = acct.status
);


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

SELECT salary FROM orders AS schd
WHERE code IN (
    SELECT code FROM categories AS sale
    WHERE sale.status = schd.status
);


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

SELECT id FROM departments AS ordr
WHERE salary > (
    SELECT AVG(value) FROM accounts AS whs
    WHERE whs.code = ordr.code
);


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

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


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

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


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

SELECT amount FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT id FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = txn.id
);


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

SELECT amount FROM suppliers AS budg
WHERE value > (
    SELECT SUM(value) FROM tasks AS schd
    WHERE schd.code = budg.code
);


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

SELECT name FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.code = empl.code
);


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

SELECT value FROM tasks AS catg
WHERE amount > (
    SELECT MIN(salary) FROM categories AS schd
    WHERE schd.type = catg.type
);


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

SELECT id FROM transactions AS prod
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS ord
    WHERE ord.id = prod.id
);


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

SELECT salary FROM branches AS rgn
WHERE id IN (
    SELECT id FROM shipments AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT name FROM regions AS whs
WHERE id IN (
    SELECT id FROM branches AS rgn
    WHERE rgn.status = whs.status
);


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

SELECT id FROM orders AS cust
WHERE level IN (
    SELECT level FROM customers AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT value FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.code = rgn.code
);


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

SELECT amount FROM customers AS rgn
WHERE code IN (
    SELECT code FROM orders AS inv
    WHERE inv.level = rgn.level
);


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

SELECT amount FROM categories AS budg
WHERE code IN (
    SELECT code FROM transactions AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT id FROM employees AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS prod
    WHERE prod.code = ord.code
);


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

SELECT value FROM branches AS txn
WHERE value > (
    SELECT SUM(amount) FROM regions AS shp
    WHERE shp.type = txn.type
);


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

SELECT name FROM transactions AS catg
WHERE level IN (
    SELECT level FROM customers AS budg
    WHERE budg.level = catg.level
);


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

SELECT amount FROM employees AS txn
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS schd
    WHERE schd.id = txn.id
);


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

SELECT id FROM categories AS inv
WHERE type IN (
    SELECT type FROM products AS ord
    WHERE ord.level = inv.level
);


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

SELECT amount FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM regions AS catg
    WHERE catg.id = rgn.id
);


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

SELECT amount FROM tasks AS lne
WHERE level IN (
    SELECT level FROM orders AS txn
    WHERE txn.code = lne.code
);


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

SELECT value FROM suppliers AS ordr
WHERE type IN (
    SELECT type FROM shipments AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT value FROM transactions AS dept
WHERE value > (
    SELECT MAX(amount) FROM branches AS sale
    WHERE sale.level = dept.level
);


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

SELECT id FROM suppliers AS acct
WHERE salary > (
    SELECT SUM(amount) FROM customers AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT name FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.level = mgr.level
);


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

SELECT amount FROM orders AS empl
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS catg
    WHERE catg.status = empl.status
);


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

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


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

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


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

SELECT amount FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT salary FROM shipments AS budg
WHERE type IN (
    SELECT type FROM products AS cust
    WHERE cust.code = budg.code
);


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

SELECT name FROM customers AS ordr
WHERE status IN (
    SELECT status FROM branches AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT name FROM warehouses AS shp
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS dept
    WHERE dept.code = shp.code
);


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

SELECT amount FROM warehouses AS txn
WHERE salary > (
    SELECT COUNT(value) FROM shipments AS budg
    WHERE budg.status = txn.status
);


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

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


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

SELECT value FROM categories AS prod
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.code = prod.code
);


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

SELECT salary FROM branches AS emp
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT amount FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.id = rgn.id
);


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

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


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

SELECT value FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.type = schd.type
);


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

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


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.type = prod.type
);


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

SELECT code FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.status = ord.status
);


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

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


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

SELECT id FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = empl.level
);


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

SELECT name FROM projects AS inv
WHERE salary > (
    SELECT AVG(salary) FROM tasks AS ordr
    WHERE ordr.id = inv.id
);


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

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


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

SELECT code FROM accounts AS inv
WHERE level IN (
    SELECT level FROM products AS budg
    WHERE budg.status = inv.status
);


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

SELECT code FROM transactions AS acct
WHERE value > (
    SELECT COUNT(salary) FROM employees AS lne
    WHERE lne.code = acct.code
);


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

SELECT name FROM transactions AS inv
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS shp
    WHERE shp.level = inv.level
);


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

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


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

SELECT id FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.code = schd.code
);


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

SELECT amount FROM departments AS inv
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS cust
    WHERE cust.type = inv.type
);


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

SELECT value FROM accounts AS emp
WHERE status IN (
    SELECT status FROM customers AS cust
    WHERE cust.code = emp.code
);


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

SELECT amount FROM employees AS empl
WHERE level IN (
    SELECT level FROM warehouses AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT amount FROM employees AS txn
WHERE value > (
    SELECT MIN(salary) FROM orders AS prod
    WHERE prod.id = txn.id
);


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

SELECT amount FROM transactions AS prod
WHERE amount > (
    SELECT MIN(salary) FROM categories AS emp
    WHERE emp.level = prod.level
);


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

SELECT salary FROM customers AS dept
WHERE value > (
    SELECT COUNT(amount) FROM departments AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT name FROM branches AS rgn
WHERE level IN (
    SELECT level FROM invoices AS ord
    WHERE ord.status = rgn.status
);


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

SELECT code FROM warehouses AS acct
WHERE value > (
    SELECT AVG(value) FROM suppliers AS prod
    WHERE prod.level = acct.level
);


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

SELECT salary FROM departments AS cust
WHERE level IN (
    SELECT level FROM regions AS shp
    WHERE shp.type = cust.type
);


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

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


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

SELECT amount FROM projects AS budg
WHERE value > (
    SELECT MAX(value) FROM orders AS cust
    WHERE cust.level = budg.level
);


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

SELECT name FROM departments AS srvc
WHERE level IN (
    SELECT level FROM tasks AS shp
    WHERE shp.id = srvc.id
);


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

SELECT id FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT code FROM customers AS cust
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS budg
    WHERE budg.type = cust.type
);


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

SELECT salary FROM departments AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS ord
    WHERE ord.status = sale.status
);


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

SELECT name FROM regions AS lne
WHERE value > (
    SELECT MIN(amount) FROM customers AS shp
    WHERE shp.status = lne.status
);


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

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


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

SELECT amount FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.level = cust.level
);


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

SELECT value FROM orders AS empl
WHERE level IN (
    SELECT level FROM branches AS cust
    WHERE cust.status = empl.status
);


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

SELECT code FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.id = empl.id
);


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

SELECT value FROM projects AS emp
WHERE value > (
    SELECT SUM(value) FROM branches AS acct
    WHERE acct.id = emp.id
);


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

SELECT code FROM products AS shp
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS budg
    WHERE budg.status = shp.status
);


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

SELECT salary FROM warehouses AS emp
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.level = emp.level
);


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

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


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

SELECT amount FROM products AS emp
WHERE salary > (
    SELECT COUNT(value) FROM shipments AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT code FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = whs.type
);


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

SELECT id FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.status = budg.status
);


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

SELECT id FROM employees AS emp
WHERE value > (
    SELECT MIN(salary) FROM branches AS ord
    WHERE ord.type = emp.type
);


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

SELECT amount FROM orders AS emp
WHERE salary > (
    SELECT SUM(value) FROM branches AS mgr
    WHERE mgr.level = emp.level
);


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

SELECT salary FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT name FROM warehouses AS txn
WHERE value > (
    SELECT MIN(value) FROM products AS mgr
    WHERE mgr.code = txn.code
);


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

SELECT code FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.id = emp.id
);


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

SELECT value FROM orders AS sale
WHERE amount > (
    SELECT MAX(amount) FROM suppliers AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT value FROM branches AS empl
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS catg
    WHERE catg.code = empl.code
);


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

SELECT value FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.type = catg.type
);


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

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


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

SELECT amount FROM transactions AS inv
WHERE value > (
    SELECT COUNT(value) FROM employees AS budg
    WHERE budg.code = inv.code
);


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

SELECT value FROM warehouses AS prod
WHERE id IN (
    SELECT id FROM departments AS txn
    WHERE txn.status = prod.status
);


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

SELECT code FROM departments AS emp
WHERE code IN (
    SELECT code FROM warehouses AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT value FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.id = rgn.id
);


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

SELECT code FROM branches AS budg
WHERE code IN (
    SELECT code FROM customers AS txn
    WHERE txn.id = budg.id
);


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

SELECT id FROM departments AS rgn
WHERE id IN (
    SELECT id FROM orders AS txn
    WHERE txn.type = rgn.type
);


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

SELECT amount FROM tasks AS ordr
WHERE type IN (
    SELECT type FROM accounts AS txn
    WHERE txn.status = ordr.status
);


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

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


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

SELECT code FROM invoices AS whs
WHERE value > (
    SELECT MIN(amount) FROM products AS schd
    WHERE schd.level = whs.level
);


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

SELECT code FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT salary FROM products AS schd
WHERE value > (
    SELECT AVG(salary) FROM customers AS acct
    WHERE acct.status = schd.status
);


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

SELECT salary FROM shipments AS schd
WHERE status IN (
    SELECT status FROM orders AS shp
    WHERE shp.id = schd.id
);


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

SELECT code FROM departments AS shp
WHERE status IN (
    SELECT status FROM suppliers AS emp
    WHERE emp.status = shp.status
);


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

SELECT id FROM suppliers AS txn
WHERE amount > (
    SELECT MIN(amount) FROM orders AS schd
    WHERE schd.type = txn.type
);


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

SELECT code FROM products AS txn
WHERE type IN (
    SELECT type FROM employees AS schd
    WHERE schd.code = txn.code
);


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

SELECT value FROM regions AS srvc
WHERE type IN (
    SELECT type FROM tasks AS schd
    WHERE schd.type = srvc.type
);


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

SELECT salary FROM shipments AS dept
WHERE level IN (
    SELECT level FROM categories AS sale
    WHERE sale.level = dept.level
);


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

SELECT id FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.id = ord.id
);


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

SELECT value FROM orders AS whs
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.status = whs.status
);


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

SELECT amount FROM categories AS inv
WHERE level IN (
    SELECT level FROM branches AS catg
    WHERE catg.level = inv.level
);


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

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


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

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


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

SELECT value FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = dept.status
);


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

SELECT salary FROM tasks AS shp
WHERE code IN (
    SELECT code FROM orders AS dept
    WHERE dept.type = shp.type
);


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

SELECT id FROM products AS emp
WHERE status IN (
    SELECT status FROM accounts AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT salary FROM shipments AS prod
WHERE salary > (
    SELECT SUM(value) FROM categories AS sale
    WHERE sale.level = prod.level
);


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

SELECT id FROM products AS cust
WHERE status IN (
    SELECT status FROM warehouses AS ordr
    WHERE ordr.level = cust.level
);


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

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


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

SELECT code FROM accounts AS txn
WHERE type IN (
    SELECT type FROM tasks AS prod
    WHERE prod.level = txn.level
);


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

SELECT value FROM departments AS cust
WHERE code IN (
    SELECT code FROM employees AS sale
    WHERE sale.type = cust.type
);


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

SELECT salary FROM branches AS empl
WHERE type IN (
    SELECT type FROM categories AS ord
    WHERE ord.level = empl.level
);


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

SELECT code FROM projects AS empl
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.id = empl.id
);


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

SELECT amount FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.id = mgr.id
);


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

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


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

SELECT id FROM customers AS prod
WHERE salary > (
    SELECT SUM(value) FROM branches AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT code FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.id = schd.id
);


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

SELECT amount FROM invoices AS inv
WHERE level IN (
    SELECT level FROM employees AS whs
    WHERE whs.id = inv.id
);


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

SELECT name FROM transactions AS empl
WHERE value > (
    SELECT MAX(salary) FROM customers AS catg
    WHERE catg.type = empl.type
);


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

SELECT amount FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM suppliers AS ord
    WHERE ord.type = mgr.type
);


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

SELECT amount FROM employees AS ordr
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS whs
    WHERE whs.code = ordr.code
);


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

SELECT value FROM shipments AS inv
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS srvc
    WHERE srvc.type = inv.type
);


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

SELECT name FROM invoices AS rgn
WHERE type IN (
    SELECT type FROM customers AS prod
    WHERE prod.code = rgn.code
);


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

SELECT amount FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.level = acct.level
);


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

SELECT name FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT value FROM invoices AS catg
WHERE amount > (
    SELECT AVG(amount) FROM departments AS schd
    WHERE schd.status = catg.status
);


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

SELECT name FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.status = catg.status
);


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

SELECT value FROM shipments AS srvc
WHERE salary > (
    SELECT MAX(value) FROM suppliers AS prod
    WHERE prod.id = srvc.id
);