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

SELECT salary FROM categories AS emp
WHERE status IN (
    SELECT status FROM regions AS budg
    WHERE budg.level = emp.level
);


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

SELECT id FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT salary FROM shipments AS budg
WHERE type IN (
    SELECT type FROM orders AS prod
    WHERE prod.code = budg.code
);


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

SELECT id FROM warehouses AS ordr
WHERE code IN (
    SELECT code FROM branches AS acct
    WHERE acct.level = ordr.level
);


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

SELECT amount FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.status = mgr.status
);


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

SELECT name FROM regions AS emp
WHERE level IN (
    SELECT level FROM transactions AS acct
    WHERE acct.id = emp.id
);


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

SELECT salary FROM projects AS dept
WHERE value > (
    SELECT MAX(salary) FROM transactions AS sale
    WHERE sale.id = dept.id
);


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

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


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

SELECT id FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT value FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = txn.status
);


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

SELECT id FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.type = mgr.type
);


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

SELECT id FROM invoices AS schd
WHERE type IN (
    SELECT type FROM categories AS inv
    WHERE inv.level = schd.level
);


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

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


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

SELECT amount FROM branches AS budg
WHERE code IN (
    SELECT code FROM transactions AS sale
    WHERE sale.level = budg.level
);


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

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


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

SELECT salary FROM departments AS rgn
WHERE level IN (
    SELECT level FROM projects AS shp
    WHERE shp.type = rgn.type
);


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

SELECT code FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.level = ordr.level
);


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

SELECT amount FROM branches AS shp
WHERE type IN (
    SELECT type FROM products AS dept
    WHERE dept.id = shp.id
);


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

SELECT value FROM regions AS shp
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS cust
    WHERE cust.id = shp.id
);


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

SELECT salary FROM products AS mgr
WHERE level IN (
    SELECT level FROM transactions AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT code FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.code = ordr.code
);


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

SELECT name FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.type = mgr.type
);


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

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


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

SELECT id FROM warehouses AS budg
WHERE code IN (
    SELECT code FROM projects AS prod
    WHERE prod.code = budg.code
);


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

SELECT salary FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT value FROM shipments AS sale
WHERE status IN (
    SELECT status FROM tasks AS cust
    WHERE cust.status = sale.status
);


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

SELECT salary FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.code = ordr.code
);


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

SELECT amount FROM employees AS acct
WHERE code IN (
    SELECT code FROM branches AS empl
    WHERE empl.id = acct.id
);


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

SELECT salary FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.code = prod.code
);


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

SELECT id FROM customers AS prod
WHERE salary > (
    SELECT MIN(salary) FROM orders AS sale
    WHERE sale.id = prod.id
);


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

SELECT id FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.code = sale.code
);


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

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


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

SELECT name FROM branches AS empl
WHERE level IN (
    SELECT level FROM orders AS cust
    WHERE cust.code = empl.code
);


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

SELECT salary FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = ordr.status
);


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

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


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

SELECT value FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.id = ord.id
);


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

SELECT id FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.level = mgr.level
);


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

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


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

SELECT code FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.type = cust.type
);


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

SELECT name FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.level = dept.level
);


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

SELECT amount FROM suppliers AS txn
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.id = txn.id
);


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

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


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

SELECT name FROM tasks AS ord
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS budg
    WHERE budg.status = ord.status
);


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

SELECT amount FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = dept.id
);


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

SELECT salary FROM suppliers AS lne
WHERE value > (
    SELECT SUM(salary) FROM projects AS emp
    WHERE emp.code = lne.code
);


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

SELECT amount FROM shipments AS srvc
WHERE id IN (
    SELECT id FROM suppliers AS empl
    WHERE empl.status = srvc.status
);


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

SELECT value FROM products AS acct
WHERE value > (
    SELECT MAX(value) FROM orders AS shp
    WHERE shp.code = acct.code
);


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

SELECT salary FROM regions AS ord
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT name FROM employees AS ord
WHERE level IN (
    SELECT level FROM invoices AS sale
    WHERE sale.id = ord.id
);


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

SELECT name FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT salary FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.code = lne.code
);


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

SELECT id FROM orders AS whs
WHERE id IN (
    SELECT id FROM customers AS catg
    WHERE catg.type = whs.type
);


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

SELECT salary FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.status = schd.status
);


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

SELECT salary FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.id = acct.id
);


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

SELECT code FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = shp.code
);


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

SELECT code FROM tasks AS cust
WHERE code IN (
    SELECT code FROM transactions AS budg
    WHERE budg.type = cust.type
);


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

SELECT value FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.status = ord.status
);


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

SELECT name FROM departments AS acct
WHERE amount > (
    SELECT MIN(value) FROM projects AS txn
    WHERE txn.level = acct.level
);


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

SELECT value FROM shipments AS ord
WHERE value > (
    SELECT AVG(value) FROM regions AS srvc
    WHERE srvc.id = ord.id
);


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

SELECT value FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.code = prod.code
);


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

SELECT code FROM branches AS sale
WHERE value > (
    SELECT COUNT(salary) FROM accounts AS inv
    WHERE inv.status = sale.status
);


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

SELECT code FROM accounts AS budg
WHERE status IN (
    SELECT status FROM products AS mgr
    WHERE mgr.id = budg.id
);


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

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


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

SELECT id FROM employees AS emp
WHERE salary > (
    SELECT SUM(value) FROM tasks AS budg
    WHERE budg.type = emp.type
);


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

SELECT value FROM suppliers AS cust
WHERE salary > (
    SELECT AVG(value) FROM employees AS shp
    WHERE shp.code = cust.code
);


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

SELECT name FROM products AS acct
WHERE value > (
    SELECT MIN(amount) FROM transactions AS txn
    WHERE txn.code = acct.code
);


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

SELECT code FROM suppliers AS catg
WHERE salary > (
    SELECT MAX(amount) FROM orders AS lne
    WHERE lne.level = catg.level
);


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

SELECT salary FROM regions AS rgn
WHERE level IN (
    SELECT level FROM categories AS prod
    WHERE prod.status = rgn.status
);


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

SELECT salary FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.code = budg.code
);


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

SELECT salary FROM suppliers AS shp
WHERE status IN (
    SELECT status FROM branches AS dept
    WHERE dept.level = shp.level
);


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

SELECT salary FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.level = ordr.level
);


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

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


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

SELECT value FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = schd.type
);


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

SELECT name FROM employees AS budg
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS srvc
    WHERE srvc.id = budg.id
);


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

SELECT code FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = catg.level
);


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

SELECT value FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.type = emp.type
);


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

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


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

SELECT amount FROM categories AS ord
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.code = ord.code
);


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

SELECT id FROM projects AS mgr
WHERE salary > (
    SELECT MIN(value) FROM accounts AS emp
    WHERE emp.level = mgr.level
);


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

SELECT id FROM employees AS lne
WHERE id IN (
    SELECT id FROM departments AS acct
    WHERE acct.type = lne.type
);


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

SELECT code FROM branches AS lne
WHERE salary > (
    SELECT COUNT(value) FROM transactions AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT amount FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.id = inv.id
);


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

SELECT name FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.type = schd.type
);


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

SELECT id FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.level = schd.level
);


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

SELECT code FROM transactions AS catg
WHERE value > (
    SELECT COUNT(value) FROM shipments AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT code FROM projects AS shp
WHERE status IN (
    SELECT status FROM customers AS lne
    WHERE lne.id = shp.id
);


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

SELECT name FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.level = sale.level
);


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

SELECT amount FROM regions AS catg
WHERE value > (
    SELECT MAX(value) FROM orders AS inv
    WHERE inv.id = catg.id
);


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

SELECT code FROM departments AS catg
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS empl
    WHERE empl.id = catg.id
);


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

SELECT code FROM departments AS inv
WHERE type IN (
    SELECT type FROM customers AS emp
    WHERE emp.id = inv.id
);


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

SELECT name FROM warehouses AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS mgr
    WHERE mgr.type = catg.type
);


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

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


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

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


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

SELECT id FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT id FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.level = lne.level
);


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

SELECT amount FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.id = mgr.id
);


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

SELECT code FROM customers AS empl
WHERE type IN (
    SELECT type FROM projects AS acct
    WHERE acct.status = empl.status
);


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

SELECT salary FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.id = ord.id
);


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

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


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

SELECT amount FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT value FROM suppliers AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM warehouses AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT id FROM invoices AS dept
WHERE value > (
    SELECT MIN(value) FROM tasks AS lne
    WHERE lne.type = dept.type
);


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

SELECT salary FROM transactions AS cust
WHERE id IN (
    SELECT id FROM employees AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT value FROM regions AS acct
WHERE value > (
    SELECT MIN(amount) FROM invoices AS schd
    WHERE schd.level = acct.level
);


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

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


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

SELECT code FROM products AS shp
WHERE code IN (
    SELECT code FROM transactions AS schd
    WHERE schd.status = shp.status
);


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

SELECT amount FROM projects AS srvc
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.id = srvc.id
);


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

SELECT value FROM suppliers AS inv
WHERE id IN (
    SELECT id FROM transactions AS catg
    WHERE catg.id = inv.id
);


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

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


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

SELECT value FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.level = dept.level
);


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

SELECT id FROM customers AS shp
WHERE salary > (
    SELECT AVG(value) FROM categories AS catg
    WHERE catg.type = shp.type
);


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

SELECT value FROM products AS sale
WHERE code IN (
    SELECT code FROM customers AS schd
    WHERE schd.code = sale.code
);


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

SELECT code FROM invoices AS prod
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.type = prod.type
);


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

SELECT name FROM projects AS emp
WHERE type IN (
    SELECT type FROM invoices AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT code FROM tasks AS dept
WHERE id IN (
    SELECT id FROM transactions AS sale
    WHERE sale.type = dept.type
);


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

SELECT value FROM tasks AS inv
WHERE id IN (
    SELECT id FROM customers AS dept
    WHERE dept.type = inv.type
);


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

SELECT name FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.code = prod.code
);


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

SELECT amount FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.code = mgr.code
);


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

SELECT id FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT value FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.level = prod.level
);


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

SELECT name FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.id = catg.id
);


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

SELECT name FROM products AS acct
WHERE status IN (
    SELECT status FROM departments AS empl
    WHERE empl.code = acct.code
);


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

SELECT value FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.id = ord.id
);


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

SELECT value FROM products AS schd
WHERE type IN (
    SELECT type FROM suppliers AS budg
    WHERE budg.id = schd.id
);


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

SELECT code FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM suppliers AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT id FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT id FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.level = prod.level
);


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

SELECT name FROM employees AS ordr
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS sale
    WHERE sale.type = ordr.type
);


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

SELECT name FROM warehouses AS shp
WHERE type IN (
    SELECT type FROM regions AS whs
    WHERE whs.status = shp.status
);


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

SELECT id FROM invoices AS budg
WHERE salary > (
    SELECT AVG(amount) FROM projects AS inv
    WHERE inv.code = budg.code
);


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

SELECT name FROM employees AS lne
WHERE amount > (
    SELECT MAX(value) FROM categories AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT name FROM departments AS sale
WHERE type IN (
    SELECT type FROM categories AS schd
    WHERE schd.id = sale.id
);


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

SELECT id FROM warehouses AS txn
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS inv
    WHERE inv.level = txn.level
);


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

SELECT amount FROM categories AS rgn
WHERE level IN (
    SELECT level FROM accounts AS emp
    WHERE emp.id = rgn.id
);


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

SELECT name FROM accounts AS lne
WHERE level IN (
    SELECT level FROM categories AS txn
    WHERE txn.status = lne.status
);


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

SELECT value FROM tasks AS schd
WHERE code IN (
    SELECT code FROM regions AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT code FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.type = dept.type
);


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

SELECT name FROM employees AS txn
WHERE id IN (
    SELECT id FROM categories AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT id FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT salary FROM departments AS dept
WHERE value > (
    SELECT MAX(salary) FROM accounts AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT value FROM orders AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS lne
    WHERE lne.id = mgr.id
);


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

SELECT value FROM employees AS cust
WHERE status IN (
    SELECT status FROM categories AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT amount FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.status = srvc.status
);


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

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


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

SELECT name FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.type = cust.type
);


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

SELECT salary FROM accounts AS cust
WHERE amount > (
    SELECT MIN(amount) FROM employees AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT value FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.level = lne.level
);


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

SELECT name FROM products AS empl
WHERE type IN (
    SELECT type FROM departments AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT id FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.type = emp.type
);


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

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


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

SELECT salary FROM suppliers AS schd
WHERE level IN (
    SELECT level FROM orders AS rgn
    WHERE rgn.id = schd.id
);


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

SELECT name FROM departments AS sale
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS budg
    WHERE budg.id = sale.id
);


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

SELECT value FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.id = schd.id
);


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

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


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

SELECT name FROM projects AS rgn
WHERE id IN (
    SELECT id FROM orders AS txn
    WHERE txn.status = rgn.status
);


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

SELECT id FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.id = ord.id
);


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

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


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

SELECT amount FROM categories AS prod
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS catg
    WHERE catg.type = prod.type
);


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

SELECT salary FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.id = lne.id
);


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

SELECT name FROM categories AS schd
WHERE type IN (
    SELECT type FROM branches AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT id FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.status = ord.status
);


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

SELECT salary FROM invoices AS srvc
WHERE id IN (
    SELECT id FROM departments AS shp
    WHERE shp.level = srvc.level
);


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

SELECT value FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.code = acct.code
);


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

SELECT value FROM categories AS prod
WHERE value > (
    SELECT AVG(salary) FROM regions AS catg
    WHERE catg.code = prod.code
);


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

SELECT value FROM employees AS whs
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS txn
    WHERE txn.status = whs.status
);


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

SELECT salary FROM categories AS budg
WHERE type IN (
    SELECT type FROM regions AS txn
    WHERE txn.id = budg.id
);


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

SELECT code FROM employees AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM transactions AS cust
    WHERE cust.status = ordr.status
);


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

SELECT name FROM transactions AS whs
WHERE amount > (
    SELECT AVG(value) FROM invoices AS txn
    WHERE txn.type = whs.type
);


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

SELECT value FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.id = empl.id
);


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

SELECT name FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.level = srvc.level
);


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

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


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

SELECT code FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.id = inv.id
);


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

SELECT value FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.status = whs.status
);


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

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


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

SELECT salary FROM departments AS inv
WHERE code IN (
    SELECT code FROM transactions AS acct
    WHERE acct.id = inv.id
);


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

SELECT salary FROM tasks AS empl
WHERE code IN (
    SELECT code FROM products AS prod
    WHERE prod.id = empl.id
);


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

SELECT code FROM branches AS lne
WHERE value > (
    SELECT COUNT(salary) FROM orders AS whs
    WHERE whs.code = lne.code
);


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

SELECT salary FROM branches AS acct
WHERE status IN (
    SELECT status FROM suppliers AS cust
    WHERE cust.id = acct.id
);


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

SELECT id FROM invoices AS ord
WHERE amount > (
    SELECT AVG(salary) FROM projects AS cust
    WHERE cust.status = ord.status
);


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

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


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

SELECT salary FROM categories AS acct
WHERE id IN (
    SELECT id FROM products AS cust
    WHERE cust.status = acct.status
);


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

SELECT value FROM tasks AS txn
WHERE status IN (
    SELECT status FROM accounts AS budg
    WHERE budg.code = txn.code
);


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

SELECT id FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.status = catg.status
);


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

SELECT value FROM invoices AS catg
WHERE type IN (
    SELECT type FROM shipments AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT code FROM products AS schd
WHERE value > (
    SELECT COUNT(value) FROM tasks AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT amount FROM customers AS dept
WHERE value > (
    SELECT SUM(amount) FROM branches AS empl
    WHERE empl.id = dept.id
);


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

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


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

SELECT name FROM projects AS whs
WHERE salary > (
    SELECT SUM(value) FROM suppliers AS empl
    WHERE empl.id = whs.id
);


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

SELECT id FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.status = shp.status
);


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

SELECT code FROM categories AS dept
WHERE type IN (
    SELECT type FROM warehouses AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT value FROM customers AS ord
WHERE amount > (
    SELECT MAX(salary) FROM branches AS whs
    WHERE whs.id = ord.id
);


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

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


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

SELECT value FROM departments AS prod
WHERE id IN (
    SELECT id FROM transactions AS budg
    WHERE budg.status = prod.status
);


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

SELECT salary FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.level = ord.level
);


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

SELECT amount FROM invoices AS cust
WHERE level IN (
    SELECT level FROM shipments AS emp
    WHERE emp.id = cust.id
);


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

SELECT id FROM categories AS sale
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.level = sale.level
);


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

SELECT value FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT amount FROM shipments AS mgr
WHERE status IN (
    SELECT status FROM departments AS whs
    WHERE whs.status = mgr.status
);


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

SELECT salary FROM customers AS whs
WHERE amount > (
    SELECT MAX(value) FROM employees AS lne
    WHERE lne.type = whs.type
);


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

SELECT value FROM employees AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS cust
    WHERE cust.type = mgr.type
);


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

SELECT id FROM branches AS sale
WHERE id IN (
    SELECT id FROM categories AS prod
    WHERE prod.type = sale.type
);


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

SELECT value FROM orders AS cust
WHERE salary > (
    SELECT MIN(amount) FROM categories AS whs
    WHERE whs.id = cust.id
);


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

SELECT value FROM accounts AS schd
WHERE code IN (
    SELECT code FROM tasks AS catg
    WHERE catg.level = schd.level
);


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

SELECT code FROM projects AS acct
WHERE status IN (
    SELECT status FROM orders AS schd
    WHERE schd.id = acct.id
);


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

SELECT value FROM shipments AS cust
WHERE id IN (
    SELECT id FROM branches AS shp
    WHERE shp.level = cust.level
);


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

SELECT code FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT salary FROM accounts AS sale
WHERE value > (
    SELECT MIN(salary) FROM orders AS inv
    WHERE inv.level = sale.level
);


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

SELECT code FROM projects AS shp
WHERE value > (
    SELECT AVG(amount) FROM orders AS srvc
    WHERE srvc.id = shp.id
);


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

SELECT name FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = sale.level
);


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

SELECT amount FROM categories AS ordr
WHERE id IN (
    SELECT id FROM employees AS schd
    WHERE schd.code = ordr.code
);


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

SELECT name FROM invoices AS rgn
WHERE type IN (
    SELECT type FROM products AS emp
    WHERE emp.id = rgn.id
);


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

SELECT value FROM shipments AS sale
WHERE amount > (
    SELECT SUM(value) FROM tasks AS mgr
    WHERE mgr.code = sale.code
);


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

SELECT amount FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.id = sale.id
);


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

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


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

SELECT id FROM transactions AS srvc
WHERE code IN (
    SELECT code FROM employees AS whs
    WHERE whs.id = srvc.id
);


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

SELECT code FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.code = budg.code
);


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

SELECT amount FROM employees AS acct
WHERE status IN (
    SELECT status FROM shipments AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT salary FROM warehouses AS mgr
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.code = mgr.code
);


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

SELECT salary FROM suppliers AS txn
WHERE id IN (
    SELECT id FROM projects AS lne
    WHERE lne.status = txn.status
);


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

SELECT amount FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.level = srvc.level
);


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

SELECT amount FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT name FROM branches AS emp
WHERE status IN (
    SELECT status FROM invoices AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT value FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.id = sale.id
);


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

SELECT name FROM employees AS ord
WHERE amount > (
    SELECT MIN(salary) FROM orders AS empl
    WHERE empl.type = ord.type
);


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

SELECT amount FROM warehouses AS sale
WHERE id IN (
    SELECT id FROM projects AS prod
    WHERE prod.level = sale.level
);


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

SELECT code FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.status = budg.status
);


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

SELECT name FROM accounts AS srvc
WHERE type IN (
    SELECT type FROM suppliers AS ord
    WHERE ord.level = srvc.level
);


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

SELECT code FROM products AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT code FROM projects AS acct
WHERE code IN (
    SELECT code FROM warehouses AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT code FROM warehouses AS lne
WHERE value > (
    SELECT MIN(value) FROM orders AS shp
    WHERE shp.code = lne.code
);


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

SELECT value FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT value FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.level = mgr.level
);


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

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


Prompt:
Schema:
  warehouses (alias: cust)(id, amount, date, level)
  shipments(value, id, amount, date)
Task: Retrieve amount from warehouses with amount above the MIN(salary) of shipments rows sharing the same id.
SQL:

SELECT amount FROM warehouses AS cust
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS budg
    WHERE budg.id = cust.id
);


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

SELECT salary FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.type = srvc.type
);


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

SELECT value FROM products AS acct
WHERE id IN (
    SELECT id FROM tasks AS shp
    WHERE shp.level = acct.level
);


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

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


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

SELECT name FROM accounts AS rgn
WHERE amount > (
    SELECT SUM(value) FROM employees AS empl
    WHERE empl.level = rgn.level
);


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

SELECT amount FROM regions AS dept
WHERE status IN (
    SELECT status FROM accounts AS emp
    WHERE emp.code = dept.code
);


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

SELECT name FROM regions AS mgr
WHERE value > (
    SELECT MAX(amount) FROM branches AS empl
    WHERE empl.level = mgr.level
);


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

SELECT code FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = emp.status
);


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

SELECT salary FROM shipments AS rgn
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.level = rgn.level
);


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

SELECT id FROM orders AS inv
WHERE salary > (
    SELECT SUM(salary) FROM branches AS mgr
    WHERE mgr.level = inv.level
);


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

SELECT code FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.status = schd.status
);


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

SELECT id FROM projects AS lne
WHERE value > (
    SELECT COUNT(amount) FROM products AS schd
    WHERE schd.type = lne.type
);


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

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


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

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


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

SELECT amount FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.status = emp.status
);


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

SELECT value FROM categories AS cust
WHERE type IN (
    SELECT type FROM employees AS sale
    WHERE sale.id = cust.id
);


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

SELECT name FROM branches AS catg
WHERE id IN (
    SELECT id FROM transactions AS acct
    WHERE acct.id = catg.id
);


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

SELECT amount FROM products AS schd
WHERE value > (
    SELECT SUM(amount) FROM departments AS catg
    WHERE catg.code = schd.code
);


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

SELECT id FROM regions AS budg
WHERE value > (
    SELECT MIN(value) FROM accounts AS lne
    WHERE lne.type = budg.type
);


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

SELECT code FROM invoices AS emp
WHERE amount > (
    SELECT AVG(value) FROM employees AS dept
    WHERE dept.status = emp.status
);


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

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


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

SELECT name FROM branches AS txn
WHERE code IN (
    SELECT code FROM accounts AS shp
    WHERE shp.level = txn.level
);


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

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


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

SELECT value FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.code = lne.code
);


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

SELECT name FROM departments AS emp
WHERE level IN (
    SELECT level FROM shipments AS whs
    WHERE whs.type = emp.type
);


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

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


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

SELECT amount FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.id = budg.id
);


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

SELECT salary FROM suppliers AS whs
WHERE salary > (
    SELECT SUM(salary) FROM projects AS acct
    WHERE acct.status = whs.status
);


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

SELECT salary FROM categories AS whs
WHERE salary > (
    SELECT MAX(amount) FROM employees AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT code FROM branches AS inv
WHERE salary > (
    SELECT COUNT(value) FROM warehouses AS srvc
    WHERE srvc.id = inv.id
);


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

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


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

SELECT salary FROM accounts AS empl
WHERE type IN (
    SELECT type FROM employees AS acct
    WHERE acct.id = empl.id
);


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

SELECT salary FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.id = lne.id
);


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

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


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

SELECT name FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.level = ordr.level
);


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

SELECT name FROM projects AS mgr
WHERE status IN (
    SELECT status FROM employees AS acct
    WHERE acct.code = mgr.code
);


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

SELECT code FROM warehouses AS mgr
WHERE type IN (
    SELECT type FROM orders AS sale
    WHERE sale.type = mgr.type
);


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

SELECT name FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.code = srvc.code
);


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

SELECT value FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.status = mgr.status
);


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

SELECT id FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = empl.id
);


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

SELECT code FROM transactions AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM regions AS sale
    WHERE sale.level = mgr.level
);


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

SELECT amount FROM tasks AS ord
WHERE code IN (
    SELECT code FROM suppliers AS empl
    WHERE empl.id = ord.id
);


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

SELECT id FROM products AS sale
WHERE id IN (
    SELECT id FROM shipments AS srvc
    WHERE srvc.id = sale.id
);


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

SELECT name FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.id = prod.id
);


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

SELECT amount FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.code = srvc.code
);


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

SELECT code FROM invoices AS empl
WHERE id IN (
    SELECT id FROM categories AS cust
    WHERE cust.status = empl.status
);


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

SELECT value FROM transactions AS lne
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS prod
    WHERE prod.type = lne.type
);


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

SELECT amount FROM tasks AS srvc
WHERE value > (
    SELECT MIN(value) FROM customers AS txn
    WHERE txn.type = srvc.type
);


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

SELECT value FROM transactions AS emp
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS prod
    WHERE prod.code = emp.code
);


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

SELECT name FROM accounts AS rgn
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT name FROM orders AS budg
WHERE id IN (
    SELECT id FROM suppliers AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT id FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.code = catg.code
);


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

SELECT value FROM transactions AS whs
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.status = whs.status
);


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

SELECT value FROM categories AS whs
WHERE id IN (
    SELECT id FROM transactions AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT name FROM invoices AS lne
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT value FROM employees AS empl
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS ordr
    WHERE ordr.id = empl.id
);


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

SELECT id FROM departments AS budg
WHERE level IN (
    SELECT level FROM regions AS dept
    WHERE dept.code = budg.code
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.type = txn.type
);


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

SELECT amount FROM invoices AS ord
WHERE amount > (
    SELECT MAX(amount) FROM departments AS inv
    WHERE inv.type = ord.type
);


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

SELECT value FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.id = srvc.id
);


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

SELECT name FROM projects AS lne
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS acct
    WHERE acct.type = lne.type
);