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

SELECT name FROM orders AS emp
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.status = emp.status
);


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

SELECT value FROM orders AS acct
WHERE salary > (
    SELECT MIN(value) FROM customers AS emp
    WHERE emp.level = acct.level
);


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

SELECT amount FROM warehouses AS mgr
WHERE level IN (
    SELECT level FROM invoices AS acct
    WHERE acct.id = mgr.id
);


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

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


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

SELECT id FROM employees AS empl
WHERE amount > (
    SELECT AVG(amount) FROM orders AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT salary FROM departments AS emp
WHERE level IN (
    SELECT level FROM warehouses AS dept
    WHERE dept.status = emp.status
);


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

SELECT amount FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.id = txn.id
);


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

SELECT amount FROM suppliers AS ord
WHERE value > (
    SELECT MIN(amount) FROM regions AS emp
    WHERE emp.level = ord.level
);


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

SELECT id FROM employees AS mgr
WHERE id IN (
    SELECT id FROM branches AS prod
    WHERE prod.code = mgr.code
);


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

SELECT value FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.code = shp.code
);


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

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


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

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


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

SELECT code FROM products AS sale
WHERE level IN (
    SELECT level FROM invoices AS ord
    WHERE ord.status = sale.status
);


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

SELECT name FROM tasks AS emp
WHERE salary > (
    SELECT MIN(value) FROM categories AS catg
    WHERE catg.id = emp.id
);


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

SELECT code FROM warehouses AS ordr
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.status = ordr.status
);


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

SELECT salary FROM branches AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM products AS lne
    WHERE lne.type = catg.type
);


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

SELECT id FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.level = empl.level
);


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

SELECT value FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.id = catg.id
);


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

SELECT name FROM departments AS whs
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS acct
    WHERE acct.type = whs.type
);


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

SELECT id FROM suppliers AS ord
WHERE value > (
    SELECT MIN(value) FROM branches AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT salary FROM shipments AS mgr
WHERE id IN (
    SELECT id FROM invoices AS srvc
    WHERE srvc.id = mgr.id
);


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

SELECT salary FROM customers AS sale
WHERE value > (
    SELECT SUM(value) FROM employees AS whs
    WHERE whs.status = sale.status
);


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

SELECT id FROM orders AS catg
WHERE value > (
    SELECT MIN(salary) FROM tasks AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT code FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.status = srvc.status
);


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

SELECT amount FROM categories AS lne
WHERE status IN (
    SELECT status FROM accounts AS whs
    WHERE whs.id = lne.id
);


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

SELECT id FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.code = whs.code
);


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

SELECT value FROM orders AS dept
WHERE value > (
    SELECT COUNT(salary) FROM accounts AS txn
    WHERE txn.id = dept.id
);


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

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


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

SELECT name FROM branches AS empl
WHERE value > (
    SELECT AVG(value) FROM accounts AS budg
    WHERE budg.id = empl.id
);


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

SELECT amount FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.status = catg.status
);


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

SELECT name FROM categories AS shp
WHERE status IN (
    SELECT status FROM warehouses AS srvc
    WHERE srvc.id = shp.id
);


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

SELECT amount FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.type = sale.type
);


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

SELECT name FROM invoices AS catg
WHERE level IN (
    SELECT level FROM customers AS whs
    WHERE whs.level = catg.level
);


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

SELECT amount FROM customers AS budg
WHERE value > (
    SELECT COUNT(salary) FROM accounts AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT salary FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.id = emp.id
);


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

SELECT amount FROM employees AS cust
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.id = cust.id
);


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

SELECT value FROM employees AS dept
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT salary FROM accounts AS dept
WHERE type IN (
    SELECT type FROM suppliers AS lne
    WHERE lne.status = dept.status
);


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

SELECT id FROM projects AS prod
WHERE amount > (
    SELECT MIN(amount) FROM customers AS schd
    WHERE schd.id = prod.id
);


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

SELECT salary FROM departments AS cust
WHERE amount > (
    SELECT AVG(amount) FROM employees AS inv
    WHERE inv.code = cust.code
);


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

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


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

SELECT name FROM regions AS txn
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.id = txn.id
);


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

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


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

SELECT id FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.status = mgr.status
);


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

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


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

SELECT value FROM employees AS acct
WHERE amount > (
    SELECT AVG(value) FROM transactions AS dept
    WHERE dept.status = acct.status
);


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM suppliers AS dept
    WHERE dept.type = ord.type
);


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

SELECT name FROM transactions AS inv
WHERE status IN (
    SELECT status FROM warehouses AS sale
    WHERE sale.status = inv.status
);


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

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


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

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


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

SELECT code FROM transactions AS lne
WHERE id IN (
    SELECT id FROM suppliers AS dept
    WHERE dept.id = lne.id
);


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

SELECT id FROM branches AS inv
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS ord
    WHERE ord.status = inv.status
);


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

SELECT value FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.status = ord.status
);


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

SELECT id FROM orders AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS cust
    WHERE cust.level = ord.level
);


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

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


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

SELECT value FROM transactions AS txn
WHERE amount > (
    SELECT MIN(value) FROM accounts AS ordr
    WHERE ordr.code = txn.code
);


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

SELECT amount FROM branches AS ord
WHERE amount > (
    SELECT SUM(salary) FROM projects AS inv
    WHERE inv.type = ord.type
);


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

SELECT value FROM tasks AS whs
WHERE salary > (
    SELECT MIN(amount) FROM categories AS budg
    WHERE budg.status = whs.status
);


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

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


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

SELECT code FROM suppliers AS sale
WHERE salary > (
    SELECT MIN(amount) FROM employees AS acct
    WHERE acct.type = sale.type
);


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

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


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

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


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

SELECT salary FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.id = cust.id
);


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

SELECT name FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.code = whs.code
);


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

SELECT id FROM transactions AS txn
WHERE salary > (
    SELECT AVG(salary) FROM tasks AS inv
    WHERE inv.id = txn.id
);


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

SELECT name FROM transactions AS empl
WHERE id IN (
    SELECT id FROM projects AS whs
    WHERE whs.id = empl.id
);


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

SELECT amount FROM categories AS budg
WHERE code IN (
    SELECT code FROM customers AS schd
    WHERE schd.code = budg.code
);


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

SELECT amount FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.level = acct.level
);


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

SELECT code FROM products AS inv
WHERE status IN (
    SELECT status FROM shipments AS ord
    WHERE ord.type = inv.type
);


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

SELECT code FROM suppliers AS rgn
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.type = rgn.type
);


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

SELECT code FROM employees AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT amount FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.id = dept.id
);


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

SELECT id FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.level = budg.level
);


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

SELECT salary FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.level = inv.level
);


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

SELECT id FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT salary FROM employees AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM departments AS dept
    WHERE dept.code = txn.code
);


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

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


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

SELECT name FROM products AS empl
WHERE code IN (
    SELECT code FROM warehouses AS emp
    WHERE emp.id = empl.id
);


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

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


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

SELECT id FROM categories AS emp
WHERE value > (
    SELECT COUNT(salary) FROM regions AS dept
    WHERE dept.code = emp.code
);


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

SELECT code FROM regions AS schd
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT id FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT salary FROM suppliers AS lne
WHERE status IN (
    SELECT status FROM transactions AS budg
    WHERE budg.id = lne.id
);


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

SELECT amount FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.id = lne.id
);


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

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


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

SELECT code FROM shipments AS cust
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS catg
    WHERE catg.id = cust.id
);


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

SELECT amount FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.status = srvc.status
);


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

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


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

SELECT name FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT amount FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.status = sale.status
);


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

SELECT code FROM invoices AS ordr
WHERE salary > (
    SELECT AVG(value) FROM branches AS prod
    WHERE prod.level = ordr.level
);


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

SELECT amount FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT id FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.code = prod.code
);


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

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


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

SELECT code FROM products AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM projects AS txn
    WHERE txn.level = mgr.level
);


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

SELECT salary FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT id FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.type = ordr.type
);


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

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


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

SELECT salary FROM categories AS ordr
WHERE type IN (
    SELECT type FROM products AS sale
    WHERE sale.id = ordr.id
);


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

SELECT salary FROM shipments AS txn
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT name FROM categories AS lne
WHERE code IN (
    SELECT code FROM transactions AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT name FROM projects AS cust
WHERE code IN (
    SELECT code FROM suppliers AS inv
    WHERE inv.level = cust.level
);


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

SELECT code FROM orders AS schd
WHERE value > (
    SELECT MIN(salary) FROM regions AS shp
    WHERE shp.status = schd.status
);


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

SELECT name FROM branches AS lne
WHERE status IN (
    SELECT status FROM regions AS ord
    WHERE ord.status = lne.status
);


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

SELECT salary FROM transactions AS ordr
WHERE value > (
    SELECT SUM(value) FROM branches AS schd
    WHERE schd.level = ordr.level
);


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

SELECT id FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.id = srvc.id
);


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

SELECT id FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = acct.type
);


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

SELECT salary FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT code FROM customers AS lne
WHERE amount > (
    SELECT MAX(value) FROM departments AS cust
    WHERE cust.level = lne.level
);


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

SELECT code FROM regions AS schd
WHERE amount > (
    SELECT MAX(salary) FROM products AS prod
    WHERE prod.type = schd.type
);


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

SELECT name FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.status = cust.status
);


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

SELECT value FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.status = cust.status
);


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

SELECT salary FROM employees AS ordr
WHERE amount > (
    SELECT SUM(value) FROM orders AS txn
    WHERE txn.status = ordr.status
);


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

SELECT id FROM orders AS srvc
WHERE level IN (
    SELECT level FROM employees AS prod
    WHERE prod.status = srvc.status
);


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

SELECT name FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.status = srvc.status
);


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

SELECT salary FROM tasks AS txn
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.status = acct.status
);


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

SELECT value FROM categories AS ordr
WHERE type IN (
    SELECT type FROM tasks AS shp
    WHERE shp.level = ordr.level
);


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

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


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

SELECT code FROM products AS mgr
WHERE code IN (
    SELECT code FROM suppliers AS txn
    WHERE txn.type = mgr.type
);


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

SELECT amount FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.level = ord.level
);


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

SELECT value FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.id = emp.id
);


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

SELECT salary FROM orders AS txn
WHERE amount > (
    SELECT AVG(salary) FROM departments AS srvc
    WHERE srvc.level = txn.level
);


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

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


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

SELECT id FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT amount FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.code = sale.code
);


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

SELECT salary FROM suppliers AS prod
WHERE salary > (
    SELECT COUNT(value) FROM departments AS txn
    WHERE txn.code = prod.code
);


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

SELECT code FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.id = budg.id
);


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

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


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

SELECT name FROM tasks AS budg
WHERE amount > (
    SELECT SUM(salary) FROM warehouses AS srvc
    WHERE srvc.id = budg.id
);


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

SELECT amount FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.id = rgn.id
);


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

SELECT id FROM customers AS empl
WHERE salary > (
    SELECT MIN(value) FROM warehouses AS shp
    WHERE shp.id = empl.id
);


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

SELECT amount FROM tasks AS txn
WHERE id IN (
    SELECT id FROM orders AS srvc
    WHERE srvc.type = txn.type
);


Prompt:
Schema:
  employees (alias: prod)(id, type, code, amount)
  products(level, amount, type, id)
Task: Find id from employees where code appears in products entries with matching level.
SQL:

SELECT id FROM employees AS prod
WHERE code IN (
    SELECT code FROM products AS acct
    WHERE acct.level = prod.level
);


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

SELECT amount FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.type = txn.type
);


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

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


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

SELECT amount FROM warehouses AS lne
WHERE type IN (
    SELECT type FROM customers AS empl
    WHERE empl.status = lne.status
);


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

SELECT id FROM categories AS srvc
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS ord
    WHERE ord.type = srvc.type
);


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

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


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

SELECT salary FROM categories AS inv
WHERE amount > (
    SELECT COUNT(value) FROM warehouses AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT value FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.id = sale.id
);


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

SELECT salary FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT name FROM regions AS acct
WHERE id IN (
    SELECT id FROM departments AS catg
    WHERE catg.type = acct.type
);


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

SELECT salary FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.type = shp.type
);


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

SELECT value FROM customers AS whs
WHERE code IN (
    SELECT code FROM tasks AS cust
    WHERE cust.type = whs.type
);


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

SELECT name FROM branches AS budg
WHERE code IN (
    SELECT code FROM shipments AS whs
    WHERE whs.code = budg.code
);


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

SELECT code FROM tasks AS shp
WHERE salary > (
    SELECT MIN(salary) FROM orders AS cust
    WHERE cust.type = shp.type
);


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

SELECT code FROM orders AS acct
WHERE value > (
    SELECT MAX(value) FROM departments AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT code FROM branches AS acct
WHERE salary > (
    SELECT COUNT(value) FROM regions AS inv
    WHERE inv.type = acct.type
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT salary FROM categories AS emp
WHERE value > (
    SELECT SUM(amount) FROM shipments AS budg
    WHERE budg.level = emp.level
);


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

SELECT salary FROM shipments AS budg
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS schd
    WHERE schd.code = budg.code
);


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

SELECT id FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.id = mgr.id
);


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

SELECT id FROM products AS srvc
WHERE type IN (
    SELECT type FROM transactions AS dept
    WHERE dept.level = srvc.level
);


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

SELECT id FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.id = shp.id
);


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

SELECT amount FROM products AS emp
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.status = emp.status
);


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

SELECT id FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.code = acct.code
);


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

SELECT salary FROM orders AS srvc
WHERE value > (
    SELECT COUNT(salary) FROM employees AS sale
    WHERE sale.status = srvc.status
);


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

SELECT amount FROM departments AS srvc
WHERE value > (
    SELECT AVG(value) FROM shipments AS shp
    WHERE shp.id = srvc.id
);


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

SELECT salary FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.status = ord.status
);


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

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


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

SELECT name FROM tasks AS catg
WHERE id IN (
    SELECT id FROM projects AS acct
    WHERE acct.type = catg.type
);


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

SELECT amount FROM customers AS empl
WHERE amount > (
    SELECT MAX(salary) FROM departments AS shp
    WHERE shp.code = empl.code
);


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

SELECT value FROM accounts AS dept
WHERE id IN (
    SELECT id FROM employees AS inv
    WHERE inv.code = dept.code
);


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

SELECT id FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.code = empl.code
);


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

SELECT name FROM warehouses AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM customers AS budg
    WHERE budg.code = ordr.code
);


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

SELECT salary FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.type = whs.type
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.id = shp.id
);


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

SELECT name FROM transactions AS rgn
WHERE status IN (
    SELECT status FROM departments AS ord
    WHERE ord.level = rgn.level
);


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

SELECT salary FROM branches AS prod
WHERE salary > (
    SELECT AVG(salary) FROM products AS empl
    WHERE empl.level = prod.level
);


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

SELECT id FROM regions AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS dept
    WHERE dept.code = ord.code
);


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

SELECT salary FROM orders AS whs
WHERE amount > (
    SELECT AVG(amount) FROM categories AS srvc
    WHERE srvc.status = whs.status
);


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

SELECT amount FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.id = sale.id
);


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

SELECT salary FROM projects AS txn
WHERE amount > (
    SELECT SUM(salary) FROM customers AS ord
    WHERE ord.level = txn.level
);


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

SELECT name FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.level = txn.level
);


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

SELECT salary FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.status = schd.status
);


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

SELECT name FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.level = ord.level
);


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

SELECT value FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.id = dept.id
);


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

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.type = shp.type
);


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

SELECT name FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.status = inv.status
);


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

SELECT salary FROM suppliers AS rgn
WHERE code IN (
    SELECT code FROM products AS emp
    WHERE emp.type = rgn.type
);


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

SELECT salary FROM shipments AS schd
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS catg
    WHERE catg.id = schd.id
);


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

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT AVG(salary) FROM transactions AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT code FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.code = shp.code
);


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

SELECT value FROM branches AS schd
WHERE type IN (
    SELECT type FROM departments AS prod
    WHERE prod.code = schd.code
);


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

SELECT salary FROM tasks AS mgr
WHERE amount > (
    SELECT AVG(value) FROM shipments AS inv
    WHERE inv.status = mgr.status
);


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

SELECT salary FROM branches AS budg
WHERE level IN (
    SELECT level FROM regions AS whs
    WHERE whs.id = budg.id
);


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

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


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

SELECT name FROM invoices AS acct
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT value FROM accounts AS budg
WHERE status IN (
    SELECT status FROM departments AS whs
    WHERE whs.status = budg.status
);


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

SELECT name FROM accounts AS ord
WHERE value > (
    SELECT MAX(salary) FROM regions AS lne
    WHERE lne.type = ord.type
);


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

SELECT value FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.level = schd.level
);


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

SELECT salary FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.type = lne.type
);


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

SELECT salary FROM orders AS shp
WHERE type IN (
    SELECT type FROM projects AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT id FROM warehouses AS srvc
WHERE value > (
    SELECT AVG(amount) FROM employees AS lne
    WHERE lne.code = srvc.code
);


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

SELECT amount FROM accounts AS sale
WHERE value > (
    SELECT MIN(value) FROM products AS whs
    WHERE whs.type = sale.type
);


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

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


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

SELECT value FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT salary FROM transactions AS srvc
WHERE salary > (
    SELECT SUM(value) FROM regions AS inv
    WHERE inv.level = srvc.level
);


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

SELECT amount FROM regions AS srvc
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS budg
    WHERE budg.code = srvc.code
);


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

SELECT name FROM orders AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM transactions AS catg
    WHERE catg.level = rgn.level
);


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

SELECT id FROM categories AS sale
WHERE salary > (
    SELECT SUM(value) FROM transactions AS schd
    WHERE schd.type = sale.type
);


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

SELECT id FROM employees AS sale
WHERE value > (
    SELECT MIN(amount) FROM accounts AS ord
    WHERE ord.status = sale.status
);


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

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


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

SELECT name FROM tasks AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM categories AS mgr
    WHERE mgr.type = srvc.type
);


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

SELECT value FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.id = shp.id
);


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

SELECT amount FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.type = dept.type
);


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

SELECT amount FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT code FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.level = ordr.level
);


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

SELECT salary FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.code = schd.code
);


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

SELECT code FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT id FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.type = ord.type
);


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

SELECT value FROM products AS shp
WHERE amount > (
    SELECT SUM(amount) FROM customers AS lne
    WHERE lne.level = shp.level
);


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

SELECT value FROM transactions AS schd
WHERE value > (
    SELECT COUNT(amount) FROM departments AS ord
    WHERE ord.level = schd.level
);


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

SELECT amount FROM shipments AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM customers AS emp
    WHERE emp.id = ordr.id
);


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

SELECT code FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.code = mgr.code
);


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

SELECT salary FROM regions AS rgn
WHERE id IN (
    SELECT id FROM transactions AS lne
    WHERE lne.type = rgn.type
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.type = whs.type
);


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

SELECT id FROM departments AS lne
WHERE level IN (
    SELECT level FROM products AS sale
    WHERE sale.type = lne.type
);


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

SELECT value FROM regions AS cust
WHERE code IN (
    SELECT code FROM projects AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT code FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.level = sale.level
);


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

SELECT name FROM branches AS budg
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS schd
    WHERE schd.id = budg.id
);


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

SELECT amount FROM employees AS ord
WHERE code IN (
    SELECT code FROM orders AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT id FROM departments AS inv
WHERE amount > (
    SELECT SUM(salary) FROM orders AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT salary FROM tasks AS txn
WHERE salary > (
    SELECT COUNT(amount) FROM products AS budg
    WHERE budg.code = txn.code
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.code = inv.code
);


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

SELECT name FROM branches AS cust
WHERE salary > (
    SELECT AVG(salary) FROM departments AS emp
    WHERE emp.status = cust.status
);


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

SELECT amount FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.code = emp.code
);


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

SELECT name FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT amount FROM employees AS ordr
WHERE level IN (
    SELECT level FROM accounts AS shp
    WHERE shp.status = ordr.status
);


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

SELECT name FROM departments AS inv
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS acct
    WHERE acct.type = inv.type
);


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

SELECT code FROM warehouses AS acct
WHERE salary > (
    SELECT MAX(salary) FROM projects AS schd
    WHERE schd.type = acct.type
);


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

SELECT id FROM accounts AS catg
WHERE level IN (
    SELECT level FROM tasks AS prod
    WHERE prod.type = catg.type
);


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

SELECT amount FROM accounts AS cust
WHERE salary > (
    SELECT MIN(salary) FROM regions AS budg
    WHERE budg.type = cust.type
);


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

SELECT id FROM branches AS txn
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS mgr
    WHERE mgr.id = txn.id
);


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

SELECT name FROM shipments AS txn
WHERE salary > (
    SELECT COUNT(value) FROM products AS dept
    WHERE dept.code = txn.code
);


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

SELECT name FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.status = acct.status
);


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

SELECT id FROM projects AS lne
WHERE code IN (
    SELECT code FROM tasks AS emp
    WHERE emp.level = lne.level
);


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

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


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

SELECT code FROM departments AS cust
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS acct
    WHERE acct.id = cust.id
);


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

SELECT salary FROM accounts AS acct
WHERE level IN (
    SELECT level FROM transactions AS empl
    WHERE empl.level = acct.level
);


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

SELECT name FROM branches AS acct
WHERE amount > (
    SELECT COUNT(value) FROM transactions AS emp
    WHERE emp.type = acct.type
);


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

SELECT salary FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.status = budg.status
);


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

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


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

SELECT id FROM customers AS rgn
WHERE code IN (
    SELECT code FROM regions AS sale
    WHERE sale.type = rgn.type
);


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

SELECT name FROM suppliers AS lne
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.level = lne.level
);


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

SELECT salary FROM products AS prod
WHERE amount > (
    SELECT AVG(value) FROM projects AS inv
    WHERE inv.id = prod.id
);


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

SELECT code FROM products AS cust
WHERE id IN (
    SELECT id FROM employees AS ord
    WHERE ord.id = cust.id
);


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

SELECT value FROM branches AS emp
WHERE value > (
    SELECT COUNT(value) FROM invoices AS ord
    WHERE ord.code = emp.code
);


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

SELECT value FROM orders AS mgr
WHERE value > (
    SELECT MAX(amount) FROM customers AS schd
    WHERE schd.id = mgr.id
);


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

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


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

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


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

SELECT amount FROM regions AS sale
WHERE status IN (
    SELECT status FROM departments AS cust
    WHERE cust.level = sale.level
);


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

SELECT salary FROM orders AS ord
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT amount FROM shipments AS acct
WHERE amount > (
    SELECT MIN(value) FROM departments AS ord
    WHERE ord.status = acct.status
);


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

SELECT amount FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.type = whs.type
);


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

SELECT id FROM suppliers AS whs
WHERE status IN (
    SELECT status FROM branches AS ord
    WHERE ord.level = whs.level
);


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

SELECT name FROM tasks AS acct
WHERE level IN (
    SELECT level FROM products AS cust
    WHERE cust.level = acct.level
);


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

SELECT value FROM regions AS schd
WHERE value > (
    SELECT MIN(amount) FROM warehouses AS catg
    WHERE catg.status = schd.status
);


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

SELECT id FROM departments AS catg
WHERE type IN (
    SELECT type FROM branches AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT salary FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.status = rgn.status
);


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

SELECT value FROM accounts AS ord
WHERE id IN (
    SELECT id FROM products AS budg
    WHERE budg.status = ord.status
);


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

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


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

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


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM accounts AS inv
    WHERE inv.id = rgn.id
);


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

SELECT salary FROM tasks AS sale
WHERE code IN (
    SELECT code FROM regions AS txn
    WHERE txn.id = sale.id
);


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

SELECT code FROM customers AS ord
WHERE type IN (
    SELECT type FROM accounts AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT name FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.type = txn.type
);


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

SELECT name FROM orders AS dept
WHERE value > (
    SELECT COUNT(value) FROM suppliers AS budg
    WHERE budg.level = dept.level
);


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

SELECT value FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = shp.level
);


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

SELECT id FROM accounts AS empl
WHERE value > (
    SELECT AVG(value) FROM categories AS txn
    WHERE txn.type = empl.type
);


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

SELECT code FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.status = schd.status
);


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

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT amount FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.status = cust.status
);


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

SELECT salary FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.code = acct.code
);


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

SELECT code FROM departments AS catg
WHERE id IN (
    SELECT id FROM invoices AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT amount FROM projects AS cust
WHERE type IN (
    SELECT type FROM invoices AS dept
    WHERE dept.id = cust.id
);


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

SELECT salary FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.code = txn.code
);


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

SELECT id FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.code = schd.code
);


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

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


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

SELECT salary FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.id = schd.id
);


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

SELECT value FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.level = ordr.level
);


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

SELECT value FROM tasks AS srvc
WHERE code IN (
    SELECT code FROM employees AS empl
    WHERE empl.code = srvc.code
);


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

SELECT salary FROM employees AS prod
WHERE level IN (
    SELECT level FROM invoices AS catg
    WHERE catg.type = prod.type
);


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

SELECT name FROM customers AS whs
WHERE value > (
    SELECT AVG(salary) FROM branches AS sale
    WHERE sale.id = whs.id
);


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

SELECT name FROM shipments AS whs
WHERE code IN (
    SELECT code FROM regions AS acct
    WHERE acct.level = whs.level
);


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

SELECT amount FROM projects AS whs
WHERE level IN (
    SELECT level FROM employees AS budg
    WHERE budg.id = whs.id
);


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

SELECT name FROM invoices AS shp
WHERE salary > (
    SELECT SUM(value) FROM transactions AS txn
    WHERE txn.level = shp.level
);


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

SELECT code FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.type = catg.type
);


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

SELECT value FROM accounts AS sale
WHERE salary > (
    SELECT AVG(salary) FROM projects AS schd
    WHERE schd.status = sale.status
);


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

SELECT name FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.level = prod.level
);


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

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


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

SELECT name FROM shipments AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS sale
    WHERE sale.id = catg.id
);