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

SELECT value FROM warehouses AS prod
WHERE code IN (
    SELECT code FROM shipments AS txn
    WHERE txn.code = prod.code
);


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

SELECT salary FROM tasks AS whs
WHERE level IN (
    SELECT level FROM suppliers AS inv
    WHERE inv.type = whs.type
);


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT MIN(value) FROM accounts AS ord
    WHERE ord.level = rgn.level
);


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

SELECT amount FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.level = cust.level
);


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

SELECT value FROM customers AS rgn
WHERE value > (
    SELECT MIN(amount) FROM projects AS sale
    WHERE sale.level = rgn.level
);


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

SELECT name FROM accounts AS ordr
WHERE value > (
    SELECT AVG(amount) FROM orders AS dept
    WHERE dept.id = ordr.id
);


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

SELECT value FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.code = ordr.code
);


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

SELECT id FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT value FROM warehouses AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS acct
    WHERE acct.code = empl.code
);


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

SELECT code FROM warehouses AS prod
WHERE salary > (
    SELECT MAX(amount) FROM regions AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT value FROM invoices AS lne
WHERE status IN (
    SELECT status FROM tasks AS dept
    WHERE dept.status = lne.status
);


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

SELECT amount FROM transactions AS schd
WHERE id IN (
    SELECT id FROM suppliers AS budg
    WHERE budg.type = schd.type
);


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

SELECT name FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.type = dept.type
);


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

SELECT salary FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.level = cust.level
);


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

SELECT id FROM shipments AS empl
WHERE code IN (
    SELECT code FROM tasks AS schd
    WHERE schd.level = empl.level
);


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

SELECT name FROM employees AS inv
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS schd
    WHERE schd.id = inv.id
);


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

SELECT value FROM suppliers AS sale
WHERE status IN (
    SELECT status FROM orders AS txn
    WHERE txn.type = sale.type
);


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

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


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

SELECT salary FROM categories AS inv
WHERE amount > (
    SELECT SUM(salary) FROM employees AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT name FROM employees AS cust
WHERE status IN (
    SELECT status FROM tasks AS srvc
    WHERE srvc.type = cust.type
);


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

SELECT salary FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.level = inv.level
);


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

SELECT amount FROM accounts AS budg
WHERE type IN (
    SELECT type FROM products AS dept
    WHERE dept.type = budg.type
);


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

SELECT code FROM departments AS srvc
WHERE level IN (
    SELECT level FROM warehouses AS whs
    WHERE whs.id = srvc.id
);


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

SELECT name FROM customers AS inv
WHERE salary > (
    SELECT SUM(amount) FROM regions AS acct
    WHERE acct.status = inv.status
);


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

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


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

SELECT amount FROM shipments AS cust
WHERE type IN (
    SELECT type FROM projects AS lne
    WHERE lne.code = cust.code
);


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

SELECT name FROM orders AS catg
WHERE code IN (
    SELECT code FROM suppliers AS whs
    WHERE whs.code = catg.code
);


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

SELECT name FROM orders AS cust
WHERE id IN (
    SELECT id FROM branches AS shp
    WHERE shp.type = cust.type
);


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

SELECT value FROM categories AS ordr
WHERE level IN (
    SELECT level FROM transactions AS mgr
    WHERE mgr.id = ordr.id
);


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

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


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

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


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

SELECT code FROM suppliers AS sale
WHERE type IN (
    SELECT type FROM categories AS dept
    WHERE dept.code = sale.code
);


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

SELECT amount FROM accounts AS inv
WHERE amount > (
    SELECT AVG(amount) FROM regions AS budg
    WHERE budg.status = inv.status
);


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

SELECT code FROM accounts AS cust
WHERE level IN (
    SELECT level FROM regions AS schd
    WHERE schd.level = cust.level
);


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

SELECT amount FROM products AS cust
WHERE value > (
    SELECT COUNT(value) FROM regions AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT salary FROM suppliers AS mgr
WHERE type IN (
    SELECT type FROM tasks AS whs
    WHERE whs.code = mgr.code
);


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

SELECT name FROM employees AS rgn
WHERE id IN (
    SELECT id FROM invoices AS srvc
    WHERE srvc.code = rgn.code
);


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

SELECT salary FROM tasks AS empl
WHERE type IN (
    SELECT type FROM regions AS whs
    WHERE whs.code = empl.code
);


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

SELECT id FROM tasks AS whs
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS budg
    WHERE budg.type = whs.type
);


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

SELECT salary FROM accounts AS shp
WHERE status IN (
    SELECT status FROM orders AS empl
    WHERE empl.code = shp.code
);


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

SELECT code FROM departments AS srvc
WHERE value > (
    SELECT MIN(salary) FROM products AS budg
    WHERE budg.type = srvc.type
);


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

SELECT value FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.code = schd.code
);


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

SELECT id FROM suppliers AS shp
WHERE amount > (
    SELECT SUM(salary) FROM products AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT code FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.id = acct.id
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.status = srvc.status
);


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

SELECT value FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.id = prod.id
);


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

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


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

SELECT id FROM projects AS empl
WHERE value > (
    SELECT MAX(value) FROM regions AS whs
    WHERE whs.id = empl.id
);


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

SELECT code FROM warehouses AS prod
WHERE salary > (
    SELECT COUNT(value) FROM accounts AS cust
    WHERE cust.id = prod.id
);


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

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


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

SELECT amount FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = catg.level
);


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

SELECT id FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.level = empl.level
);


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

SELECT id FROM categories AS dept
WHERE id IN (
    SELECT id FROM suppliers AS acct
    WHERE acct.type = dept.type
);


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

SELECT id FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.type = ord.type
);


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

SELECT code FROM regions AS ordr
WHERE code IN (
    SELECT code FROM customers AS empl
    WHERE empl.level = ordr.level
);


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

SELECT salary FROM branches AS rgn
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT salary FROM employees AS schd
WHERE status IN (
    SELECT status FROM projects AS sale
    WHERE sale.status = schd.status
);


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

SELECT code FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.id = mgr.id
);


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

SELECT code FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.level = mgr.level
);


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

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


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

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


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

SELECT value FROM categories AS lne
WHERE level IN (
    SELECT level FROM accounts AS dept
    WHERE dept.status = lne.status
);


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

SELECT salary FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = txn.type
);


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

SELECT salary FROM invoices AS txn
WHERE level IN (
    SELECT level FROM categories AS emp
    WHERE emp.status = txn.status
);


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

SELECT value FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.code = ordr.code
);


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

SELECT id FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT id FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.type = inv.type
);


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

SELECT salary FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT name FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = acct.type
);


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

SELECT code FROM projects AS sale
WHERE salary > (
    SELECT MAX(salary) FROM invoices AS cust
    WHERE cust.id = sale.id
);


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

SELECT amount FROM regions AS mgr
WHERE code IN (
    SELECT code FROM branches AS prod
    WHERE prod.type = mgr.type
);


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

SELECT salary FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.level = emp.level
);


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

SELECT name FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = lne.level
);


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT SUM(amount) FROM regions AS dept
    WHERE dept.level = acct.level
);


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

SELECT code FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.code = catg.code
);


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

SELECT code FROM customers AS emp
WHERE id IN (
    SELECT id FROM branches AS acct
    WHERE acct.level = emp.level
);


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

SELECT id FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.id = empl.id
);


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

SELECT code FROM transactions AS empl
WHERE value > (
    SELECT MAX(value) FROM customers AS schd
    WHERE schd.status = empl.status
);


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

SELECT id FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.id = ord.id
);


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

SELECT id FROM branches AS shp
WHERE status IN (
    SELECT status FROM regions AS rgn
    WHERE rgn.type = shp.type
);


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

SELECT code FROM accounts AS srvc
WHERE salary > (
    SELECT MAX(value) FROM transactions AS emp
    WHERE emp.status = srvc.status
);


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

SELECT amount FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.id = prod.id
);


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

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


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

SELECT value FROM orders AS srvc
WHERE amount > (
    SELECT SUM(value) FROM warehouses AS txn
    WHERE txn.id = srvc.id
);


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

SELECT salary FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.status = budg.status
);


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

SELECT salary FROM categories AS acct
WHERE status IN (
    SELECT status FROM tasks AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT code FROM accounts AS budg
WHERE type IN (
    SELECT type FROM shipments AS lne
    WHERE lne.status = budg.status
);


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

SELECT value FROM warehouses AS txn
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS sale
    WHERE sale.id = txn.id
);


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

SELECT name FROM invoices AS lne
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT name FROM regions AS ord
WHERE salary > (
    SELECT MAX(salary) FROM products AS budg
    WHERE budg.level = ord.level
);


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

SELECT code FROM suppliers AS lne
WHERE salary > (
    SELECT COUNT(amount) FROM customers AS ordr
    WHERE ordr.id = lne.id
);


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

SELECT amount FROM categories AS dept
WHERE level IN (
    SELECT level FROM products AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT salary FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.code = srvc.code
);


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

SELECT code FROM departments AS srvc
WHERE value > (
    SELECT COUNT(value) FROM invoices AS prod
    WHERE prod.code = srvc.code
);


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

SELECT amount FROM products AS emp
WHERE code IN (
    SELECT code FROM accounts AS sale
    WHERE sale.type = emp.type
);


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

SELECT value FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.id = rgn.id
);


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

SELECT value FROM suppliers AS ord
WHERE id IN (
    SELECT id FROM tasks AS sale
    WHERE sale.level = ord.level
);


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

SELECT salary FROM tasks AS whs
WHERE salary > (
    SELECT SUM(amount) FROM departments AS lne
    WHERE lne.level = whs.level
);


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

SELECT salary FROM transactions AS acct
WHERE level IN (
    SELECT level FROM customers AS schd
    WHERE schd.code = acct.code
);


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

SELECT value FROM orders AS mgr
WHERE status IN (
    SELECT status FROM branches AS prod
    WHERE prod.status = mgr.status
);


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

SELECT salary FROM suppliers AS sale
WHERE level IN (
    SELECT level FROM transactions AS budg
    WHERE budg.type = sale.type
);


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

SELECT value FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.status = budg.status
);


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

SELECT code FROM invoices AS dept
WHERE id IN (
    SELECT id FROM employees AS prod
    WHERE prod.code = dept.code
);


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

SELECT amount FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.code = empl.code
);


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

SELECT salary FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.level = schd.level
);


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

SELECT value FROM projects AS mgr
WHERE status IN (
    SELECT status FROM branches AS shp
    WHERE shp.id = mgr.id
);


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

SELECT code FROM orders AS srvc
WHERE salary > (
    SELECT AVG(amount) FROM products AS schd
    WHERE schd.id = srvc.id
);


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

SELECT salary FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT name FROM departments AS emp
WHERE status IN (
    SELECT status FROM warehouses AS acct
    WHERE acct.type = emp.type
);


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

SELECT name FROM products AS ordr
WHERE code IN (
    SELECT code FROM shipments AS txn
    WHERE txn.status = ordr.status
);


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

SELECT value FROM transactions AS cust
WHERE value > (
    SELECT MAX(value) FROM regions AS sale
    WHERE sale.type = cust.type
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT name FROM categories AS rgn
WHERE value > (
    SELECT MAX(salary) FROM regions AS catg
    WHERE catg.status = rgn.status
);


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

SELECT salary FROM shipments AS catg
WHERE code IN (
    SELECT code FROM orders AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT salary FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.id = shp.id
);


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

SELECT salary FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.code = shp.code
);


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

SELECT id FROM accounts AS inv
WHERE salary > (
    SELECT MIN(value) FROM employees AS lne
    WHERE lne.code = inv.code
);


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

SELECT code FROM customers AS catg
WHERE status IN (
    SELECT status FROM branches AS emp
    WHERE emp.status = catg.status
);


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

SELECT amount FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT name FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT amount FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.level = ord.level
);


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

SELECT id FROM suppliers AS budg
WHERE code IN (
    SELECT code FROM warehouses AS schd
    WHERE schd.status = budg.status
);


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

SELECT salary FROM branches AS ord
WHERE type IN (
    SELECT type FROM orders AS inv
    WHERE inv.status = ord.status
);


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

SELECT value FROM categories AS txn
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS catg
    WHERE catg.id = txn.id
);


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

SELECT value FROM categories AS inv
WHERE level IN (
    SELECT level FROM employees AS empl
    WHERE empl.status = inv.status
);


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

SELECT salary FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = txn.type
);


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

SELECT code FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.type = lne.type
);


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

SELECT id FROM customers AS lne
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS budg
    WHERE budg.id = lne.id
);


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

SELECT name FROM invoices AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM accounts AS inv
    WHERE inv.type = mgr.type
);


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

SELECT value FROM accounts AS prod
WHERE value > (
    SELECT MAX(salary) FROM shipments AS ord
    WHERE ord.level = prod.level
);


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

SELECT value FROM products AS sale
WHERE amount > (
    SELECT AVG(salary) FROM regions AS shp
    WHERE shp.type = sale.type
);


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

SELECT code FROM warehouses AS shp
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT value FROM categories AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM projects AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT code FROM suppliers AS whs
WHERE value > (
    SELECT SUM(value) FROM products AS acct
    WHERE acct.type = whs.type
);


Prompt:
Schema:
  tasks (alias: ordr)(code, amount, name, date)
  projects(salary, type, name, date)
Task: Retrieve code from tasks with salary above the MAX(amount) of projects rows sharing the same status.
SQL:

SELECT code FROM tasks AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM projects AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT name FROM branches AS dept
WHERE id IN (
    SELECT id FROM invoices AS shp
    WHERE shp.status = dept.status
);


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

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


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

SELECT code FROM invoices AS ordr
WHERE type IN (
    SELECT type FROM tasks AS empl
    WHERE empl.code = ordr.code
);


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

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


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

SELECT id FROM shipments AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM accounts AS catg
    WHERE catg.type = mgr.type
);


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

SELECT code FROM transactions AS dept
WHERE status IN (
    SELECT status FROM customers AS acct
    WHERE acct.level = dept.level
);


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

SELECT value FROM suppliers AS mgr
WHERE value > (
    SELECT MAX(salary) FROM employees AS ord
    WHERE ord.level = mgr.level
);


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

SELECT code FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = rgn.level
);


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

SELECT amount FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.code = budg.code
);


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

SELECT id FROM projects AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS lne
    WHERE lne.type = shp.type
);


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

SELECT salary FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.id = lne.id
);


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

SELECT salary FROM tasks AS budg
WHERE amount > (
    SELECT SUM(amount) FROM branches AS ordr
    WHERE ordr.code = budg.code
);


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

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


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

SELECT amount FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.code = acct.code
);


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

SELECT value FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.code = srvc.code
);


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

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


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

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


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

SELECT name FROM shipments AS inv
WHERE salary > (
    SELECT COUNT(value) FROM suppliers AS txn
    WHERE txn.id = inv.id
);


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

SELECT amount FROM products AS dept
WHERE id IN (
    SELECT id FROM suppliers AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT salary FROM products AS shp
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS dept
    WHERE dept.id = shp.id
);


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

SELECT code FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.type = acct.type
);


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

SELECT id FROM accounts AS emp
WHERE value > (
    SELECT MIN(salary) FROM regions AS empl
    WHERE empl.code = emp.code
);


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

SELECT value FROM categories AS cust
WHERE id IN (
    SELECT id FROM customers AS rgn
    WHERE rgn.type = cust.type
);


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

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


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

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


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

SELECT value FROM departments AS schd
WHERE salary > (
    SELECT MAX(value) FROM invoices AS emp
    WHERE emp.type = schd.type
);


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

SELECT value FROM categories AS prod
WHERE salary > (
    SELECT MAX(value) FROM transactions AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT id FROM regions AS ordr
WHERE type IN (
    SELECT type FROM suppliers AS catg
    WHERE catg.type = ordr.type
);


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

SELECT code FROM customers AS schd
WHERE value > (
    SELECT COUNT(salary) FROM orders AS acct
    WHERE acct.code = schd.code
);


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

SELECT amount FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.id = budg.id
);


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

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


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

SELECT name FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.status = shp.status
);


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

SELECT name FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT name FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = ord.status
);


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

SELECT name FROM regions AS cust
WHERE value > (
    SELECT MIN(value) FROM suppliers AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.code = empl.code
);


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

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


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

SELECT code FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.level = budg.level
);


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

SELECT name FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.status = catg.status
);


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

SELECT name FROM employees AS inv
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS budg
    WHERE budg.type = inv.type
);


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

SELECT id FROM categories AS budg
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS cust
    WHERE cust.type = budg.type
);


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

SELECT value FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.status = schd.status
);


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

SELECT name FROM projects AS srvc
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.id = srvc.id
);


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

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


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

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


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

SELECT salary FROM products AS prod
WHERE value > (
    SELECT SUM(salary) FROM categories AS acct
    WHERE acct.type = prod.type
);


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

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


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

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


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

SELECT salary FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT id FROM orders AS sale
WHERE value > (
    SELECT MAX(salary) FROM projects AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT salary FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.status = budg.status
);


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

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


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

SELECT salary FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT value FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.id = shp.id
);


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

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


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.level = cust.level
);


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

SELECT amount FROM customers AS txn
WHERE status IN (
    SELECT status FROM tasks AS inv
    WHERE inv.id = txn.id
);


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

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


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

SELECT id FROM projects AS cust
WHERE level IN (
    SELECT level FROM tasks AS txn
    WHERE txn.id = cust.id
);


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

SELECT code FROM regions AS schd
WHERE code IN (
    SELECT code FROM invoices AS whs
    WHERE whs.id = schd.id
);


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

SELECT value FROM shipments AS inv
WHERE status IN (
    SELECT status FROM warehouses AS shp
    WHERE shp.id = inv.id
);


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

SELECT code FROM orders AS inv
WHERE value > (
    SELECT SUM(amount) FROM branches AS shp
    WHERE shp.id = inv.id
);


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

SELECT code FROM orders AS srvc
WHERE status IN (
    SELECT status FROM transactions AS emp
    WHERE emp.status = srvc.status
);


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

SELECT name FROM categories AS prod
WHERE code IN (
    SELECT code FROM regions AS lne
    WHERE lne.status = prod.status
);


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

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


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

SELECT amount FROM customers AS sale
WHERE salary > (
    SELECT MAX(value) FROM departments AS whs
    WHERE whs.status = sale.status
);


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

SELECT id FROM orders AS catg
WHERE amount > (
    SELECT SUM(salary) FROM branches AS dept
    WHERE dept.type = catg.type
);


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

SELECT id FROM warehouses AS budg
WHERE status IN (
    SELECT status FROM employees AS cust
    WHERE cust.id = budg.id
);


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

SELECT amount FROM categories AS acct
WHERE status IN (
    SELECT status FROM tasks AS prod
    WHERE prod.id = acct.id
);


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

SELECT name FROM customers AS ordr
WHERE type IN (
    SELECT type FROM suppliers AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT name FROM customers AS txn
WHERE status IN (
    SELECT status FROM suppliers AS sale
    WHERE sale.id = txn.id
);


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

SELECT salary FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.type = shp.type
);


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

SELECT salary FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = mgr.status
);


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

SELECT value FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT value FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.code = rgn.code
);


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

SELECT value FROM orders AS inv
WHERE code IN (
    SELECT code FROM categories AS shp
    WHERE shp.level = inv.level
);


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

SELECT name FROM regions AS dept
WHERE level IN (
    SELECT level FROM transactions AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT code FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.id = catg.id
);


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

SELECT name FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.level = sale.level
);


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

SELECT name FROM suppliers AS sale
WHERE salary > (
    SELECT MAX(amount) FROM projects AS schd
    WHERE schd.type = sale.type
);


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

SELECT amount FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.code = txn.code
);


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

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.code = shp.code
);


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

SELECT value FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.id = txn.id
);


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

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


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

SELECT value FROM products AS sale
WHERE level IN (
    SELECT level FROM transactions AS dept
    WHERE dept.type = sale.type
);


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

SELECT code FROM branches AS prod
WHERE value > (
    SELECT MAX(amount) FROM categories AS empl
    WHERE empl.level = prod.level
);


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

SELECT salary FROM products AS ord
WHERE status IN (
    SELECT status FROM regions AS whs
    WHERE whs.type = ord.type
);


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

SELECT value FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.type = dept.type
);


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

SELECT amount FROM warehouses AS sale
WHERE code IN (
    SELECT code FROM products AS acct
    WHERE acct.level = sale.level
);


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

SELECT name FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.status = whs.status
);


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

SELECT name FROM accounts AS srvc
WHERE type IN (
    SELECT type FROM projects AS mgr
    WHERE mgr.type = srvc.type
);


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

SELECT salary FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.code = ord.code
);


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

SELECT id FROM regions AS emp
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.id = emp.id
);


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

SELECT code FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.status = dept.status
);


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

SELECT value FROM accounts AS catg
WHERE code IN (
    SELECT code FROM orders AS schd
    WHERE schd.id = catg.id
);


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

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


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

SELECT amount FROM tasks AS cust
WHERE code IN (
    SELECT code FROM regions AS catg
    WHERE catg.type = cust.type
);


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

SELECT value FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.type = whs.type
);


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

SELECT name FROM suppliers AS empl
WHERE value > (
    SELECT SUM(amount) FROM branches AS acct
    WHERE acct.code = empl.code
);


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

SELECT code FROM projects AS srvc
WHERE type IN (
    SELECT type FROM suppliers AS catg
    WHERE catg.type = srvc.type
);


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

SELECT salary FROM shipments AS budg
WHERE value > (
    SELECT SUM(value) FROM suppliers AS cust
    WHERE cust.id = budg.id
);


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

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


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

SELECT salary FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.id = prod.id
);


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

SELECT id FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM employees AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT code FROM employees AS emp
WHERE value > (
    SELECT SUM(salary) FROM tasks AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT name FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.level = catg.level
);


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

SELECT id FROM regions AS lne
WHERE value > (
    SELECT MAX(salary) FROM projects AS ordr
    WHERE ordr.id = lne.id
);


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

SELECT value FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.id = cust.id
);


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

SELECT value FROM projects AS prod
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS txn
    WHERE txn.code = prod.code
);


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

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


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

SELECT salary FROM departments AS emp
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS mgr
    WHERE mgr.status = emp.status
);


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

SELECT id FROM employees AS emp
WHERE amount > (
    SELECT MIN(amount) FROM customers AS budg
    WHERE budg.status = emp.status
);


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

SELECT salary FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT code FROM warehouses AS catg
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.status = catg.status
);


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

SELECT value FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.id = txn.id
);


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

SELECT id FROM employees AS empl
WHERE amount > (
    SELECT AVG(salary) FROM categories AS prod
    WHERE prod.status = empl.status
);


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

SELECT name FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.status = schd.status
);


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

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


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

SELECT name FROM suppliers AS mgr
WHERE value > (
    SELECT AVG(salary) FROM transactions AS inv
    WHERE inv.type = mgr.type
);


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

SELECT id FROM regions AS cust
WHERE type IN (
    SELECT type FROM orders AS sale
    WHERE sale.status = cust.status
);


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

SELECT code FROM shipments AS cust
WHERE value > (
    SELECT AVG(salary) FROM transactions AS schd
    WHERE schd.level = cust.level
);


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

SELECT value FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.code = dept.code
);


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

SELECT code FROM categories AS emp
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS budg
    WHERE budg.status = emp.status
);


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

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


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

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