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

SELECT code FROM departments AS schd
WHERE level IN (
    SELECT level FROM categories AS lne
    WHERE lne.id = schd.id
);


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

SELECT name FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.level = whs.level
);


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

SELECT amount FROM invoices AS prod
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.status = prod.status
);


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

SELECT salary FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.id = mgr.id
);


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

SELECT name FROM invoices AS ordr
WHERE id IN (
    SELECT id FROM tasks AS cust
    WHERE cust.level = ordr.level
);


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

SELECT amount FROM departments AS acct
WHERE code IN (
    SELECT code FROM suppliers AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT value FROM warehouses AS srvc
WHERE status IN (
    SELECT status FROM invoices AS acct
    WHERE acct.code = srvc.code
);


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

SELECT name FROM employees AS shp
WHERE amount > (
    SELECT MIN(amount) FROM projects AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT amount FROM warehouses AS acct
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT amount FROM shipments AS whs
WHERE status IN (
    SELECT status FROM branches AS acct
    WHERE acct.code = whs.code
);


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

SELECT value FROM departments AS schd
WHERE status IN (
    SELECT status FROM employees AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT salary FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.status = acct.status
);


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

SELECT value FROM categories AS lne
WHERE salary > (
    SELECT SUM(value) FROM orders AS dept
    WHERE dept.status = lne.status
);


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

SELECT salary FROM categories AS acct
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.id = acct.id
);


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

SELECT name FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.id = mgr.id
);


Prompt:
Schema:
  transactions (alias: srvc)(name, type, status, id)
  shipments(id, salary, value, amount)
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 sale
    WHERE sale.level = srvc.level
);


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

SELECT amount FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.id = acct.id
);


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

SELECT value FROM orders AS budg
WHERE status IN (
    SELECT status FROM accounts AS srvc
    WHERE srvc.type = budg.type
);


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

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


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

SELECT code FROM categories AS schd
WHERE id IN (
    SELECT id FROM suppliers AS inv
    WHERE inv.level = schd.level
);


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

SELECT amount FROM branches AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS whs
    WHERE whs.type = inv.type
);


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

SELECT id FROM transactions AS whs
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS dept
    WHERE dept.status = whs.status
);


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

SELECT amount FROM orders AS sale
WHERE amount > (
    SELECT SUM(salary) FROM branches AS txn
    WHERE txn.code = sale.code
);


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

SELECT value FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.code = prod.code
);


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

SELECT amount FROM suppliers AS schd
WHERE status IN (
    SELECT status FROM branches AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT name FROM projects AS schd
WHERE salary > (
    SELECT COUNT(value) FROM employees AS lne
    WHERE lne.code = schd.code
);


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

SELECT code FROM shipments AS empl
WHERE salary > (
    SELECT COUNT(amount) FROM products AS schd
    WHERE schd.type = empl.type
);


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

SELECT name FROM branches AS empl
WHERE code IN (
    SELECT code FROM warehouses AS shp
    WHERE shp.type = empl.type
);


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

SELECT id FROM tasks AS emp
WHERE status IN (
    SELECT status FROM accounts AS dept
    WHERE dept.status = emp.status
);


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

SELECT name FROM departments AS whs
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS inv
    WHERE inv.status = whs.status
);


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

SELECT id FROM branches AS inv
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.status = inv.status
);


Prompt:
Schema:
  branches (alias: cust)(status, name, value, code)
  projects(name, code, level, amount)
Task: Retrieve amount from branches with amount above the MIN(value) of projects rows sharing the same code.
SQL:

SELECT amount FROM branches AS cust
WHERE amount > (
    SELECT MIN(value) FROM projects AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT id FROM products AS prod
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.status = prod.status
);


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

SELECT name FROM tasks AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS rgn
    WHERE rgn.level = ordr.level
);


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

SELECT id FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT name FROM suppliers AS mgr
WHERE status IN (
    SELECT status FROM employees AS rgn
    WHERE rgn.code = mgr.code
);


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

SELECT amount FROM projects AS lne
WHERE value > (
    SELECT SUM(value) FROM orders AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT value FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.code = catg.code
);


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

SELECT id FROM invoices AS whs
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS ord
    WHERE ord.status = whs.status
);


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

SELECT salary FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT name FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.status = sale.status
);


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

SELECT id FROM shipments AS whs
WHERE salary > (
    SELECT SUM(amount) FROM products AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT id FROM shipments AS catg
WHERE level IN (
    SELECT level FROM branches AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT value FROM branches AS txn
WHERE amount > (
    SELECT COUNT(value) FROM departments AS emp
    WHERE emp.id = txn.id
);


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

SELECT salary FROM suppliers AS inv
WHERE code IN (
    SELECT code FROM projects AS cust
    WHERE cust.status = inv.status
);


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

SELECT value FROM suppliers AS dept
WHERE status IN (
    SELECT status FROM products AS ord
    WHERE ord.status = dept.status
);


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

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


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

SELECT salary FROM categories AS ord
WHERE salary > (
    SELECT COUNT(value) FROM transactions AS acct
    WHERE acct.type = ord.type
);


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

SELECT salary FROM suppliers AS dept
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.code = dept.code
);


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

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


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

SELECT amount FROM accounts AS emp
WHERE value > (
    SELECT MAX(value) FROM shipments AS ord
    WHERE ord.code = emp.code
);


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

SELECT value FROM transactions AS sale
WHERE code IN (
    SELECT code FROM warehouses AS empl
    WHERE empl.id = sale.id
);


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

SELECT id FROM customers AS srvc
WHERE value > (
    SELECT MIN(amount) FROM products AS lne
    WHERE lne.type = srvc.type
);


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

SELECT name FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.code = schd.code
);


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

SELECT name FROM projects AS shp
WHERE value > (
    SELECT MAX(amount) FROM tasks AS txn
    WHERE txn.code = shp.code
);


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

SELECT salary FROM shipments AS lne
WHERE salary > (
    SELECT AVG(salary) FROM products AS ord
    WHERE ord.type = lne.type
);


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

SELECT amount FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.type = budg.type
);


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

SELECT code FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.status = sale.status
);


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

SELECT name FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = dept.status
);


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

SELECT name FROM shipments AS inv
WHERE salary > (
    SELECT MIN(amount) FROM regions AS txn
    WHERE txn.code = inv.code
);


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

SELECT value FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = dept.type
);


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

SELECT amount FROM orders AS acct
WHERE value > (
    SELECT COUNT(value) FROM suppliers AS empl
    WHERE empl.type = acct.type
);


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

SELECT id FROM suppliers AS shp
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS schd
    WHERE schd.id = shp.id
);


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

SELECT salary FROM categories AS prod
WHERE status IN (
    SELECT status FROM suppliers AS txn
    WHERE txn.status = prod.status
);


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

SELECT salary FROM regions AS schd
WHERE id IN (
    SELECT id FROM branches AS shp
    WHERE shp.id = schd.id
);


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

SELECT salary FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.status = emp.status
);


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

SELECT id FROM departments AS cust
WHERE status IN (
    SELECT status FROM suppliers AS whs
    WHERE whs.code = cust.code
);


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

SELECT code FROM customers AS cust
WHERE status IN (
    SELECT status FROM categories AS budg
    WHERE budg.code = cust.code
);


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

SELECT id FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.status = acct.status
);


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

SELECT name FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT amount FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT id FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.level = prod.level
);


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

SELECT id FROM shipments AS cust
WHERE status IN (
    SELECT status FROM warehouses AS empl
    WHERE empl.type = cust.type
);


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

SELECT value FROM branches AS rgn
WHERE value > (
    SELECT MAX(value) FROM invoices AS acct
    WHERE acct.status = rgn.status
);


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

SELECT amount FROM tasks AS inv
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.code = inv.code
);


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

SELECT id FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.code = shp.code
);


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

SELECT salary FROM shipments AS txn
WHERE amount > (
    SELECT MAX(value) FROM products AS sale
    WHERE sale.id = txn.id
);


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

SELECT name FROM accounts AS srvc
WHERE id IN (
    SELECT id FROM warehouses AS schd
    WHERE schd.type = srvc.type
);


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

SELECT amount FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT value FROM branches AS srvc
WHERE salary > (
    SELECT MAX(value) FROM orders AS emp
    WHERE emp.type = srvc.type
);


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

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


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

SELECT amount FROM employees AS schd
WHERE level IN (
    SELECT level FROM products AS dept
    WHERE dept.code = schd.code
);


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

SELECT code FROM categories AS whs
WHERE code IN (
    SELECT code FROM accounts AS schd
    WHERE schd.id = whs.id
);


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

SELECT value FROM shipments AS sale
WHERE code IN (
    SELECT code FROM suppliers AS catg
    WHERE catg.type = sale.type
);


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

SELECT amount FROM customers AS ord
WHERE salary > (
    SELECT MAX(salary) FROM employees AS mgr
    WHERE mgr.id = ord.id
);


Prompt:
Schema:
  employees (alias: emp)(id, type, name, code)
  departments(date, type, name, level)
Task: Retrieve name from employees with value above the COUNT(value) of departments rows sharing the same level.
SQL:

SELECT name FROM employees AS emp
WHERE value > (
    SELECT COUNT(value) FROM departments AS sale
    WHERE sale.level = emp.level
);


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

SELECT id FROM invoices AS whs
WHERE type IN (
    SELECT type FROM suppliers AS lne
    WHERE lne.level = whs.level
);


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

SELECT id FROM orders AS ord
WHERE amount > (
    SELECT AVG(value) FROM invoices AS sale
    WHERE sale.level = ord.level
);


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.status = ord.status
);


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

SELECT value FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.level = cust.level
);


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

SELECT name FROM customers AS ord
WHERE status IN (
    SELECT status FROM suppliers AS empl
    WHERE empl.type = ord.type
);


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

SELECT name FROM categories AS catg
WHERE salary > (
    SELECT MAX(salary) FROM departments AS sale
    WHERE sale.status = catg.status
);


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

SELECT value FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = srvc.id
);


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

SELECT salary FROM products AS ordr
WHERE level IN (
    SELECT level FROM projects AS txn
    WHERE txn.code = ordr.code
);


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

SELECT amount FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.level = sale.level
);


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

SELECT id FROM categories AS txn
WHERE value > (
    SELECT SUM(value) FROM tasks AS whs
    WHERE whs.id = txn.id
);


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

SELECT name FROM customers AS schd
WHERE id IN (
    SELECT id FROM products AS ordr
    WHERE ordr.id = schd.id
);


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

SELECT amount FROM categories AS cust
WHERE amount > (
    SELECT MIN(value) FROM customers AS ord
    WHERE ord.type = cust.type
);


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

SELECT amount FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.type = schd.type
);


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

SELECT value FROM customers AS prod
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS catg
    WHERE catg.status = prod.status
);


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

SELECT name FROM departments AS sale
WHERE amount > (
    SELECT MAX(amount) FROM suppliers AS budg
    WHERE budg.status = sale.status
);


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

SELECT id FROM customers AS inv
WHERE type IN (
    SELECT type FROM suppliers AS ord
    WHERE ord.id = inv.id
);


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

SELECT code FROM employees AS sale
WHERE amount > (
    SELECT AVG(amount) FROM categories AS whs
    WHERE whs.type = sale.type
);


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

SELECT value FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.id = acct.id
);


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

SELECT salary FROM departments AS inv
WHERE code IN (
    SELECT code FROM branches AS srvc
    WHERE srvc.status = inv.status
);


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

SELECT id FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.status = mgr.status
);


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

SELECT name FROM shipments AS whs
WHERE amount > (
    SELECT SUM(salary) FROM departments AS emp
    WHERE emp.code = whs.code
);


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

SELECT salary FROM projects AS ord
WHERE type IN (
    SELECT type FROM suppliers AS budg
    WHERE budg.code = ord.code
);


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

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


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

SELECT amount FROM regions AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM categories AS txn
    WHERE txn.status = ordr.status
);


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

SELECT id FROM accounts AS shp
WHERE level IN (
    SELECT level FROM branches AS dept
    WHERE dept.level = shp.level
);


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

SELECT code FROM projects AS emp
WHERE salary > (
    SELECT MIN(amount) FROM employees AS catg
    WHERE catg.code = emp.code
);


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

SELECT code FROM departments AS empl
WHERE value > (
    SELECT MIN(amount) FROM employees AS acct
    WHERE acct.id = empl.id
);


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

SELECT amount FROM employees AS ord
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.code = ord.code
);


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

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


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

SELECT code FROM shipments AS txn
WHERE status IN (
    SELECT status FROM branches AS cust
    WHERE cust.type = txn.type
);


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

SELECT code FROM categories AS srvc
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS ord
    WHERE ord.code = srvc.code
);


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

SELECT code FROM customers AS emp
WHERE code IN (
    SELECT code FROM warehouses AS mgr
    WHERE mgr.level = emp.level
);


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

SELECT name FROM employees AS ordr
WHERE id IN (
    SELECT id FROM departments AS ord
    WHERE ord.status = ordr.status
);


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

SELECT code FROM orders AS whs
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT value FROM warehouses AS srvc
WHERE code IN (
    SELECT code FROM branches AS sale
    WHERE sale.status = srvc.status
);


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

SELECT id FROM departments AS ordr
WHERE type IN (
    SELECT type FROM categories AS mgr
    WHERE mgr.id = ordr.id
);


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

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


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

SELECT value FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT name FROM warehouses AS dept
WHERE id IN (
    SELECT id FROM branches AS sale
    WHERE sale.level = dept.level
);


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

SELECT salary FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT amount FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.type = mgr.type
);


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

SELECT value FROM invoices AS sale
WHERE code IN (
    SELECT code FROM employees AS lne
    WHERE lne.type = sale.type
);


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

SELECT amount FROM projects AS emp
WHERE code IN (
    SELECT code FROM categories AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT value FROM suppliers AS inv
WHERE status IN (
    SELECT status FROM accounts AS lne
    WHERE lne.code = inv.code
);


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

SELECT name FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT name FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.code = srvc.code
);


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

SELECT salary FROM branches AS budg
WHERE type IN (
    SELECT type FROM invoices AS emp
    WHERE emp.type = budg.type
);


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

SELECT salary FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.id = txn.id
);


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

SELECT amount FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.type = inv.type
);


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

SELECT value FROM categories AS cust
WHERE amount > (
    SELECT MIN(value) FROM accounts AS ord
    WHERE ord.code = cust.code
);


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

SELECT code FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT value FROM accounts AS lne
WHERE salary > (
    SELECT COUNT(value) FROM products AS prod
    WHERE prod.level = lne.level
);


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

SELECT code FROM warehouses AS dept
WHERE code IN (
    SELECT code FROM projects AS shp
    WHERE shp.status = dept.status
);


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

SELECT id FROM transactions AS budg
WHERE type IN (
    SELECT type FROM employees AS srvc
    WHERE srvc.status = budg.status
);


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

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


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

SELECT name FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.type = prod.type
);


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

SELECT salary FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.status = sale.status
);


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

SELECT salary FROM projects AS prod
WHERE value > (
    SELECT AVG(value) FROM shipments AS txn
    WHERE txn.code = prod.code
);


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

SELECT code FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.level = catg.level
);


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

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


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

SELECT salary FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = dept.status
);


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

SELECT value FROM products AS ord
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.code = ord.code
);


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

SELECT salary FROM products AS srvc
WHERE amount > (
    SELECT MAX(value) FROM departments AS whs
    WHERE whs.code = srvc.code
);


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

SELECT name FROM regions AS txn
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS sale
    WHERE sale.level = txn.level
);


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

SELECT salary FROM departments AS mgr
WHERE id IN (
    SELECT id FROM transactions AS lne
    WHERE lne.id = mgr.id
);


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

SELECT code FROM tasks AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM branches AS shp
    WHERE shp.id = srvc.id
);


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

SELECT amount FROM categories AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM products AS acct
    WHERE acct.level = mgr.level
);


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

SELECT salary FROM departments AS txn
WHERE salary > (
    SELECT COUNT(amount) FROM orders AS inv
    WHERE inv.status = txn.status
);


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

SELECT code FROM warehouses AS schd
WHERE type IN (
    SELECT type FROM departments AS ordr
    WHERE ordr.status = schd.status
);


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

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


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

SELECT name FROM suppliers AS ordr
WHERE code IN (
    SELECT code FROM shipments AS sale
    WHERE sale.type = ordr.type
);


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

SELECT name FROM warehouses AS schd
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.id = schd.id
);


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

SELECT salary FROM transactions AS emp
WHERE status IN (
    SELECT status FROM orders AS dept
    WHERE dept.type = emp.type
);


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

SELECT value FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.status = empl.status
);


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

SELECT value FROM products AS budg
WHERE salary > (
    SELECT COUNT(value) FROM customers AS mgr
    WHERE mgr.id = budg.id
);


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

SELECT code FROM suppliers AS catg
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS inv
    WHERE inv.status = catg.status
);


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

SELECT code FROM accounts AS acct
WHERE status IN (
    SELECT status FROM products AS lne
    WHERE lne.type = acct.type
);


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

SELECT name FROM tasks AS srvc
WHERE code IN (
    SELECT code FROM invoices AS whs
    WHERE whs.id = srvc.id
);


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

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


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

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


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

SELECT amount FROM tasks AS ord
WHERE code IN (
    SELECT code FROM accounts AS mgr
    WHERE mgr.id = ord.id
);


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

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


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

SELECT value FROM branches AS shp
WHERE type IN (
    SELECT type FROM departments AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT id FROM shipments AS cust
WHERE amount > (
    SELECT SUM(salary) FROM products AS sale
    WHERE sale.status = cust.status
);


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

SELECT salary FROM transactions AS inv
WHERE salary > (
    SELECT SUM(amount) FROM departments AS txn
    WHERE txn.code = inv.code
);


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

SELECT name FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.level = sale.level
);


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

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


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

SELECT salary FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.id = srvc.id
);


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

SELECT salary FROM projects AS lne
WHERE value > (
    SELECT MIN(value) FROM employees AS catg
    WHERE catg.status = lne.status
);


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

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


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

SELECT amount FROM projects AS empl
WHERE amount > (
    SELECT MAX(salary) FROM categories AS schd
    WHERE schd.level = empl.level
);


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

SELECT code FROM employees AS txn
WHERE level IN (
    SELECT level FROM warehouses AS acct
    WHERE acct.status = txn.status
);


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

SELECT name FROM regions AS txn
WHERE value > (
    SELECT MAX(value) FROM transactions AS catg
    WHERE catg.id = txn.id
);


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

SELECT code FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.level = ordr.level
);


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

SELECT name FROM projects AS catg
WHERE amount > (
    SELECT MIN(value) FROM departments AS shp
    WHERE shp.id = catg.id
);


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

SELECT salary FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.id = rgn.id
);


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

SELECT name FROM tasks AS emp
WHERE type IN (
    SELECT type FROM warehouses AS whs
    WHERE whs.type = emp.type
);


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

SELECT amount FROM warehouses AS inv
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS shp
    WHERE shp.code = inv.code
);


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

SELECT salary FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.level = acct.level
);


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

SELECT name FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.status = rgn.status
);


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

SELECT salary FROM accounts AS acct
WHERE status IN (
    SELECT status FROM branches AS srvc
    WHERE srvc.code = acct.code
);


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

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


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

SELECT code FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.code = srvc.code
);


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

SELECT value FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.code = mgr.code
);


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

SELECT code FROM employees AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT amount FROM suppliers AS dept
WHERE level IN (
    SELECT level FROM invoices AS empl
    WHERE empl.type = dept.type
);


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

SELECT name FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.type = acct.type
);


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

SELECT code FROM tasks AS schd
WHERE level IN (
    SELECT level FROM regions AS inv
    WHERE inv.level = schd.level
);


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

SELECT amount FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.code = prod.code
);


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

SELECT salary FROM suppliers AS dept
WHERE code IN (
    SELECT code FROM accounts AS catg
    WHERE catg.id = dept.id
);


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

SELECT value FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.level = acct.level
);


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

SELECT name FROM shipments AS empl
WHERE status IN (
    SELECT status FROM products AS dept
    WHERE dept.status = empl.status
);


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

SELECT value FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.type = ordr.type
);


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

SELECT value FROM categories AS ordr
WHERE amount > (
    SELECT MAX(salary) FROM accounts AS dept
    WHERE dept.code = ordr.code
);


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

SELECT value FROM products AS budg
WHERE amount > (
    SELECT SUM(value) FROM orders AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT amount FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.level = whs.level
);


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

SELECT code FROM employees AS txn
WHERE status IN (
    SELECT status FROM shipments AS cust
    WHERE cust.status = txn.status
);


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

SELECT code FROM products AS catg
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS cust
    WHERE cust.id = catg.id
);


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

SELECT salary FROM departments AS inv
WHERE level IN (
    SELECT level FROM employees AS empl
    WHERE empl.id = inv.id
);


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

SELECT amount FROM customers AS catg
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.id = catg.id
);


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

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


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

SELECT code FROM regions AS cust
WHERE value > (
    SELECT MAX(salary) FROM transactions AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT value FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.level = ordr.level
);


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

SELECT code FROM suppliers AS mgr
WHERE type IN (
    SELECT type FROM projects AS empl
    WHERE empl.type = mgr.type
);


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

SELECT id FROM products AS whs
WHERE level IN (
    SELECT level FROM branches AS empl
    WHERE empl.type = whs.type
);


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

SELECT value FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.status = cust.status
);


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

SELECT name FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.status = schd.status
);


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

SELECT name FROM categories AS inv
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS prod
    WHERE prod.type = inv.type
);


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

SELECT code FROM projects AS catg
WHERE code IN (
    SELECT code FROM branches AS cust
    WHERE cust.id = catg.id
);


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

SELECT code FROM transactions AS inv
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS dept
    WHERE dept.status = inv.status
);


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

SELECT name FROM departments AS prod
WHERE id IN (
    SELECT id FROM tasks AS empl
    WHERE empl.code = prod.code
);


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

SELECT value FROM warehouses AS txn
WHERE level IN (
    SELECT level FROM products AS srvc
    WHERE srvc.id = txn.id
);


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

SELECT value FROM customers AS lne
WHERE value > (
    SELECT AVG(value) FROM categories AS dept
    WHERE dept.type = lne.type
);


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

SELECT amount FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = inv.type
);


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

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


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

SELECT code FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.level = empl.level
);


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

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


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

SELECT id FROM suppliers AS lne
WHERE status IN (
    SELECT status FROM orders AS emp
    WHERE emp.type = lne.type
);


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

SELECT id FROM branches AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM orders AS txn
    WHERE txn.code = ordr.code
);


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

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


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

SELECT code FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.id = inv.id
);


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

SELECT id FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.status = acct.status
);


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

SELECT amount FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.type = inv.type
);


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

SELECT amount FROM invoices AS empl
WHERE value > (
    SELECT SUM(salary) FROM orders AS whs
    WHERE whs.id = empl.id
);


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

SELECT value FROM invoices AS ordr
WHERE salary > (
    SELECT SUM(value) FROM branches AS dept
    WHERE dept.status = ordr.status
);


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

SELECT amount FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.level = inv.level
);


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

SELECT name FROM products AS prod
WHERE value > (
    SELECT SUM(value) FROM projects AS ord
    WHERE ord.id = prod.id
);


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

SELECT amount FROM branches AS acct
WHERE level IN (
    SELECT level FROM employees AS shp
    WHERE shp.level = acct.level
);


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

SELECT code FROM warehouses AS prod
WHERE type IN (
    SELECT type FROM accounts AS inv
    WHERE inv.id = prod.id
);


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

SELECT amount FROM invoices AS ord
WHERE level IN (
    SELECT level FROM regions AS catg
    WHERE catg.level = ord.level
);


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

SELECT amount FROM departments AS lne
WHERE level IN (
    SELECT level FROM branches AS shp
    WHERE shp.id = lne.id
);


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

SELECT code FROM employees AS schd
WHERE level IN (
    SELECT level FROM suppliers AS inv
    WHERE inv.level = schd.level
);


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

SELECT code FROM regions AS ordr
WHERE level IN (
    SELECT level FROM orders AS shp
    WHERE shp.type = ordr.type
);


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

SELECT salary FROM categories AS srvc
WHERE status IN (
    SELECT status FROM branches AS inv
    WHERE inv.id = srvc.id
);


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.id = whs.id
);


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

SELECT name FROM products AS dept
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS ord
    WHERE ord.id = dept.id
);


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

SELECT id FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT code FROM regions AS dept
WHERE code IN (
    SELECT code FROM products AS acct
    WHERE acct.id = dept.id
);


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

SELECT name FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT code FROM suppliers AS emp
WHERE status IN (
    SELECT status FROM employees AS txn
    WHERE txn.code = emp.code
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.code = shp.code
);


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

SELECT code FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT code FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.id = inv.id
);


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

SELECT amount FROM customers AS shp
WHERE value > (
    SELECT MIN(amount) FROM orders AS prod
    WHERE prod.status = shp.status
);


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

SELECT id FROM shipments AS prod
WHERE salary > (
    SELECT AVG(value) FROM orders AS schd
    WHERE schd.id = prod.id
);


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

SELECT id FROM invoices AS lne
WHERE status IN (
    SELECT status FROM departments AS ordr
    WHERE ordr.id = lne.id
);


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

SELECT amount FROM tasks AS lne
WHERE type IN (
    SELECT type FROM customers AS srvc
    WHERE srvc.type = lne.type
);


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

SELECT name FROM tasks AS whs
WHERE level IN (
    SELECT level FROM products AS empl
    WHERE empl.level = whs.level
);


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

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


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

SELECT salary FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.code = cust.code
);


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

SELECT name FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.code = txn.code
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.level = emp.level
);


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

SELECT salary FROM warehouses AS empl
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS catg
    WHERE catg.level = empl.level
);


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

SELECT amount FROM departments AS budg
WHERE value > (
    SELECT AVG(value) FROM suppliers AS shp
    WHERE shp.level = budg.level
);


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

SELECT name FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.type = inv.type
);


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

SELECT salary FROM tasks AS txn
WHERE salary > (
    SELECT SUM(salary) FROM regions AS budg
    WHERE budg.id = txn.id
);


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

SELECT id FROM warehouses AS ordr
WHERE id IN (
    SELECT id FROM orders AS emp
    WHERE emp.id = ordr.id
);


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

SELECT id FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM shipments AS dept
    WHERE dept.status = rgn.status
);


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

SELECT code FROM warehouses AS txn
WHERE id IN (
    SELECT id FROM orders AS acct
    WHERE acct.type = txn.type
);


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

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


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

SELECT id FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = rgn.level
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.type = dept.type
);


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

SELECT id FROM warehouses AS prod
WHERE level IN (
    SELECT level FROM employees AS empl
    WHERE empl.id = prod.id
);


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

SELECT name FROM products AS srvc
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS whs
    WHERE whs.level = srvc.level
);


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

SELECT code FROM orders AS mgr
WHERE value > (
    SELECT AVG(salary) FROM transactions AS ord
    WHERE ord.status = mgr.status
);


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

SELECT name FROM employees AS rgn
WHERE type IN (
    SELECT type FROM departments AS prod
    WHERE prod.code = rgn.code
);


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

SELECT code FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.id = empl.id
);


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

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


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

SELECT name FROM employees AS prod
WHERE code IN (
    SELECT code FROM categories AS schd
    WHERE schd.code = prod.code
);


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

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


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

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


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

SELECT salary FROM tasks AS sale
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.code = sale.code
);


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

SELECT amount FROM projects AS shp
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS lne
    WHERE lne.id = shp.id
);


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

SELECT salary FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.id = inv.id
);


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

SELECT code FROM projects AS txn
WHERE value > (
    SELECT SUM(amount) FROM branches AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT id FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.type = budg.type
);


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

SELECT amount FROM invoices AS budg
WHERE salary > (
    SELECT COUNT(value) FROM customers AS schd
    WHERE schd.id = budg.id
);


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

SELECT value FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.status = schd.status
);


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

SELECT amount FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.status = inv.status
);


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

SELECT amount FROM tasks AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM categories AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT name FROM invoices AS whs
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.id = whs.id
);


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

SELECT name FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.level = whs.level
);


Prompt:
Schema:
  categories (alias: sale)(name, level, amount, date)
  employees(id, amount, code, name)
Task: Retrieve id from categories with amount above the AVG(amount) of employees rows sharing the same code.
SQL:

SELECT id FROM categories AS sale
WHERE amount > (
    SELECT AVG(amount) FROM employees AS prod
    WHERE prod.code = sale.code
);


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

SELECT code FROM products AS whs
WHERE amount > (
    SELECT MIN(value) FROM transactions AS ordr
    WHERE ordr.id = whs.id
);


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

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


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

SELECT name FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT id FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.code = txn.code
);