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

SELECT name FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.type = ordr.type
);


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

SELECT id FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.type = shp.type
);


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

SELECT id FROM transactions AS ord
WHERE value > (
    SELECT COUNT(salary) FROM branches AS dept
    WHERE dept.level = ord.level
);


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

SELECT value FROM suppliers AS emp
WHERE value > (
    SELECT SUM(amount) FROM branches AS catg
    WHERE catg.code = emp.code
);


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

SELECT value FROM departments AS shp
WHERE type IN (
    SELECT type FROM suppliers AS ordr
    WHERE ordr.code = shp.code
);


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

SELECT salary FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.status = catg.status
);


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

SELECT salary FROM tasks AS budg
WHERE amount > (
    SELECT MIN(value) FROM departments AS shp
    WHERE shp.type = budg.type
);


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

SELECT salary FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.level = shp.level
);


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

SELECT amount FROM tasks AS lne
WHERE level IN (
    SELECT level FROM invoices AS shp
    WHERE shp.type = lne.type
);


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

SELECT salary FROM suppliers AS inv
WHERE id IN (
    SELECT id FROM orders AS acct
    WHERE acct.type = inv.type
);


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

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


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

SELECT salary FROM warehouses AS srvc
WHERE value > (
    SELECT MIN(amount) FROM branches AS rgn
    WHERE rgn.level = srvc.level
);


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

SELECT name FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.id = schd.id
);


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

SELECT id FROM shipments AS shp
WHERE code IN (
    SELECT code FROM regions AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT code FROM shipments AS sale
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS ordr
    WHERE ordr.type = sale.type
);


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

SELECT salary FROM products AS schd
WHERE amount > (
    SELECT MIN(salary) FROM branches AS inv
    WHERE inv.status = schd.status
);


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

SELECT salary FROM products AS acct
WHERE type IN (
    SELECT type FROM categories AS ord
    WHERE ord.status = acct.status
);


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

SELECT salary FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.status = sale.status
);


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

SELECT name FROM categories AS catg
WHERE salary > (
    SELECT MIN(value) FROM departments AS dept
    WHERE dept.type = catg.type
);


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

SELECT code FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.level = catg.level
);


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

SELECT value FROM projects AS dept
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS mgr
    WHERE mgr.id = dept.id
);


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

SELECT code FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.code = srvc.code
);


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

SELECT value FROM departments AS emp
WHERE type IN (
    SELECT type FROM orders AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT value FROM shipments AS mgr
WHERE status IN (
    SELECT status FROM regions AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT value FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.id = lne.id
);


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

SELECT amount FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.status = inv.status
);


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

SELECT salary FROM transactions AS dept
WHERE salary > (
    SELECT MAX(salary) FROM branches AS acct
    WHERE acct.status = dept.status
);


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

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


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

SELECT salary FROM customers AS schd
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT value FROM customers AS emp
WHERE type IN (
    SELECT type FROM employees AS ord
    WHERE ord.level = emp.level
);


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

SELECT amount FROM accounts AS budg
WHERE id IN (
    SELECT id FROM employees AS sale
    WHERE sale.status = budg.status
);


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

SELECT amount FROM orders AS prod
WHERE amount > (
    SELECT MAX(amount) FROM departments AS txn
    WHERE txn.id = prod.id
);


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

SELECT name FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.id = acct.id
);


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

SELECT value FROM warehouses AS mgr
WHERE type IN (
    SELECT type FROM shipments AS lne
    WHERE lne.level = mgr.level
);


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

SELECT id FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.level = rgn.level
);


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

SELECT amount FROM transactions AS txn
WHERE value > (
    SELECT AVG(amount) FROM accounts AS mgr
    WHERE mgr.type = txn.type
);


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

SELECT amount FROM departments AS budg
WHERE id IN (
    SELECT id FROM suppliers AS catg
    WHERE catg.id = budg.id
);


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

SELECT id FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.code = ordr.code
);


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

SELECT id FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.type = lne.type
);


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

SELECT code FROM orders AS rgn
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS prod
    WHERE prod.type = rgn.type
);


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

SELECT amount FROM warehouses AS lne
WHERE type IN (
    SELECT type FROM shipments AS shp
    WHERE shp.status = lne.status
);


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

SELECT amount FROM warehouses AS acct
WHERE amount > (
    SELECT AVG(amount) FROM regions AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT salary FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.status = cust.status
);


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

SELECT value FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.code = mgr.code
);


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

SELECT name FROM projects AS inv
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS txn
    WHERE txn.level = inv.level
);


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

SELECT code FROM regions AS shp
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.status = shp.status
);


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

SELECT id FROM transactions AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS cust
    WHERE cust.status = shp.status
);


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

SELECT id FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.status = emp.status
);


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

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


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

SELECT value FROM suppliers AS txn
WHERE id IN (
    SELECT id FROM transactions AS srvc
    WHERE srvc.id = txn.id
);


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

SELECT value FROM departments AS srvc
WHERE value > (
    SELECT SUM(salary) FROM transactions AS prod
    WHERE prod.status = srvc.status
);


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

SELECT id FROM orders AS rgn
WHERE amount > (
    SELECT SUM(salary) FROM projects AS shp
    WHERE shp.id = rgn.id
);


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

SELECT name FROM regions AS lne
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS whs
    WHERE whs.id = lne.id
);


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

SELECT salary FROM customers AS lne
WHERE value > (
    SELECT AVG(value) FROM branches AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT name FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.type = cust.type
);


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

SELECT name FROM customers AS txn
WHERE amount > (
    SELECT COUNT(value) FROM transactions AS ord
    WHERE ord.id = txn.id
);


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

SELECT name FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.code = ordr.code
);


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

SELECT name FROM warehouses AS dept
WHERE code IN (
    SELECT code FROM projects AS budg
    WHERE budg.level = dept.level
);


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

SELECT value FROM regions AS inv
WHERE id IN (
    SELECT id FROM projects AS lne
    WHERE lne.type = inv.type
);


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

SELECT name FROM projects AS cust
WHERE status IN (
    SELECT status FROM regions AS catg
    WHERE catg.code = cust.code
);


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

SELECT value FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.status = lne.status
);


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

SELECT amount FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.code = ordr.code
);


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

SELECT amount FROM transactions AS budg
WHERE amount > (
    SELECT SUM(value) FROM categories AS acct
    WHERE acct.id = budg.id
);


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

SELECT id FROM warehouses AS cust
WHERE status IN (
    SELECT status FROM invoices AS emp
    WHERE emp.code = cust.code
);


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

SELECT code FROM branches AS empl
WHERE value > (
    SELECT COUNT(value) FROM transactions AS sale
    WHERE sale.id = empl.id
);


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

SELECT value FROM employees AS catg
WHERE amount > (
    SELECT AVG(value) FROM categories AS empl
    WHERE empl.code = catg.code
);


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

SELECT name FROM branches AS sale
WHERE salary > (
    SELECT AVG(salary) FROM orders AS txn
    WHERE txn.type = sale.type
);


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

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


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

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


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

SELECT id FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.status = schd.status
);


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

SELECT amount FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.status = mgr.status
);


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

SELECT code FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT id FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT salary FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT code FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.type = dept.type
);


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

SELECT code FROM regions AS empl
WHERE salary > (
    SELECT AVG(value) FROM customers AS cust
    WHERE cust.level = empl.level
);


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

SELECT name FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = ordr.level
);


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

SELECT salary FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.type = mgr.type
);


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

SELECT id FROM accounts AS emp
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS dept
    WHERE dept.code = emp.code
);


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

SELECT salary FROM categories AS ordr
WHERE salary > (
    SELECT AVG(value) FROM departments AS shp
    WHERE shp.status = ordr.status
);


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

SELECT value FROM invoices AS inv
WHERE level IN (
    SELECT level FROM categories AS txn
    WHERE txn.code = inv.code
);


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

SELECT id FROM tasks AS empl
WHERE type IN (
    SELECT type FROM products AS cust
    WHERE cust.id = empl.id
);


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

SELECT name FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.code = emp.code
);


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

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


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

SELECT salary FROM regions AS empl
WHERE salary > (
    SELECT MAX(amount) FROM branches AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT id FROM suppliers AS prod
WHERE code IN (
    SELECT code FROM branches AS acct
    WHERE acct.status = prod.status
);


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

SELECT code FROM branches AS empl
WHERE code IN (
    SELECT code FROM shipments AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT code FROM projects AS ord
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.level = ord.level
);


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

SELECT amount FROM products AS prod
WHERE value > (
    SELECT MIN(value) FROM branches AS inv
    WHERE inv.id = prod.id
);


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

SELECT value FROM categories AS ord
WHERE amount > (
    SELECT AVG(amount) FROM customers AS sale
    WHERE sale.id = ord.id
);


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

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


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

SELECT salary FROM warehouses AS cust
WHERE value > (
    SELECT MIN(salary) FROM projects AS mgr
    WHERE mgr.status = cust.status
);


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

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


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

SELECT code FROM categories AS budg
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.status = budg.status
);


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

SELECT amount FROM warehouses AS shp
WHERE amount > (
    SELECT AVG(value) FROM shipments AS emp
    WHERE emp.type = shp.type
);


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

SELECT code FROM transactions AS mgr
WHERE type IN (
    SELECT type FROM departments AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT value FROM branches AS emp
WHERE level IN (
    SELECT level FROM warehouses AS whs
    WHERE whs.status = emp.status
);


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

SELECT name FROM regions AS schd
WHERE status IN (
    SELECT status FROM customers AS txn
    WHERE txn.id = schd.id
);


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

SELECT id FROM tasks AS prod
WHERE value > (
    SELECT AVG(salary) FROM categories AS lne
    WHERE lne.status = prod.status
);


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

SELECT value FROM shipments AS sale
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS shp
    WHERE shp.type = sale.type
);


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

SELECT name FROM categories AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM products AS shp
    WHERE shp.level = ordr.level
);


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

SELECT value FROM shipments AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM products AS catg
    WHERE catg.level = mgr.level
);


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

SELECT value FROM customers AS mgr
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS dept
    WHERE dept.status = mgr.status
);


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

SELECT value FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = inv.type
);


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

SELECT id FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.status = txn.status
);


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

SELECT salary FROM suppliers AS emp
WHERE type IN (
    SELECT type FROM transactions AS inv
    WHERE inv.type = emp.type
);


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

SELECT salary FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.code = catg.code
);


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

SELECT salary FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.status = lne.status
);


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

SELECT name FROM projects AS txn
WHERE type IN (
    SELECT type FROM warehouses AS lne
    WHERE lne.id = txn.id
);


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

SELECT code FROM warehouses AS srvc
WHERE level IN (
    SELECT level FROM regions AS ordr
    WHERE ordr.type = srvc.type
);


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

SELECT code FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.id = ordr.id
);


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

SELECT value FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT amount FROM accounts AS cust
WHERE amount > (
    SELECT MAX(salary) FROM regions AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT name FROM employees AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM projects AS inv
    WHERE inv.id = rgn.id
);


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

SELECT name FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT salary FROM orders AS mgr
WHERE value > (
    SELECT SUM(salary) FROM employees AS emp
    WHERE emp.id = mgr.id
);


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

SELECT name FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.code = srvc.code
);


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

SELECT code FROM transactions AS budg
WHERE amount > (
    SELECT MIN(value) FROM orders AS lne
    WHERE lne.type = budg.type
);


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

SELECT amount FROM customers AS cust
WHERE type IN (
    SELECT type FROM shipments AS txn
    WHERE txn.id = cust.id
);


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

SELECT salary FROM categories AS schd
WHERE level IN (
    SELECT level FROM customers AS dept
    WHERE dept.status = schd.status
);


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

SELECT id FROM warehouses AS rgn
WHERE value > (
    SELECT MIN(salary) FROM invoices AS lne
    WHERE lne.id = rgn.id
);


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

SELECT salary FROM projects AS mgr
WHERE value > (
    SELECT MIN(salary) FROM invoices AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT code FROM warehouses AS inv
WHERE salary > (
    SELECT MAX(value) FROM products AS cust
    WHERE cust.type = inv.type
);


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

SELECT value FROM employees AS empl
WHERE level IN (
    SELECT level FROM categories AS budg
    WHERE budg.code = empl.code
);


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

SELECT name FROM employees AS emp
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS sale
    WHERE sale.id = emp.id
);


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

SELECT value FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.type = txn.type
);


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

SELECT value FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.status = prod.status
);


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

SELECT name FROM departments AS mgr
WHERE amount > (
    SELECT AVG(value) FROM invoices AS sale
    WHERE sale.type = mgr.type
);


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

SELECT salary FROM warehouses AS dept
WHERE code IN (
    SELECT code FROM customers AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT code FROM orders AS schd
WHERE code IN (
    SELECT code FROM branches AS prod
    WHERE prod.id = schd.id
);


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

SELECT id FROM shipments AS empl
WHERE level IN (
    SELECT level FROM employees AS cust
    WHERE cust.code = empl.code
);


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

SELECT code FROM orders AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS catg
    WHERE catg.type = mgr.type
);


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

SELECT value FROM tasks AS catg
WHERE level IN (
    SELECT level FROM categories AS txn
    WHERE txn.type = catg.type
);


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

SELECT amount FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.type = sale.type
);


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

SELECT value FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.level = schd.level
);


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

SELECT code FROM transactions AS empl
WHERE id IN (
    SELECT id FROM regions AS ord
    WHERE ord.status = empl.status
);


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

SELECT code FROM branches AS mgr
WHERE type IN (
    SELECT type FROM projects AS inv
    WHERE inv.status = mgr.status
);


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

SELECT value FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = acct.status
);


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

SELECT value FROM departments AS prod
WHERE amount > (
    SELECT SUM(salary) FROM employees AS sale
    WHERE sale.code = prod.code
);


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

SELECT salary FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.status = shp.status
);


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

SELECT value FROM shipments AS rgn
WHERE value > (
    SELECT MAX(salary) FROM products AS schd
    WHERE schd.code = rgn.code
);


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

SELECT amount FROM products AS mgr
WHERE code IN (
    SELECT code FROM customers AS shp
    WHERE shp.status = mgr.status
);


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

SELECT value FROM accounts AS prod
WHERE level IN (
    SELECT level FROM invoices AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT id FROM projects AS prod
WHERE code IN (
    SELECT code FROM regions AS empl
    WHERE empl.code = prod.code
);


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

SELECT code FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.id = empl.id
);


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

SELECT name FROM categories AS empl
WHERE id IN (
    SELECT id FROM branches AS lne
    WHERE lne.level = empl.level
);


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

SELECT value FROM transactions AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM customers AS cust
    WHERE cust.type = catg.type
);


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

SELECT value FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.type = mgr.type
);


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

SELECT name FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.id = prod.id
);


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

SELECT id FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.id = srvc.id
);


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

SELECT amount FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.status = srvc.status
);


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

SELECT code FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = prod.status
);


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

SELECT code FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = txn.status
);


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

SELECT amount FROM suppliers AS catg
WHERE value > (
    SELECT MAX(value) FROM invoices AS dept
    WHERE dept.code = catg.code
);


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

SELECT salary FROM invoices AS rgn
WHERE value > (
    SELECT COUNT(amount) FROM categories AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT id FROM invoices AS emp
WHERE type IN (
    SELECT type FROM tasks AS schd
    WHERE schd.code = emp.code
);


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

SELECT value FROM projects AS srvc
WHERE code IN (
    SELECT code FROM invoices AS catg
    WHERE catg.status = srvc.status
);


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

SELECT code FROM categories AS catg
WHERE id IN (
    SELECT id FROM projects AS dept
    WHERE dept.code = catg.code
);


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

SELECT salary FROM categories AS catg
WHERE level IN (
    SELECT level FROM customers AS schd
    WHERE schd.status = catg.status
);


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

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


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

SELECT salary FROM transactions AS emp
WHERE status IN (
    SELECT status FROM customers AS schd
    WHERE schd.type = emp.type
);


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

SELECT code FROM projects AS ord
WHERE level IN (
    SELECT level FROM tasks AS whs
    WHERE whs.level = ord.level
);


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

SELECT value FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.status = schd.status
);


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

SELECT id FROM customers AS cust
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS ord
    WHERE ord.code = cust.code
);


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

SELECT code FROM warehouses AS shp
WHERE amount > (
    SELECT SUM(salary) FROM employees AS sale
    WHERE sale.status = shp.status
);


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

SELECT code FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.status = shp.status
);


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

SELECT salary FROM invoices AS dept
WHERE status IN (
    SELECT status FROM regions AS whs
    WHERE whs.status = dept.status
);


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

SELECT salary FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.code = cust.code
);


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

SELECT salary FROM suppliers AS mgr
WHERE value > (
    SELECT AVG(amount) FROM departments AS acct
    WHERE acct.status = mgr.status
);


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

SELECT id FROM warehouses AS ord
WHERE salary > (
    SELECT SUM(amount) FROM projects AS ordr
    WHERE ordr.status = ord.status
);


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

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


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

SELECT id FROM regions AS dept
WHERE id IN (
    SELECT id FROM invoices AS cust
    WHERE cust.status = dept.status
);


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

SELECT name FROM branches AS emp
WHERE level IN (
    SELECT level FROM invoices AS prod
    WHERE prod.id = emp.id
);


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

SELECT value FROM employees AS budg
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS catg
    WHERE catg.level = budg.level
);


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

SELECT amount FROM invoices AS ord
WHERE status IN (
    SELECT status FROM categories AS txn
    WHERE txn.status = ord.status
);


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

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


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

SELECT id FROM categories AS shp
WHERE status IN (
    SELECT status FROM transactions AS inv
    WHERE inv.code = shp.code
);


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

SELECT code FROM branches AS schd
WHERE id IN (
    SELECT id FROM products AS lne
    WHERE lne.code = schd.code
);


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

SELECT id FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.status = whs.status
);


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

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


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

SELECT amount FROM categories AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS shp
    WHERE shp.code = lne.code
);


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

SELECT amount FROM invoices AS inv
WHERE level IN (
    SELECT level FROM departments AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT amount FROM accounts AS mgr
WHERE code IN (
    SELECT code FROM projects AS lne
    WHERE lne.code = mgr.code
);


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

SELECT value FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.level = dept.level
);


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

SELECT id FROM shipments AS schd
WHERE amount > (
    SELECT SUM(amount) FROM branches AS empl
    WHERE empl.id = schd.id
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.level = shp.level
);


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

SELECT salary FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.id = srvc.id
);


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

SELECT amount FROM customers AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM orders AS emp
    WHERE emp.status = rgn.status
);


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

SELECT name FROM categories AS acct
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS budg
    WHERE budg.level = acct.level
);


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

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


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

SELECT code FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = catg.status
);


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

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


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

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


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

SELECT name FROM suppliers AS acct
WHERE salary > (
    SELECT MIN(amount) FROM categories AS budg
    WHERE budg.id = acct.id
);


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

SELECT id FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT salary FROM categories AS cust
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.id = cust.id
);


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

SELECT id FROM suppliers AS acct
WHERE status IN (
    SELECT status FROM invoices AS whs
    WHERE whs.level = acct.level
);


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

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


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

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


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

SELECT code FROM warehouses AS schd
WHERE id IN (
    SELECT id FROM invoices AS inv
    WHERE inv.level = schd.level
);


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

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


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

SELECT salary FROM tasks AS budg
WHERE value > (
    SELECT COUNT(value) FROM transactions AS shp
    WHERE shp.level = budg.level
);


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

SELECT value FROM products AS rgn
WHERE status IN (
    SELECT status FROM employees AS lne
    WHERE lne.type = rgn.type
);


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

SELECT id FROM products AS catg
WHERE amount > (
    SELECT SUM(value) FROM orders AS empl
    WHERE empl.type = catg.type
);


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

SELECT amount FROM transactions AS mgr
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT name FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT id FROM accounts AS empl
WHERE level IN (
    SELECT level FROM suppliers AS lne
    WHERE lne.type = empl.type
);


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

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


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

SELECT value FROM categories AS lne
WHERE value > (
    SELECT COUNT(value) FROM regions AS ord
    WHERE ord.type = lne.type
);


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

SELECT id FROM departments AS ord
WHERE amount > (
    SELECT AVG(amount) FROM accounts AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT name FROM employees AS lne
WHERE value > (
    SELECT COUNT(salary) FROM orders AS txn
    WHERE txn.type = lne.type
);


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

SELECT code FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.level = emp.level
);


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

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


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

SELECT value FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM tasks AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT code FROM departments AS lne
WHERE amount > (
    SELECT MIN(salary) FROM employees AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT name FROM branches AS inv
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS lne
    WHERE lne.code = inv.code
);


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

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


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

SELECT name FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.level = acct.level
);


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

SELECT salary FROM customers AS budg
WHERE type IN (
    SELECT type FROM orders AS txn
    WHERE txn.id = budg.id
);


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

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


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

SELECT salary FROM invoices AS shp
WHERE code IN (
    SELECT code FROM warehouses AS emp
    WHERE emp.type = shp.type
);


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

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


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

SELECT value FROM shipments AS mgr
WHERE id IN (
    SELECT id FROM products AS emp
    WHERE emp.type = mgr.type
);


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

SELECT name FROM transactions AS ord
WHERE id IN (
    SELECT id FROM tasks AS srvc
    WHERE srvc.code = ord.code
);


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

SELECT value FROM regions AS prod
WHERE code IN (
    SELECT code FROM departments AS budg
    WHERE budg.level = prod.level
);


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

SELECT amount FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.type = lne.type
);


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

SELECT salary FROM products AS inv
WHERE code IN (
    SELECT code FROM shipments AS acct
    WHERE acct.status = inv.status
);


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

SELECT value FROM customers AS txn
WHERE code IN (
    SELECT code FROM invoices AS empl
    WHERE empl.status = txn.status
);


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

SELECT name FROM employees AS lne
WHERE salary > (
    SELECT SUM(salary) FROM projects AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT value FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = mgr.id
);


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

SELECT name FROM customers AS whs
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT code FROM invoices AS empl
WHERE value > (
    SELECT MIN(salary) FROM employees AS cust
    WHERE cust.status = empl.status
);


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

SELECT amount FROM invoices AS dept
WHERE status IN (
    SELECT status FROM accounts AS schd
    WHERE schd.id = dept.id
);


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

SELECT code FROM suppliers AS shp
WHERE id IN (
    SELECT id FROM regions AS acct
    WHERE acct.id = shp.id
);


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

SELECT value FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.code = emp.code
);


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

SELECT value FROM tasks AS schd
WHERE value > (
    SELECT MIN(amount) FROM invoices AS inv
    WHERE inv.type = schd.type
);


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.type = dept.type
);


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

SELECT name FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.type = cust.type
);


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

SELECT code FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.id = budg.id
);


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

SELECT salary FROM invoices AS catg
WHERE salary > (
    SELECT MAX(amount) FROM regions AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT id FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = inv.status
);


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

SELECT code FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.status = prod.status
);


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

SELECT name FROM tasks AS txn
WHERE level IN (
    SELECT level FROM invoices AS lne
    WHERE lne.level = txn.level
);


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

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


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

SELECT code FROM invoices AS shp
WHERE value > (
    SELECT MAX(salary) FROM categories AS schd
    WHERE schd.level = shp.level
);


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

SELECT id FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.code = shp.code
);


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

SELECT code FROM transactions AS shp
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.type = shp.type
);


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

SELECT name FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT code FROM tasks AS sale
WHERE level IN (
    SELECT level FROM products AS shp
    WHERE shp.type = sale.type
);


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

SELECT amount FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.id = ordr.id
);


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

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


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

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


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

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


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

SELECT name FROM transactions AS budg
WHERE salary > (
    SELECT MAX(amount) FROM products AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT code FROM orders AS txn
WHERE level IN (
    SELECT level FROM transactions AS acct
    WHERE acct.status = txn.status
);


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

SELECT amount FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT amount FROM regions AS cust
WHERE type IN (
    SELECT type FROM transactions AS dept
    WHERE dept.status = cust.status
);


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

SELECT name FROM warehouses AS dept
WHERE level IN (
    SELECT level FROM shipments AS empl
    WHERE empl.id = dept.id
);


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

SELECT code FROM warehouses AS srvc
WHERE value > (
    SELECT COUNT(salary) FROM categories AS shp
    WHERE shp.code = srvc.code
);


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

SELECT value FROM shipments AS shp
WHERE amount > (
    SELECT AVG(value) FROM employees AS whs
    WHERE whs.status = shp.status
);


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

SELECT amount FROM products AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM warehouses AS emp
    WHERE emp.level = ord.level
);


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

SELECT code FROM employees AS srvc
WHERE level IN (
    SELECT level FROM departments AS rgn
    WHERE rgn.level = srvc.level
);


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

SELECT code FROM customers AS budg
WHERE amount > (
    SELECT MAX(value) FROM regions AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT amount FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.code = catg.code
);


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

SELECT id FROM invoices AS schd
WHERE level IN (
    SELECT level FROM customers AS ord
    WHERE ord.code = schd.code
);


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

SELECT code FROM shipments AS acct
WHERE type IN (
    SELECT type FROM warehouses AS dept
    WHERE dept.type = acct.type
);


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

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


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

SELECT code FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.status = budg.status
);


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

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


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

SELECT salary FROM employees AS acct
WHERE value > (
    SELECT MAX(salary) FROM shipments AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT id FROM suppliers AS ord
WHERE type IN (
    SELECT type FROM accounts AS catg
    WHERE catg.code = ord.code
);


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

SELECT salary FROM invoices AS ord
WHERE code IN (
    SELECT code FROM transactions AS whs
    WHERE whs.code = ord.code
);


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

SELECT id FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.status = schd.status
);


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

SELECT value FROM accounts AS ord
WHERE amount > (
    SELECT MIN(salary) FROM projects AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT salary FROM customers AS txn
WHERE level IN (
    SELECT level FROM orders AS empl
    WHERE empl.code = txn.code
);


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

SELECT id FROM customers AS inv
WHERE level IN (
    SELECT level FROM invoices AS emp
    WHERE emp.status = inv.status
);


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

SELECT value FROM departments AS emp
WHERE amount > (
    SELECT MAX(value) FROM projects AS catg
    WHERE catg.id = emp.id
);


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

SELECT amount FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.id = prod.id
);


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

SELECT name FROM transactions AS dept
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS schd
    WHERE schd.level = dept.level
);


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

SELECT code FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT amount FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.type = acct.type
);


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

SELECT code FROM orders AS prod
WHERE value > (
    SELECT MIN(value) FROM products AS dept
    WHERE dept.status = prod.status
);


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

SELECT salary FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.level = ord.level
);


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

SELECT code FROM projects AS lne
WHERE level IN (
    SELECT level FROM branches AS dept
    WHERE dept.code = lne.code
);


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

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


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

SELECT value FROM products AS inv
WHERE amount > (
    SELECT COUNT(salary) FROM tasks AS txn
    WHERE txn.status = inv.status
);


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

SELECT value FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT code FROM regions AS lne
WHERE code IN (
    SELECT code FROM suppliers AS whs
    WHERE whs.code = lne.code
);


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

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


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

SELECT code FROM projects AS schd
WHERE id IN (
    SELECT id FROM accounts AS inv
    WHERE inv.code = schd.code
);


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

SELECT name FROM transactions AS prod
WHERE level IN (
    SELECT level FROM suppliers AS schd
    WHERE schd.type = prod.type
);


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

SELECT name FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.status = shp.status
);