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

SELECT amount FROM transactions AS txn
WHERE id IN (
    SELECT id FROM warehouses AS empl
    WHERE empl.code = txn.code
);


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

SELECT name FROM departments AS prod
WHERE type IN (
    SELECT type FROM warehouses AS empl
    WHERE empl.level = prod.level
);


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

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


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

SELECT amount FROM branches AS sale
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.type = sale.type
);


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

SELECT id FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = empl.level
);


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

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


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

SELECT name FROM invoices AS emp
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT name FROM regions AS dept
WHERE salary > (
    SELECT AVG(value) FROM invoices AS schd
    WHERE schd.id = dept.id
);


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

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


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

SELECT amount FROM employees AS dept
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS emp
    WHERE emp.level = dept.level
);


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

SELECT name FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT salary FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.level = ordr.level
);


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

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


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

SELECT id FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.status = catg.status
);


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

SELECT name FROM regions AS shp
WHERE id IN (
    SELECT id FROM orders AS txn
    WHERE txn.code = shp.code
);


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

SELECT amount FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT value FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = sale.type
);


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

SELECT code FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.status = inv.status
);


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

SELECT value FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT name FROM suppliers AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS shp
    WHERE shp.id = ordr.id
);


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

SELECT code FROM products AS budg
WHERE id IN (
    SELECT id FROM invoices AS schd
    WHERE schd.level = budg.level
);


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

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


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

SELECT name FROM shipments AS empl
WHERE value > (
    SELECT AVG(value) FROM categories AS lne
    WHERE lne.status = empl.status
);


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

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


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

SELECT value FROM categories AS prod
WHERE salary > (
    SELECT SUM(salary) FROM orders AS emp
    WHERE emp.type = prod.type
);


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

SELECT name FROM accounts AS budg
WHERE value > (
    SELECT SUM(amount) FROM employees AS whs
    WHERE whs.code = budg.code
);


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

SELECT salary FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.type = dept.type
);


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

SELECT value FROM projects AS acct
WHERE id IN (
    SELECT id FROM warehouses AS whs
    WHERE whs.code = acct.code
);


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

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


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

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


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

SELECT name FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.id = budg.id
);


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

SELECT value FROM warehouses AS mgr
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS rgn
    WHERE rgn.type = mgr.type
);


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

SELECT name FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.type = whs.type
);


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

SELECT id FROM tasks AS cust
WHERE type IN (
    SELECT type FROM suppliers AS sale
    WHERE sale.id = cust.id
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT code FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = inv.code
);


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

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


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

SELECT id FROM tasks AS lne
WHERE amount > (
    SELECT AVG(amount) FROM employees AS catg
    WHERE catg.type = lne.type
);


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

SELECT code FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.level = dept.level
);


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

SELECT amount FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.id = sale.id
);


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

SELECT amount FROM transactions AS budg
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS catg
    WHERE catg.id = budg.id
);


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

SELECT salary FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.type = mgr.type
);


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

SELECT salary FROM tasks AS dept
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS emp
    WHERE emp.code = dept.code
);


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

SELECT name FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.id = ord.id
);


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

SELECT salary FROM customers AS emp
WHERE id IN (
    SELECT id FROM categories AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT amount FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.id = inv.id
);


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

SELECT name FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.type = srvc.type
);


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

SELECT code FROM departments AS emp
WHERE status IN (
    SELECT status FROM accounts AS prod
    WHERE prod.code = emp.code
);


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

SELECT value FROM customers AS prod
WHERE id IN (
    SELECT id FROM categories AS srvc
    WHERE srvc.level = prod.level
);


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

SELECT id FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.code = shp.code
);


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

SELECT value FROM projects AS rgn
WHERE status IN (
    SELECT status FROM tasks AS mgr
    WHERE mgr.code = rgn.code
);


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

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


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

SELECT code FROM regions AS whs
WHERE code IN (
    SELECT code FROM departments AS empl
    WHERE empl.id = whs.id
);


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

SELECT id FROM suppliers AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS sale
    WHERE sale.code = shp.code
);


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

SELECT value FROM employees AS empl
WHERE level IN (
    SELECT level FROM projects AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT name FROM branches AS budg
WHERE code IN (
    SELECT code FROM departments AS ord
    WHERE ord.code = budg.code
);


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

SELECT salary FROM branches AS dept
WHERE status IN (
    SELECT status FROM transactions AS prod
    WHERE prod.id = dept.id
);


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

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


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

SELECT salary FROM products AS dept
WHERE code IN (
    SELECT code FROM warehouses AS empl
    WHERE empl.status = dept.status
);


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

SELECT id FROM tasks AS budg
WHERE amount > (
    SELECT SUM(value) FROM shipments AS catg
    WHERE catg.status = budg.status
);


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

SELECT salary FROM tasks AS ord
WHERE status IN (
    SELECT status FROM departments AS sale
    WHERE sale.id = ord.id
);


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

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


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

SELECT salary FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.level = budg.level
);


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

SELECT amount FROM transactions AS mgr
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS sale
    WHERE sale.status = mgr.status
);


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

SELECT value FROM orders AS srvc
WHERE code IN (
    SELECT code FROM regions AS budg
    WHERE budg.type = srvc.type
);


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

SELECT salary FROM suppliers AS rgn
WHERE type IN (
    SELECT type FROM warehouses AS dept
    WHERE dept.status = rgn.status
);


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

SELECT value FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = sale.type
);


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

SELECT amount FROM accounts AS dept
WHERE type IN (
    SELECT type FROM shipments AS txn
    WHERE txn.status = dept.status
);


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

SELECT amount FROM warehouses AS acct
WHERE type IN (
    SELECT type FROM departments AS rgn
    WHERE rgn.code = acct.code
);


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

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


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

SELECT name FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT value FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT amount FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.id = srvc.id
);


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

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


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

SELECT name FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM orders AS sale
    WHERE sale.id = whs.id
);


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

SELECT name FROM branches AS schd
WHERE value > (
    SELECT SUM(amount) FROM projects AS cust
    WHERE cust.id = schd.id
);


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

SELECT salary FROM orders AS txn
WHERE value > (
    SELECT MAX(value) FROM customers AS srvc
    WHERE srvc.code = txn.code
);


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

SELECT amount FROM employees AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM products AS sale
    WHERE sale.code = shp.code
);


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

SELECT id FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT salary FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.level = prod.level
);


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

SELECT amount FROM tasks AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM orders AS whs
    WHERE whs.id = ordr.id
);


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

SELECT code FROM orders AS rgn
WHERE salary > (
    SELECT SUM(value) FROM projects AS sale
    WHERE sale.code = rgn.code
);


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

SELECT amount FROM projects AS inv
WHERE value > (
    SELECT SUM(amount) FROM customers AS budg
    WHERE budg.type = inv.type
);


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

SELECT code FROM tasks AS inv
WHERE code IN (
    SELECT code FROM departments AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT salary FROM customers AS mgr
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS cust
    WHERE cust.id = mgr.id
);


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

SELECT amount FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.type = srvc.type
);


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

SELECT amount FROM branches AS emp
WHERE status IN (
    SELECT status FROM suppliers AS dept
    WHERE dept.level = emp.level
);


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

SELECT value FROM categories AS inv
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS schd
    WHERE schd.status = inv.status
);


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

SELECT salary FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.status = srvc.status
);


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

SELECT code FROM suppliers AS empl
WHERE code IN (
    SELECT code FROM employees AS cust
    WHERE cust.status = empl.status
);


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

SELECT name FROM regions AS catg
WHERE status IN (
    SELECT status FROM shipments AS acct
    WHERE acct.code = catg.code
);


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

SELECT code FROM accounts AS lne
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS dept
    WHERE dept.status = lne.status
);


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

SELECT id FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.status = empl.status
);


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

SELECT name FROM employees AS ordr
WHERE value > (
    SELECT AVG(amount) FROM transactions AS lne
    WHERE lne.status = ordr.status
);


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

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


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

SELECT code FROM departments AS sale
WHERE status IN (
    SELECT status FROM customers AS budg
    WHERE budg.id = sale.id
);


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

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


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

SELECT value FROM branches AS lne
WHERE type IN (
    SELECT type FROM accounts AS schd
    WHERE schd.id = lne.id
);


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

SELECT salary FROM employees AS lne
WHERE level IN (
    SELECT level FROM transactions AS whs
    WHERE whs.level = lne.level
);


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

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


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

SELECT value FROM branches AS acct
WHERE salary > (
    SELECT MIN(amount) FROM projects AS whs
    WHERE whs.code = acct.code
);


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

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


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

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


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

SELECT value FROM tasks AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM employees AS acct
    WHERE acct.code = inv.code
);


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

SELECT name FROM branches AS mgr
WHERE salary > (
    SELECT MIN(amount) FROM orders AS rgn
    WHERE rgn.level = mgr.level
);


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

SELECT amount FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = mgr.level
);


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

SELECT name FROM orders AS cust
WHERE status IN (
    SELECT status FROM transactions AS catg
    WHERE catg.level = cust.level
);


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

SELECT salary FROM tasks AS emp
WHERE level IN (
    SELECT level FROM categories AS shp
    WHERE shp.code = emp.code
);


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

SELECT value FROM warehouses AS inv
WHERE status IN (
    SELECT status FROM projects AS cust
    WHERE cust.code = inv.code
);


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

SELECT value FROM branches AS rgn
WHERE type IN (
    SELECT type FROM regions AS inv
    WHERE inv.type = rgn.type
);


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

SELECT code FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.type = mgr.type
);


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

SELECT amount FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.code = whs.code
);


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

SELECT id FROM accounts AS ordr
WHERE value > (
    SELECT SUM(value) FROM tasks AS empl
    WHERE empl.id = ordr.id
);


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

SELECT amount FROM accounts AS prod
WHERE code IN (
    SELECT code FROM transactions AS empl
    WHERE empl.status = prod.status
);


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

SELECT amount FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = rgn.code
);


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

SELECT id FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.code = emp.code
);


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

SELECT salary FROM employees AS inv
WHERE type IN (
    SELECT type FROM customers AS txn
    WHERE txn.level = inv.level
);


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

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


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

SELECT amount FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.id = whs.id
);


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

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


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

SELECT code FROM shipments AS emp
WHERE salary > (
    SELECT MAX(amount) FROM regions AS sale
    WHERE sale.type = emp.type
);


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

SELECT id FROM employees AS prod
WHERE type IN (
    SELECT type FROM invoices AS ordr
    WHERE ordr.code = prod.code
);


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

SELECT name FROM categories AS acct
WHERE salary > (
    SELECT MAX(salary) FROM orders AS dept
    WHERE dept.id = acct.id
);


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

SELECT salary FROM orders AS budg
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT code FROM customers AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS txn
    WHERE txn.type = rgn.type
);


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

SELECT code FROM tasks AS prod
WHERE salary > (
    SELECT MAX(amount) FROM customers AS txn
    WHERE txn.status = prod.status
);


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

SELECT code FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.status = prod.status
);


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

SELECT value FROM regions AS ord
WHERE amount > (
    SELECT MAX(value) FROM departments AS prod
    WHERE prod.id = ord.id
);


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

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


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

SELECT name FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.id = lne.id
);


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

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


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

SELECT name FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT amount FROM regions AS empl
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS emp
    WHERE emp.level = empl.level
);


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

SELECT name FROM tasks AS acct
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS shp
    WHERE shp.type = acct.type
);


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

SELECT amount FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = srvc.level
);


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

SELECT value FROM accounts AS prod
WHERE value > (
    SELECT SUM(value) FROM departments AS sale
    WHERE sale.level = prod.level
);


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

SELECT value FROM customers AS srvc
WHERE type IN (
    SELECT type FROM employees AS catg
    WHERE catg.code = srvc.code
);


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

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


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

SELECT salary FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT salary FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.type = txn.type
);


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

SELECT salary FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT salary FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.level = ord.level
);


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

SELECT id FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.code = sale.code
);


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

SELECT amount FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.status = catg.status
);


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

SELECT value FROM orders AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM shipments AS inv
    WHERE inv.id = mgr.id
);


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

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


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

SELECT code FROM shipments AS catg
WHERE amount > (
    SELECT MAX(salary) FROM orders AS emp
    WHERE emp.code = catg.code
);


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

SELECT id FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.code = lne.code
);


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

SELECT code FROM projects AS catg
WHERE value > (
    SELECT MIN(salary) FROM transactions AS sale
    WHERE sale.status = catg.status
);


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

SELECT value FROM departments AS schd
WHERE code IN (
    SELECT code FROM orders AS ord
    WHERE ord.status = schd.status
);


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

SELECT code FROM products AS empl
WHERE status IN (
    SELECT status FROM orders AS ordr
    WHERE ordr.type = empl.type
);


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

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


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

SELECT name FROM projects AS cust
WHERE value > (
    SELECT MIN(value) FROM invoices AS shp
    WHERE shp.level = cust.level
);


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

SELECT amount FROM departments AS cust
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS srvc
    WHERE srvc.type = cust.type
);


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

SELECT salary FROM accounts AS rgn
WHERE id IN (
    SELECT id FROM employees AS schd
    WHERE schd.code = rgn.code
);


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

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


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

SELECT salary FROM suppliers AS cust
WHERE value > (
    SELECT AVG(salary) FROM customers AS budg
    WHERE budg.type = cust.type
);


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

SELECT id FROM accounts AS inv
WHERE id IN (
    SELECT id FROM products AS srvc
    WHERE srvc.id = inv.id
);


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

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


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

SELECT amount FROM products AS schd
WHERE type IN (
    SELECT type FROM suppliers AS budg
    WHERE budg.level = schd.level
);


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

SELECT value FROM invoices AS sale
WHERE type IN (
    SELECT type FROM branches AS prod
    WHERE prod.status = sale.status
);


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

SELECT amount FROM shipments AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS lne
    WHERE lne.status = shp.status
);


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

SELECT id FROM branches AS shp
WHERE amount > (
    SELECT COUNT(value) FROM projects AS inv
    WHERE inv.type = shp.type
);


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

SELECT salary FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.code = shp.code
);


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

SELECT salary FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.type = dept.type
);


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

SELECT id FROM invoices AS sale
WHERE level IN (
    SELECT level FROM suppliers AS emp
    WHERE emp.level = sale.level
);


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

SELECT salary FROM invoices AS empl
WHERE salary > (
    SELECT SUM(amount) FROM regions AS prod
    WHERE prod.level = empl.level
);


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

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


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

SELECT id FROM shipments AS budg
WHERE level IN (
    SELECT level FROM departments AS inv
    WHERE inv.type = budg.type
);


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

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


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

SELECT amount FROM projects AS txn
WHERE amount > (
    SELECT COUNT(value) FROM branches AS catg
    WHERE catg.status = txn.status
);


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

SELECT id FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.code = whs.code
);


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

SELECT name FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.status = ordr.status
);


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

SELECT name FROM accounts AS ord
WHERE type IN (
    SELECT type FROM transactions AS shp
    WHERE shp.status = ord.status
);


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

SELECT amount FROM tasks AS sale
WHERE code IN (
    SELECT code FROM categories AS whs
    WHERE whs.id = sale.id
);


Prompt:
Schema:
  shipments (alias: txn)(code, level, status, type)
  customers(id, amount, level, name)
Task: Retrieve code from shipments with amount above the SUM(amount) of customers rows sharing the same code.
SQL:

SELECT code FROM shipments AS txn
WHERE amount > (
    SELECT SUM(amount) FROM customers AS acct
    WHERE acct.code = txn.code
);


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

SELECT amount FROM projects AS lne
WHERE type IN (
    SELECT type FROM products AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT code FROM departments AS whs
WHERE value > (
    SELECT SUM(amount) FROM categories AS prod
    WHERE prod.level = whs.level
);


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

SELECT amount FROM invoices AS cust
WHERE code IN (
    SELECT code FROM departments AS srvc
    WHERE srvc.type = cust.type
);


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

SELECT id FROM suppliers AS shp
WHERE amount > (
    SELECT COUNT(value) FROM transactions AS ord
    WHERE ord.level = shp.level
);


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

SELECT id FROM transactions AS dept
WHERE level IN (
    SELECT level FROM categories AS txn
    WHERE txn.status = dept.status
);


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

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


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

SELECT name FROM warehouses AS dept
WHERE type IN (
    SELECT type FROM employees AS sale
    WHERE sale.id = dept.id
);


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

SELECT code FROM departments AS lne
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS emp
    WHERE emp.type = lne.type
);


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

SELECT salary FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.id = srvc.id
);


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

SELECT salary FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.type = catg.type
);


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

SELECT salary FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.code = ordr.code
);


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

SELECT salary FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.id = inv.id
);


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

SELECT code FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = emp.type
);


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

SELECT code FROM branches AS prod
WHERE salary > (
    SELECT COUNT(amount) FROM shipments AS emp
    WHERE emp.status = prod.status
);


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

SELECT id FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.code = acct.code
);


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

SELECT id FROM customers AS schd
WHERE salary > (
    SELECT SUM(value) FROM shipments AS budg
    WHERE budg.status = schd.status
);


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

SELECT value FROM tasks AS schd
WHERE amount > (
    SELECT SUM(value) FROM regions AS catg
    WHERE catg.type = schd.type
);


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

SELECT code FROM transactions AS emp
WHERE status IN (
    SELECT status FROM accounts AS catg
    WHERE catg.status = emp.status
);


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

SELECT value FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.type = whs.type
);


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

SELECT id FROM tasks AS empl
WHERE id IN (
    SELECT id FROM orders AS acct
    WHERE acct.level = empl.level
);


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

SELECT amount FROM orders AS srvc
WHERE salary > (
    SELECT AVG(value) FROM regions AS empl
    WHERE empl.status = srvc.status
);


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

SELECT amount FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.level = inv.level
);


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

SELECT amount FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.level = ordr.level
);


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

SELECT name FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = prod.id
);


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

SELECT code FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.level = ord.level
);


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

SELECT id FROM branches AS lne
WHERE amount > (
    SELECT SUM(amount) FROM transactions AS dept
    WHERE dept.status = lne.status
);


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

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


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.level = whs.level
);


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

SELECT name FROM departments AS sale
WHERE status IN (
    SELECT status FROM branches AS lne
    WHERE lne.id = sale.id
);


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

SELECT id FROM categories AS rgn
WHERE value > (
    SELECT MAX(amount) FROM invoices AS inv
    WHERE inv.status = rgn.status
);


Prompt:
Schema:
  departments (alias: ordr)(value, salary, code, id)
  invoices(salary, date, value, code)
Task: Find salary from departments where code appears in invoices entries with matching code.
SQL:

SELECT salary FROM departments AS ordr
WHERE code IN (
    SELECT code FROM invoices AS prod
    WHERE prod.code = ordr.code
);


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

SELECT value FROM projects AS mgr
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.id = mgr.id
);


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

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


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

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


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

SELECT salary FROM employees AS srvc
WHERE salary > (
    SELECT AVG(value) FROM categories AS rgn
    WHERE rgn.type = srvc.type
);


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

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


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

SELECT amount FROM employees AS sale
WHERE amount > (
    SELECT MAX(value) FROM categories AS shp
    WHERE shp.type = sale.type
);


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

SELECT id FROM accounts AS prod
WHERE salary > (
    SELECT AVG(amount) FROM orders AS ord
    WHERE ord.type = prod.type
);


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

SELECT value FROM tasks AS shp
WHERE salary > (
    SELECT SUM(amount) FROM warehouses AS lne
    WHERE lne.level = shp.level
);


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

SELECT amount FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT name FROM regions AS budg
WHERE value > (
    SELECT MAX(amount) FROM orders AS mgr
    WHERE mgr.id = budg.id
);


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

SELECT amount FROM branches AS txn
WHERE value > (
    SELECT COUNT(amount) FROM categories AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT name FROM branches AS catg
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.status = catg.status
);


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

SELECT code FROM projects AS shp
WHERE code IN (
    SELECT code FROM employees AS dept
    WHERE dept.level = shp.level
);


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

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


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

SELECT salary FROM regions AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS catg
    WHERE catg.level = rgn.level
);


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

SELECT salary FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.type = srvc.type
);


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

SELECT salary FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.code = ordr.code
);


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

SELECT name FROM shipments AS inv
WHERE type IN (
    SELECT type FROM transactions AS shp
    WHERE shp.level = inv.level
);


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

SELECT salary FROM products AS prod
WHERE code IN (
    SELECT code FROM orders AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT value FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.id = mgr.id
);


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

SELECT code FROM employees AS emp
WHERE status IN (
    SELECT status FROM shipments AS whs
    WHERE whs.status = emp.status
);


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

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


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

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


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

SELECT code FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.code = empl.code
);


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

SELECT name FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.type = empl.type
);


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

SELECT salary FROM accounts AS srvc
WHERE level IN (
    SELECT level FROM transactions AS cust
    WHERE cust.type = srvc.type
);


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

SELECT value FROM accounts AS emp
WHERE salary > (
    SELECT SUM(amount) FROM projects AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT name FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT amount FROM regions AS emp
WHERE id IN (
    SELECT id FROM shipments AS budg
    WHERE budg.level = emp.level
);


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

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


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

SELECT amount FROM regions AS mgr
WHERE amount > (
    SELECT AVG(salary) FROM branches AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT amount FROM transactions AS mgr
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.level = mgr.level
);


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

SELECT code FROM invoices AS acct
WHERE id IN (
    SELECT id FROM employees AS txn
    WHERE txn.code = acct.code
);


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

SELECT name FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.id = catg.id
);


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

SELECT value FROM categories AS empl
WHERE value > (
    SELECT MAX(value) FROM products AS acct
    WHERE acct.status = empl.status
);


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

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


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

SELECT salary FROM accounts AS emp
WHERE status IN (
    SELECT status FROM warehouses AS empl
    WHERE empl.status = emp.status
);


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

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


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

SELECT code FROM projects AS catg
WHERE code IN (
    SELECT code FROM departments AS shp
    WHERE shp.id = catg.id
);


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

SELECT amount FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.status = ord.status
);


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

SELECT name FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.status = sale.status
);


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

SELECT salary FROM invoices AS budg
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.status = budg.status
);


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

SELECT amount FROM departments AS budg
WHERE id IN (
    SELECT id FROM branches AS sale
    WHERE sale.id = budg.id
);


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

SELECT value FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.id = dept.id
);


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

SELECT value FROM categories AS emp
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS inv
    WHERE inv.type = emp.type
);


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

SELECT name FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.code = sale.code
);


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

SELECT name FROM branches AS lne
WHERE code IN (
    SELECT code FROM invoices AS budg
    WHERE budg.status = lne.status
);


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

SELECT value FROM tasks AS prod
WHERE amount > (
    SELECT MIN(value) FROM departments AS sale
    WHERE sale.code = prod.code
);


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

SELECT amount FROM suppliers AS prod
WHERE status IN (
    SELECT status FROM accounts AS empl
    WHERE empl.status = prod.status
);


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

SELECT code FROM tasks AS sale
WHERE salary > (
    SELECT SUM(amount) FROM departments AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT code FROM products AS srvc
WHERE code IN (
    SELECT code FROM suppliers AS inv
    WHERE inv.type = srvc.type
);


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

SELECT code FROM orders AS mgr
WHERE code IN (
    SELECT code FROM customers AS whs
    WHERE whs.id = mgr.id
);


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

SELECT value FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.id = dept.id
);


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

SELECT code FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.id = acct.id
);


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

SELECT value FROM products AS schd
WHERE value > (
    SELECT AVG(value) FROM customers AS prod
    WHERE prod.level = schd.level
);


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

SELECT amount FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.status = acct.status
);


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

SELECT id FROM departments AS prod
WHERE type IN (
    SELECT type FROM categories AS ord
    WHERE ord.id = prod.id
);


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

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


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

SELECT value FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.code = cust.code
);


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

SELECT name FROM invoices AS lne
WHERE code IN (
    SELECT code FROM projects AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT id FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.status = cust.status
);


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

SELECT code FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.code = prod.code
);


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

SELECT salary FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.id = sale.id
);


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

SELECT code FROM departments AS schd
WHERE value > (
    SELECT SUM(amount) FROM shipments AS sale
    WHERE sale.type = schd.type
);


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

SELECT amount FROM invoices AS inv
WHERE status IN (
    SELECT status FROM tasks AS whs
    WHERE whs.level = inv.level
);


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

SELECT id FROM projects AS empl
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS shp
    WHERE shp.status = empl.status
);


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

SELECT value FROM accounts AS cust
WHERE amount > (
    SELECT SUM(amount) FROM departments AS budg
    WHERE budg.type = cust.type
);


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

SELECT value FROM suppliers AS prod
WHERE value > (
    SELECT COUNT(amount) FROM departments AS inv
    WHERE inv.id = prod.id
);


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

SELECT amount FROM departments AS emp
WHERE id IN (
    SELECT id FROM suppliers AS shp
    WHERE shp.type = emp.type
);


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

SELECT amount FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.type = srvc.type
);


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

SELECT value FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.id = mgr.id
);


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

SELECT value FROM products AS acct
WHERE value > (
    SELECT SUM(amount) FROM orders AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT code FROM shipments AS prod
WHERE value > (
    SELECT AVG(value) FROM transactions AS dept
    WHERE dept.status = prod.status
);


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

SELECT name FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.id = budg.id
);


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

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


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

SELECT amount FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.status = sale.status
);


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

SELECT amount FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.id = shp.id
);


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

SELECT amount FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.status = ordr.status
);


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

SELECT id FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.status = rgn.status
);


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

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


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

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


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

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


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

SELECT name FROM categories AS rgn
WHERE id IN (
    SELECT id FROM warehouses AS schd
    WHERE schd.level = rgn.level
);


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

SELECT value FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.status = dept.status
);


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

SELECT id FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.code = budg.code
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.type = ord.type
);


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

SELECT value FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.id = acct.id
);