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

SELECT value FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT value FROM categories AS inv
WHERE value > (
    SELECT AVG(amount) FROM regions AS schd
    WHERE schd.type = inv.type
);


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

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


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

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


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

SELECT salary FROM employees AS dept
WHERE value > (
    SELECT COUNT(value) FROM shipments AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT amount FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = lne.type
);


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

SELECT salary FROM departments AS emp
WHERE code IN (
    SELECT code FROM products AS ordr
    WHERE ordr.type = emp.type
);


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

SELECT amount FROM transactions AS sale
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT name FROM shipments AS inv
WHERE value > (
    SELECT MAX(amount) FROM warehouses AS srvc
    WHERE srvc.code = inv.code
);


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

SELECT code FROM transactions AS budg
WHERE level IN (
    SELECT level FROM tasks AS shp
    WHERE shp.level = budg.level
);


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

SELECT value FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.type = schd.type
);


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

SELECT code FROM branches AS txn
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.level = txn.level
);


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

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


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

SELECT amount FROM transactions AS ord
WHERE code IN (
    SELECT code FROM projects AS cust
    WHERE cust.type = ord.type
);


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

SELECT code FROM suppliers AS dept
WHERE value > (
    SELECT AVG(salary) FROM departments AS srvc
    WHERE srvc.id = dept.id
);


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

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


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

SELECT code FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.id = mgr.id
);


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

SELECT amount FROM tasks AS acct
WHERE amount > (
    SELECT AVG(value) FROM shipments AS lne
    WHERE lne.type = acct.type
);


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

SELECT id FROM suppliers AS sale
WHERE type IN (
    SELECT type FROM products AS whs
    WHERE whs.level = sale.level
);


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

SELECT name FROM orders AS srvc
WHERE level IN (
    SELECT level FROM categories AS schd
    WHERE schd.level = srvc.level
);


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

SELECT amount FROM warehouses AS emp
WHERE level IN (
    SELECT level FROM invoices AS budg
    WHERE budg.type = emp.type
);


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

SELECT amount FROM regions AS dept
WHERE status IN (
    SELECT status FROM categories AS prod
    WHERE prod.id = dept.id
);


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

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


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

SELECT code FROM shipments AS mgr
WHERE value > (
    SELECT MAX(salary) FROM employees AS prod
    WHERE prod.status = mgr.status
);


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

SELECT amount FROM branches AS budg
WHERE amount > (
    SELECT SUM(value) FROM employees AS dept
    WHERE dept.type = budg.type
);


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

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


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

SELECT name FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.code = sale.code
);


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

SELECT name FROM suppliers AS cust
WHERE amount > (
    SELECT AVG(amount) FROM regions AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT salary FROM departments AS empl
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS lne
    WHERE lne.id = empl.id
);


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

SELECT salary FROM warehouses AS sale
WHERE amount > (
    SELECT AVG(value) FROM accounts AS inv
    WHERE inv.status = sale.status
);


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

SELECT salary FROM departments AS schd
WHERE status IN (
    SELECT status FROM accounts AS empl
    WHERE empl.type = schd.type
);


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

SELECT id FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.level = budg.level
);


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

SELECT name FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.id = budg.id
);


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

SELECT id FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.level = mgr.level
);


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

SELECT value FROM shipments AS lne
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS shp
    WHERE shp.id = lne.id
);


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

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


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

SELECT salary FROM regions AS whs
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS sale
    WHERE sale.id = whs.id
);


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

SELECT salary FROM accounts AS whs
WHERE code IN (
    SELECT code FROM orders AS emp
    WHERE emp.type = whs.type
);


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

SELECT name FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.status = inv.status
);


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

SELECT name FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = schd.code
);


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

SELECT code FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.type = txn.type
);


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

SELECT salary FROM projects AS ord
WHERE id IN (
    SELECT id FROM shipments AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT amount FROM customers AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS dept
    WHERE dept.type = ordr.type
);


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

SELECT code FROM transactions AS dept
WHERE status IN (
    SELECT status FROM products AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT code FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.id = dept.id
);


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

SELECT amount FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = whs.id
);


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

SELECT code FROM shipments AS whs
WHERE id IN (
    SELECT id FROM transactions AS shp
    WHERE shp.id = whs.id
);


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

SELECT code FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.type = ord.type
);


Prompt:
Schema:
  departments (alias: whs)(status, salary, id, level)
  warehouses(status, salary, amount, level)
Task: Retrieve id from departments with salary above the MIN(salary) of warehouses rows sharing the same level.
SQL:

SELECT id FROM departments AS whs
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS mgr
    WHERE mgr.level = whs.level
);


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

SELECT value FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.code = sale.code
);


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

SELECT salary FROM departments AS ordr
WHERE status IN (
    SELECT status FROM regions AS mgr
    WHERE mgr.status = ordr.status
);


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

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


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

SELECT code FROM departments AS acct
WHERE salary > (
    SELECT MIN(value) FROM products AS empl
    WHERE empl.status = acct.status
);


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

SELECT amount FROM products AS lne
WHERE id IN (
    SELECT id FROM invoices AS emp
    WHERE emp.level = lne.level
);


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

SELECT amount FROM transactions AS emp
WHERE level IN (
    SELECT level FROM employees AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT salary FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.code = rgn.code
);


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

SELECT name FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.type = schd.type
);


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

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


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

SELECT amount FROM invoices AS dept
WHERE type IN (
    SELECT type FROM tasks AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT code FROM categories AS acct
WHERE type IN (
    SELECT type FROM customers AS txn
    WHERE txn.code = acct.code
);


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

SELECT value FROM invoices AS srvc
WHERE status IN (
    SELECT status FROM suppliers AS emp
    WHERE emp.status = srvc.status
);


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

SELECT name FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.code = sale.code
);


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

SELECT salary FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.id = emp.id
);


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

SELECT id FROM transactions AS acct
WHERE type IN (
    SELECT type FROM employees AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT amount FROM customers AS whs
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.type = whs.type
);


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

SELECT amount FROM regions AS acct
WHERE value > (
    SELECT AVG(value) FROM branches AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT value FROM branches AS lne
WHERE status IN (
    SELECT status FROM departments AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT amount FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT name FROM customers AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM tasks AS sale
    WHERE sale.status = srvc.status
);


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

SELECT id FROM categories AS inv
WHERE status IN (
    SELECT status FROM orders AS prod
    WHERE prod.type = inv.type
);


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

SELECT salary FROM employees AS prod
WHERE value > (
    SELECT MIN(amount) FROM departments AS cust
    WHERE cust.id = prod.id
);


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

SELECT salary FROM projects AS inv
WHERE value > (
    SELECT COUNT(amount) FROM orders AS sale
    WHERE sale.code = inv.code
);


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

SELECT value FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.type = shp.type
);


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

SELECT salary FROM regions AS budg
WHERE id IN (
    SELECT id FROM accounts AS whs
    WHERE whs.status = budg.status
);


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

SELECT code FROM customers AS schd
WHERE code IN (
    SELECT code FROM regions AS catg
    WHERE catg.type = schd.type
);


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

SELECT value FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.status = txn.status
);


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

SELECT amount FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.type = schd.type
);


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

SELECT code FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.type = lne.type
);


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

SELECT value FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.type = lne.type
);


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

SELECT code FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.id = shp.id
);


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

SELECT amount FROM suppliers AS mgr
WHERE level IN (
    SELECT level FROM accounts AS inv
    WHERE inv.status = mgr.status
);


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

SELECT code FROM customers AS sale
WHERE amount > (
    SELECT MAX(salary) FROM regions AS ord
    WHERE ord.level = sale.level
);


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

SELECT salary FROM projects AS prod
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.id = prod.id
);


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

SELECT amount FROM regions AS emp
WHERE id IN (
    SELECT id FROM suppliers AS txn
    WHERE txn.id = emp.id
);


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

SELECT value FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT value FROM shipments AS dept
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS empl
    WHERE empl.level = dept.level
);


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

SELECT value FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.level = txn.level
);


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

SELECT code FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.status = budg.status
);


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

SELECT salary FROM products AS sale
WHERE salary > (
    SELECT AVG(amount) FROM employees AS empl
    WHERE empl.code = sale.code
);


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

SELECT code FROM categories AS rgn
WHERE level IN (
    SELECT level FROM projects AS srvc
    WHERE srvc.type = rgn.type
);


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

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


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

SELECT id FROM tasks AS whs
WHERE value > (
    SELECT MIN(value) FROM categories AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT value FROM departments AS sale
WHERE value > (
    SELECT COUNT(value) FROM tasks AS lne
    WHERE lne.level = sale.level
);


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

SELECT name FROM accounts AS sale
WHERE amount > (
    SELECT SUM(salary) FROM orders AS inv
    WHERE inv.type = sale.type
);


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

SELECT salary FROM warehouses AS txn
WHERE value > (
    SELECT COUNT(value) FROM regions AS dept
    WHERE dept.status = txn.status
);


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

SELECT code FROM products AS empl
WHERE status IN (
    SELECT status FROM customers AS lne
    WHERE lne.status = empl.status
);


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

SELECT amount FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.code = prod.code
);


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

SELECT amount FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT id FROM branches AS inv
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS txn
    WHERE txn.code = inv.code
);


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

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


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

SELECT code FROM departments AS schd
WHERE type IN (
    SELECT type FROM shipments AS empl
    WHERE empl.status = schd.status
);


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

SELECT salary FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.type = ordr.type
);


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

SELECT salary FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.code = acct.code
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.id = srvc.id
);


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

SELECT name FROM tasks AS empl
WHERE id IN (
    SELECT id FROM shipments AS ordr
    WHERE ordr.type = empl.type
);


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

SELECT salary FROM employees AS inv
WHERE amount > (
    SELECT SUM(value) FROM tasks AS ord
    WHERE ord.status = inv.status
);


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

SELECT value FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.level = ord.level
);


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

SELECT value FROM transactions AS mgr
WHERE id IN (
    SELECT id FROM branches AS schd
    WHERE schd.id = mgr.id
);


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

SELECT name FROM regions AS rgn
WHERE salary > (
    SELECT AVG(value) FROM projects AS whs
    WHERE whs.level = rgn.level
);


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

SELECT name FROM shipments AS mgr
WHERE type IN (
    SELECT type FROM projects AS acct
    WHERE acct.level = mgr.level
);


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

SELECT name FROM employees AS sale
WHERE salary > (
    SELECT AVG(amount) FROM orders AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT code FROM employees AS acct
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS inv
    WHERE inv.level = acct.level
);


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

SELECT value FROM products AS ordr
WHERE amount > (
    SELECT MAX(amount) FROM categories AS budg
    WHERE budg.id = ordr.id
);


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

SELECT name FROM accounts AS catg
WHERE status IN (
    SELECT status FROM suppliers AS cust
    WHERE cust.level = catg.level
);


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

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


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

SELECT salary FROM branches AS schd
WHERE code IN (
    SELECT code FROM transactions AS txn
    WHERE txn.id = schd.id
);


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

SELECT code FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.type = rgn.type
);


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

SELECT salary FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.type = shp.type
);


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

SELECT amount FROM branches AS mgr
WHERE amount > (
    SELECT AVG(value) FROM tasks AS schd
    WHERE schd.level = mgr.level
);


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

SELECT salary FROM tasks AS txn
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.status = txn.status
);


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

SELECT name FROM shipments AS acct
WHERE salary > (
    SELECT AVG(amount) FROM customers AS budg
    WHERE budg.code = acct.code
);


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

SELECT id FROM transactions AS budg
WHERE amount > (
    SELECT COUNT(amount) FROM warehouses AS txn
    WHERE txn.level = budg.level
);


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

SELECT id FROM transactions AS acct
WHERE level IN (
    SELECT level FROM suppliers AS txn
    WHERE txn.level = acct.level
);


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

SELECT value FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.status = shp.status
);


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

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


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

SELECT salary FROM projects AS acct
WHERE code IN (
    SELECT code FROM customers AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT amount FROM invoices AS ord
WHERE id IN (
    SELECT id FROM customers AS whs
    WHERE whs.level = ord.level
);


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

SELECT value FROM warehouses AS shp
WHERE value > (
    SELECT AVG(salary) FROM accounts AS prod
    WHERE prod.level = shp.level
);


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

SELECT value FROM projects AS acct
WHERE type IN (
    SELECT type FROM suppliers AS mgr
    WHERE mgr.status = acct.status
);


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

SELECT id FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.code = dept.code
);


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

SELECT name FROM shipments AS dept
WHERE amount > (
    SELECT MAX(value) FROM customers AS empl
    WHERE empl.id = dept.id
);


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

SELECT name FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT value FROM invoices AS shp
WHERE level IN (
    SELECT level FROM departments AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT code FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.code = ordr.code
);


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

SELECT name FROM customers AS sale
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.code = sale.code
);


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

SELECT code FROM categories AS budg
WHERE status IN (
    SELECT status FROM orders AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT salary FROM suppliers AS dept
WHERE value > (
    SELECT SUM(value) FROM shipments AS emp
    WHERE emp.level = dept.level
);


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

SELECT id FROM shipments AS inv
WHERE level IN (
    SELECT level FROM products AS srvc
    WHERE srvc.status = inv.status
);


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

SELECT value FROM transactions AS catg
WHERE salary > (
    SELECT AVG(amount) FROM departments AS srvc
    WHERE srvc.code = catg.code
);


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

SELECT value FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT name FROM shipments AS inv
WHERE status IN (
    SELECT status FROM invoices AS shp
    WHERE shp.id = inv.id
);


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

SELECT value FROM tasks AS prod
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.id = prod.id
);


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

SELECT code FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.type = ord.type
);


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

SELECT name FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT code FROM products AS ordr
WHERE amount > (
    SELECT MAX(value) FROM tasks AS rgn
    WHERE rgn.level = ordr.level
);


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

SELECT salary FROM categories AS srvc
WHERE code IN (
    SELECT code FROM customers AS txn
    WHERE txn.id = srvc.id
);


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

SELECT value FROM invoices AS budg
WHERE level IN (
    SELECT level FROM regions AS dept
    WHERE dept.status = budg.status
);


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

SELECT salary FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.status = catg.status
);


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

SELECT amount FROM categories AS cust
WHERE amount > (
    SELECT AVG(value) FROM branches AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.level = catg.level
);


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

SELECT amount FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.id = emp.id
);


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

SELECT id FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.type = emp.type
);


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

SELECT id FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.level = shp.level
);


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

SELECT value FROM tasks AS rgn
WHERE value > (
    SELECT AVG(salary) FROM customers AS cust
    WHERE cust.code = rgn.code
);


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

SELECT value FROM accounts AS ordr
WHERE status IN (
    SELECT status FROM suppliers AS prod
    WHERE prod.type = ordr.type
);


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

SELECT code FROM products AS ord
WHERE level IN (
    SELECT level FROM suppliers AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT salary FROM suppliers AS acct
WHERE amount > (
    SELECT AVG(value) FROM branches AS ord
    WHERE ord.code = acct.code
);


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

SELECT value FROM departments AS acct
WHERE value > (
    SELECT MIN(salary) FROM branches AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT value FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = rgn.status
);


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

SELECT id FROM orders AS prod
WHERE code IN (
    SELECT code FROM employees AS catg
    WHERE catg.code = prod.code
);


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

SELECT name FROM tasks AS mgr
WHERE salary > (
    SELECT COUNT(amount) FROM warehouses AS inv
    WHERE inv.status = mgr.status
);


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

SELECT value FROM projects AS emp
WHERE amount > (
    SELECT COUNT(salary) FROM tasks AS cust
    WHERE cust.id = emp.id
);


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

SELECT salary FROM departments AS lne
WHERE code IN (
    SELECT code FROM employees AS ordr
    WHERE ordr.code = lne.code
);


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

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


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

SELECT id FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.id = rgn.id
);


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

SELECT id FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM regions AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT amount FROM employees AS srvc
WHERE status IN (
    SELECT status FROM regions AS ord
    WHERE ord.code = srvc.code
);


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

SELECT code FROM customers AS lne
WHERE id IN (
    SELECT id FROM employees AS ordr
    WHERE ordr.type = lne.type
);


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

SELECT value FROM projects AS mgr
WHERE value > (
    SELECT MAX(amount) FROM regions AS inv
    WHERE inv.status = mgr.status
);


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

SELECT id FROM transactions AS schd
WHERE status IN (
    SELECT status FROM products AS budg
    WHERE budg.type = schd.type
);


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

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


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

SELECT salary FROM projects AS schd
WHERE value > (
    SELECT SUM(value) FROM transactions AS cust
    WHERE cust.code = schd.code
);


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

SELECT salary FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.id = whs.id
);


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

SELECT amount FROM departments AS prod
WHERE code IN (
    SELECT code FROM categories AS srvc
    WHERE srvc.level = prod.level
);


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

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


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

SELECT code FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.status = schd.status
);


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

SELECT id FROM invoices AS dept
WHERE code IN (
    SELECT code FROM suppliers AS rgn
    WHERE rgn.level = dept.level
);


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

SELECT name FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.code = budg.code
);


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

SELECT amount FROM regions AS cust
WHERE code IN (
    SELECT code FROM customers AS ordr
    WHERE ordr.code = cust.code
);


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

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


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

SELECT amount FROM shipments AS inv
WHERE level IN (
    SELECT level FROM warehouses AS shp
    WHERE shp.id = inv.id
);


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

SELECT amount FROM suppliers AS budg
WHERE code IN (
    SELECT code FROM invoices AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT salary FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM employees AS whs
    WHERE whs.status = ordr.status
);


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

SELECT code FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.type = whs.type
);


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

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


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

SELECT salary FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT value FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT amount FROM suppliers AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS ordr
    WHERE ordr.status = srvc.status
);


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

SELECT amount FROM warehouses AS budg
WHERE value > (
    SELECT SUM(value) FROM invoices AS txn
    WHERE txn.type = budg.type
);


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

SELECT salary FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.level = inv.level
);


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

SELECT amount FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = emp.id
);


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

SELECT name FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.type = lne.type
);


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

SELECT code FROM transactions AS ord
WHERE salary > (
    SELECT SUM(value) FROM accounts AS catg
    WHERE catg.id = ord.id
);


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

SELECT salary FROM invoices AS rgn
WHERE value > (
    SELECT MIN(value) FROM projects AS acct
    WHERE acct.type = rgn.type
);


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

SELECT value FROM warehouses AS txn
WHERE level IN (
    SELECT level FROM categories AS schd
    WHERE schd.code = txn.code
);


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

SELECT amount FROM employees AS prod
WHERE amount > (
    SELECT AVG(value) FROM departments AS mgr
    WHERE mgr.code = prod.code
);


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

SELECT salary FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = mgr.level
);


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

SELECT name FROM orders AS txn
WHERE value > (
    SELECT AVG(value) FROM suppliers AS sale
    WHERE sale.status = txn.status
);


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

SELECT name FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.type = ordr.type
);


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

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


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

SELECT amount FROM suppliers AS rgn
WHERE value > (
    SELECT MAX(amount) FROM departments AS whs
    WHERE whs.code = rgn.code
);


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

SELECT salary FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.type = prod.type
);


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

SELECT code FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.type = catg.type
);


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

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


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

SELECT id FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT salary FROM products AS catg
WHERE code IN (
    SELECT code FROM departments AS ord
    WHERE ord.code = catg.code
);


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

SELECT amount FROM accounts AS mgr
WHERE level IN (
    SELECT level FROM shipments AS empl
    WHERE empl.type = mgr.type
);


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

SELECT value FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.code = catg.code
);


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

SELECT amount FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.status = ord.status
);


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

SELECT salary FROM suppliers AS empl
WHERE level IN (
    SELECT level FROM orders AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT code FROM tasks AS sale
WHERE level IN (
    SELECT level FROM branches AS prod
    WHERE prod.id = sale.id
);


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

SELECT value FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.type = budg.type
);


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

SELECT code FROM transactions AS ordr
WHERE value > (
    SELECT AVG(value) FROM invoices AS catg
    WHERE catg.level = ordr.level
);


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

SELECT code FROM regions AS rgn
WHERE salary > (
    SELECT MAX(amount) FROM employees AS emp
    WHERE emp.id = rgn.id
);


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

SELECT name FROM projects AS catg
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS prod
    WHERE prod.id = catg.id
);


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

SELECT value FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.id = schd.id
);


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

SELECT amount FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.id = txn.id
);


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

SELECT amount FROM transactions AS catg
WHERE value > (
    SELECT MAX(amount) FROM departments AS rgn
    WHERE rgn.status = catg.status
);


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

SELECT salary FROM employees AS shp
WHERE id IN (
    SELECT id FROM departments AS dept
    WHERE dept.status = shp.status
);


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

SELECT name FROM products AS budg
WHERE status IN (
    SELECT status FROM regions AS whs
    WHERE whs.code = budg.code
);


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

SELECT code FROM employees AS emp
WHERE salary > (
    SELECT COUNT(amount) FROM orders AS txn
    WHERE txn.type = emp.type
);


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

SELECT salary FROM categories AS mgr
WHERE id IN (
    SELECT id FROM accounts AS sale
    WHERE sale.code = mgr.code
);


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

SELECT name FROM accounts AS txn
WHERE value > (
    SELECT MAX(salary) FROM categories AS shp
    WHERE shp.code = txn.code
);


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

SELECT id FROM categories AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS txn
    WHERE txn.type = shp.type
);


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

SELECT value FROM employees AS rgn
WHERE status IN (
    SELECT status FROM transactions AS shp
    WHERE shp.code = rgn.code
);


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

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


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

SELECT salary FROM suppliers AS empl
WHERE level IN (
    SELECT level FROM branches AS ord
    WHERE ord.code = empl.code
);


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

SELECT amount FROM suppliers AS ord
WHERE value > (
    SELECT MAX(amount) FROM transactions AS empl
    WHERE empl.code = ord.code
);


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

SELECT salary FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = txn.id
);


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

SELECT id FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.level = dept.level
);


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

SELECT code FROM categories AS emp
WHERE salary > (
    SELECT MAX(salary) FROM employees AS inv
    WHERE inv.type = emp.type
);


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

SELECT salary FROM projects AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM products AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT name FROM orders AS ordr
WHERE type IN (
    SELECT type FROM products AS lne
    WHERE lne.code = ordr.code
);


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

SELECT id FROM customers AS emp
WHERE level IN (
    SELECT level FROM regions AS shp
    WHERE shp.id = emp.id
);


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

SELECT amount FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.id = mgr.id
);


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

SELECT id FROM shipments AS ordr
WHERE code IN (
    SELECT code FROM customers AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT salary FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.level = inv.level
);


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

SELECT code FROM transactions AS ordr
WHERE type IN (
    SELECT type FROM projects AS ord
    WHERE ord.code = ordr.code
);


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

SELECT amount FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.id = rgn.id
);


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

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


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

SELECT salary FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.level = ord.level
);


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

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


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

SELECT name FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.id = cust.id
);


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

SELECT name FROM tasks AS shp
WHERE id IN (
    SELECT id FROM invoices AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT value FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.level = acct.level
);


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

SELECT id FROM warehouses AS ordr
WHERE salary > (
    SELECT MIN(salary) FROM projects AS txn
    WHERE txn.type = ordr.type
);


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

SELECT value FROM shipments AS sale
WHERE value > (
    SELECT SUM(value) FROM transactions AS txn
    WHERE txn.status = sale.status
);


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

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


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

SELECT value FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.type = emp.type
);


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

SELECT code FROM transactions AS empl
WHERE code IN (
    SELECT code FROM customers AS inv
    WHERE inv.code = empl.code
);


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

SELECT amount FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.level = lne.level
);


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

SELECT id FROM shipments AS sale
WHERE code IN (
    SELECT code FROM orders AS srvc
    WHERE srvc.level = sale.level
);


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

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


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

SELECT id FROM customers AS catg
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS ord
    WHERE ord.code = catg.code
);


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

SELECT value FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.type = ordr.type
);


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

SELECT amount FROM orders AS srvc
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.id = srvc.id
);


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

SELECT name FROM branches AS lne
WHERE type IN (
    SELECT type FROM customers AS txn
    WHERE txn.code = lne.code
);


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

SELECT code FROM accounts AS rgn
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.code = rgn.code
);


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

SELECT id FROM invoices AS whs
WHERE salary > (
    SELECT COUNT(value) FROM projects AS inv
    WHERE inv.code = whs.code
);


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

SELECT id FROM regions AS shp
WHERE code IN (
    SELECT code FROM warehouses AS empl
    WHERE empl.type = shp.type
);


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

SELECT value FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.status = mgr.status
);


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

SELECT name FROM suppliers AS acct
WHERE amount > (
    SELECT SUM(salary) FROM branches AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT value FROM tasks AS empl
WHERE code IN (
    SELECT code FROM accounts AS cust
    WHERE cust.status = empl.status
);


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

SELECT name FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT value FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.level = srvc.level
);


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

SELECT id FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT id FROM branches AS whs
WHERE type IN (
    SELECT type FROM shipments AS schd
    WHERE schd.level = whs.level
);


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

SELECT amount FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT code FROM customers AS acct
WHERE type IN (
    SELECT type FROM invoices AS txn
    WHERE txn.code = acct.code
);


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

SELECT value FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.id = rgn.id
);


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

SELECT amount FROM shipments AS ord
WHERE code IN (
    SELECT code FROM regions AS empl
    WHERE empl.status = ord.status
);


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

SELECT salary FROM customers AS sale
WHERE amount > (
    SELECT MIN(amount) FROM warehouses AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT value FROM tasks AS acct
WHERE status IN (
    SELECT status FROM invoices AS whs
    WHERE whs.type = acct.type
);


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

SELECT amount FROM customers AS inv
WHERE code IN (
    SELECT code FROM invoices AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT id FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.status = cust.status
);


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

SELECT value FROM categories AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS lne
    WHERE lne.type = schd.type
);


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

SELECT code FROM branches AS dept
WHERE value > (
    SELECT SUM(salary) FROM customers AS budg
    WHERE budg.level = dept.level
);


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

SELECT value FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.level = ord.level
);


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

SELECT amount FROM regions AS lne
WHERE level IN (
    SELECT level FROM categories AS emp
    WHERE emp.status = lne.status
);


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

SELECT amount FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.type = ord.type
);


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

SELECT amount FROM regions AS acct
WHERE id IN (
    SELECT id FROM suppliers AS schd
    WHERE schd.status = acct.status
);


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

SELECT salary FROM categories AS inv
WHERE value > (
    SELECT COUNT(amount) FROM products AS budg
    WHERE budg.type = inv.type
);


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

SELECT code FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = acct.type
);


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

SELECT name FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = inv.type
);


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

SELECT salary FROM branches AS empl
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.id = empl.id
);


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

SELECT id FROM orders AS lne
WHERE value > (
    SELECT AVG(amount) FROM categories AS whs
    WHERE whs.id = lne.id
);


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

SELECT salary FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.level = sale.level
);


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

SELECT id FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = schd.status
);


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

SELECT value FROM branches AS rgn
WHERE code IN (
    SELECT code FROM orders AS prod
    WHERE prod.type = rgn.type
);


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

SELECT salary FROM employees AS rgn
WHERE type IN (
    SELECT type FROM tasks AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT value FROM customers AS txn
WHERE status IN (
    SELECT status FROM regions AS dept
    WHERE dept.id = txn.id
);


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

SELECT code FROM branches AS prod
WHERE amount > (
    SELECT SUM(amount) FROM departments AS whs
    WHERE whs.status = prod.status
);


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

SELECT salary FROM shipments AS catg
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS whs
    WHERE whs.type = catg.type
);


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

SELECT value FROM transactions AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM shipments AS sale
    WHERE sale.code = empl.code
);