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

SELECT value FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.code = sale.code
);


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

SELECT salary FROM accounts AS sale
WHERE id IN (
    SELECT id FROM suppliers AS acct
    WHERE acct.status = sale.status
);


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

SELECT name FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.level = srvc.level
);


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

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


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

SELECT amount FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.level = inv.level
);


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

SELECT value FROM regions AS cust
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS srvc
    WHERE srvc.id = cust.id
);


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

SELECT id FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.level = sale.level
);


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

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


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

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


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

SELECT name FROM orders AS rgn
WHERE salary > (
    SELECT MAX(value) FROM employees AS cust
    WHERE cust.code = rgn.code
);


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

SELECT amount FROM customers AS inv
WHERE level IN (
    SELECT level FROM accounts AS dept
    WHERE dept.code = inv.code
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.status = cust.status
);


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

SELECT code FROM departments AS acct
WHERE code IN (
    SELECT code FROM categories AS mgr
    WHERE mgr.type = acct.type
);


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

SELECT salary FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.id = cust.id
);


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

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


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

SELECT amount FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT name FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.status = inv.status
);


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

SELECT amount FROM regions AS schd
WHERE id IN (
    SELECT id FROM transactions AS txn
    WHERE txn.status = schd.status
);


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

SELECT salary FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.level = catg.level
);


Prompt:
Schema:
  projects (alias: sale)(status, name, amount, type)
  branches(name, type, date, value)
Task: Retrieve value from projects with value above the MAX(amount) of branches rows sharing the same type.
SQL:

SELECT value FROM projects AS sale
WHERE value > (
    SELECT MAX(amount) FROM branches AS prod
    WHERE prod.type = sale.type
);


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

SELECT id FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT id FROM branches AS cust
WHERE id IN (
    SELECT id FROM warehouses AS ord
    WHERE ord.id = cust.id
);


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

SELECT value FROM departments AS whs
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS emp
    WHERE emp.type = whs.type
);


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

SELECT value FROM accounts AS acct
WHERE type IN (
    SELECT type FROM employees AS txn
    WHERE txn.level = acct.level
);


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

SELECT salary FROM projects AS empl
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS emp
    WHERE emp.code = empl.code
);


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

SELECT value FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.type = budg.type
);


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

SELECT amount FROM regions AS whs
WHERE id IN (
    SELECT id FROM transactions AS ord
    WHERE ord.level = whs.level
);


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

SELECT amount FROM departments AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS cust
    WHERE cust.level = ordr.level
);


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

SELECT value FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.level = catg.level
);


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

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


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

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


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

SELECT salary FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM transactions AS budg
    WHERE budg.type = ordr.type
);


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

SELECT value FROM orders AS whs
WHERE salary > (
    SELECT AVG(amount) FROM departments AS prod
    WHERE prod.id = whs.id
);


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

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


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

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


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

SELECT amount FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.type = empl.type
);


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

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


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

SELECT value FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.status = mgr.status
);


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

SELECT name FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = dept.id
);


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

SELECT id FROM warehouses AS prod
WHERE code IN (
    SELECT code FROM employees AS cust
    WHERE cust.type = prod.type
);


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

SELECT name FROM employees AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM invoices AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT salary FROM warehouses AS schd
WHERE value > (
    SELECT MIN(salary) FROM tasks AS cust
    WHERE cust.id = schd.id
);


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

SELECT name FROM accounts AS budg
WHERE status IN (
    SELECT status FROM categories AS emp
    WHERE emp.type = budg.type
);


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

SELECT salary FROM departments AS shp
WHERE status IN (
    SELECT status FROM shipments AS inv
    WHERE inv.status = shp.status
);


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

SELECT id FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.status = budg.status
);


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

SELECT amount FROM orders AS srvc
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS rgn
    WHERE rgn.type = srvc.type
);


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

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


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

SELECT salary FROM regions AS inv
WHERE value > (
    SELECT MIN(value) FROM suppliers AS lne
    WHERE lne.type = inv.type
);


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

SELECT name FROM employees AS ordr
WHERE code IN (
    SELECT code FROM invoices AS budg
    WHERE budg.status = ordr.status
);


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

SELECT id FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.status = ordr.status
);


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

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


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

SELECT salary FROM regions AS emp
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS inv
    WHERE inv.id = emp.id
);


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

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


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

SELECT amount FROM accounts AS lne
WHERE code IN (
    SELECT code FROM customers AS srvc
    WHERE srvc.status = lne.status
);


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

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


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

SELECT salary FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.status = sale.status
);


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

SELECT id FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.status = whs.status
);


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

SELECT id FROM employees AS shp
WHERE level IN (
    SELECT level FROM products AS schd
    WHERE schd.status = shp.status
);


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

SELECT amount FROM invoices AS shp
WHERE id IN (
    SELECT id FROM products AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT id FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.level = acct.level
);


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

SELECT code FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM employees AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT value FROM invoices AS cust
WHERE id IN (
    SELECT id FROM accounts AS rgn
    WHERE rgn.level = cust.level
);


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

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


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

SELECT value FROM products AS dept
WHERE status IN (
    SELECT status FROM projects AS sale
    WHERE sale.code = dept.code
);


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

SELECT code FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = emp.status
);


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

SELECT name FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.type = whs.type
);


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

SELECT id FROM branches AS dept
WHERE value > (
    SELECT SUM(value) FROM suppliers AS txn
    WHERE txn.code = dept.code
);


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

SELECT salary FROM branches AS budg
WHERE level IN (
    SELECT level FROM categories AS prod
    WHERE prod.status = budg.status
);


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

SELECT value FROM tasks AS sale
WHERE type IN (
    SELECT type FROM transactions AS shp
    WHERE shp.type = sale.type
);


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

SELECT name FROM categories AS cust
WHERE status IN (
    SELECT status FROM orders AS dept
    WHERE dept.code = cust.code
);


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

SELECT name FROM projects AS lne
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS cust
    WHERE cust.status = lne.status
);


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

SELECT name FROM regions AS whs
WHERE type IN (
    SELECT type FROM tasks AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT name FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.level = budg.level
);


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

SELECT value FROM accounts AS shp
WHERE amount > (
    SELECT SUM(salary) FROM orders AS mgr
    WHERE mgr.id = shp.id
);


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

SELECT amount FROM transactions AS srvc
WHERE amount > (
    SELECT MAX(amount) FROM regions AS shp
    WHERE shp.code = srvc.code
);


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

SELECT code FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.level = dept.level
);


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

SELECT code FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.status = schd.status
);


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

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


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

SELECT name FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.level = whs.level
);


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

SELECT id FROM customers AS srvc
WHERE value > (
    SELECT COUNT(amount) FROM departments AS catg
    WHERE catg.code = srvc.code
);


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

SELECT name FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.status = srvc.status
);


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

SELECT id FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.id = rgn.id
);


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

SELECT salary FROM departments AS ord
WHERE status IN (
    SELECT status FROM branches AS sale
    WHERE sale.type = ord.type
);


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

SELECT amount FROM employees AS prod
WHERE type IN (
    SELECT type FROM customers AS empl
    WHERE empl.status = prod.status
);


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

SELECT amount FROM tasks AS dept
WHERE type IN (
    SELECT type FROM branches AS budg
    WHERE budg.status = dept.status
);


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

SELECT code FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.type = txn.type
);


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

SELECT id FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.status = budg.status
);


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

SELECT id FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT code FROM regions AS empl
WHERE status IN (
    SELECT status FROM orders AS budg
    WHERE budg.level = empl.level
);


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

SELECT value FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.code = schd.code
);


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

SELECT value FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.code = ordr.code
);


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

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


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

SELECT salary FROM products AS ord
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS cust
    WHERE cust.level = ord.level
);


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

SELECT salary FROM departments AS ordr
WHERE amount > (
    SELECT MIN(value) FROM employees AS whs
    WHERE whs.level = ordr.level
);


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

SELECT name FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.code = lne.code
);


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

SELECT id FROM orders AS whs
WHERE amount > (
    SELECT MIN(salary) FROM suppliers AS dept
    WHERE dept.code = whs.code
);


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

SELECT id FROM accounts AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS prod
    WHERE prod.code = sale.code
);


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

SELECT salary FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.type = acct.type
);


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

SELECT id FROM categories AS mgr
WHERE value > (
    SELECT MIN(salary) FROM accounts AS txn
    WHERE txn.level = mgr.level
);


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

SELECT name FROM accounts AS whs
WHERE level IN (
    SELECT level FROM customers AS dept
    WHERE dept.code = whs.code
);


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

SELECT name FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = whs.level
);


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

SELECT name FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.type = dept.type
);


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

SELECT salary FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.level = inv.level
);


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

SELECT name FROM shipments AS rgn
WHERE level IN (
    SELECT level FROM transactions AS txn
    WHERE txn.status = rgn.status
);


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

SELECT salary FROM customers AS catg
WHERE code IN (
    SELECT code FROM tasks AS inv
    WHERE inv.level = catg.level
);


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

SELECT id FROM transactions AS cust
WHERE amount > (
    SELECT SUM(salary) FROM categories AS budg
    WHERE budg.code = cust.code
);


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

SELECT name FROM transactions AS ord
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS schd
    WHERE schd.status = ord.status
);


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

SELECT amount FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.id = inv.id
);


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

SELECT salary FROM branches AS rgn
WHERE type IN (
    SELECT type FROM suppliers AS emp
    WHERE emp.level = rgn.level
);


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

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


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

SELECT code FROM branches AS catg
WHERE status IN (
    SELECT status FROM shipments AS sale
    WHERE sale.code = catg.code
);


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

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


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

SELECT amount FROM departments AS txn
WHERE status IN (
    SELECT status FROM products AS prod
    WHERE prod.level = txn.level
);


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

SELECT id FROM departments AS inv
WHERE amount > (
    SELECT MAX(value) FROM branches AS schd
    WHERE schd.level = inv.level
);


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

SELECT salary FROM transactions AS srvc
WHERE amount > (
    SELECT MAX(value) FROM projects AS cust
    WHERE cust.status = srvc.status
);


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

SELECT id FROM categories AS ordr
WHERE code IN (
    SELECT code FROM invoices AS emp
    WHERE emp.level = ordr.level
);


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

SELECT salary FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT id FROM customers AS budg
WHERE type IN (
    SELECT type FROM transactions AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT value FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.type = prod.type
);


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

SELECT name FROM transactions AS mgr
WHERE value > (
    SELECT AVG(value) FROM employees AS whs
    WHERE whs.status = mgr.status
);


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

SELECT id FROM departments AS lne
WHERE salary > (
    SELECT AVG(amount) FROM employees AS rgn
    WHERE rgn.status = lne.status
);


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

SELECT value FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.id = ordr.id
);


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

SELECT salary FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.status = ord.status
);


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

SELECT code FROM warehouses AS inv
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS shp
    WHERE shp.type = inv.type
);


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

SELECT code FROM transactions AS shp
WHERE amount > (
    SELECT AVG(value) FROM categories AS dept
    WHERE dept.id = shp.id
);


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

SELECT code FROM departments AS cust
WHERE salary > (
    SELECT AVG(value) FROM employees AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.code = whs.code
);


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

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


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

SELECT salary FROM products AS ord
WHERE amount > (
    SELECT AVG(amount) FROM categories AS inv
    WHERE inv.type = ord.type
);


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

SELECT id FROM shipments AS srvc
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS inv
    WHERE inv.status = srvc.status
);


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

SELECT amount FROM invoices AS emp
WHERE type IN (
    SELECT type FROM transactions AS inv
    WHERE inv.level = emp.level
);


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

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


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

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


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

SELECT value FROM warehouses AS catg
WHERE code IN (
    SELECT code FROM regions AS cust
    WHERE cust.type = catg.type
);


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

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


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

SELECT amount FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.status = srvc.status
);


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

SELECT id FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT amount FROM suppliers AS prod
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS inv
    WHERE inv.type = prod.type
);


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

SELECT amount FROM invoices AS cust
WHERE value > (
    SELECT MIN(salary) FROM regions AS inv
    WHERE inv.id = cust.id
);


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

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


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

SELECT id FROM invoices AS empl
WHERE level IN (
    SELECT level FROM warehouses AS acct
    WHERE acct.type = empl.type
);


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

SELECT id FROM tasks AS schd
WHERE salary > (
    SELECT AVG(value) FROM employees AS cust
    WHERE cust.level = schd.level
);


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

SELECT code FROM invoices AS whs
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS cust
    WHERE cust.status = whs.status
);


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

SELECT name FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.code = whs.code
);


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

SELECT value FROM branches AS acct
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS catg
    WHERE catg.type = acct.type
);


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

SELECT amount FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.level = mgr.level
);


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

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


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

SELECT amount FROM transactions AS lne
WHERE type IN (
    SELECT type FROM shipments AS schd
    WHERE schd.level = lne.level
);


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

SELECT name FROM branches AS catg
WHERE status IN (
    SELECT status FROM categories AS acct
    WHERE acct.id = catg.id
);


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

SELECT value FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.id = prod.id
);


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

SELECT name FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.code = inv.code
);


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

SELECT amount FROM warehouses AS cust
WHERE value > (
    SELECT MAX(value) FROM shipments AS empl
    WHERE empl.status = cust.status
);


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

SELECT id FROM employees AS sale
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS whs
    WHERE whs.code = sale.code
);


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

SELECT value FROM branches AS ordr
WHERE status IN (
    SELECT status FROM invoices AS catg
    WHERE catg.level = ordr.level
);


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

SELECT salary FROM categories AS ord
WHERE value > (
    SELECT MIN(value) FROM transactions AS shp
    WHERE shp.status = ord.status
);


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

SELECT value FROM shipments AS budg
WHERE status IN (
    SELECT status FROM warehouses AS prod
    WHERE prod.id = budg.id
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.level = prod.level
);


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

SELECT value FROM projects AS schd
WHERE status IN (
    SELECT status FROM customers AS dept
    WHERE dept.level = schd.level
);


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

SELECT salary FROM tasks AS prod
WHERE value > (
    SELECT AVG(amount) FROM regions AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT code FROM shipments AS dept
WHERE type IN (
    SELECT type FROM transactions AS txn
    WHERE txn.id = dept.id
);


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

SELECT amount FROM products AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM categories AS dept
    WHERE dept.status = rgn.status
);


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

SELECT name FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.type = emp.type
);


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

SELECT value FROM regions AS budg
WHERE amount > (
    SELECT SUM(amount) FROM customers AS ord
    WHERE ord.level = budg.level
);


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

SELECT amount FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.status = mgr.status
);


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

SELECT code FROM accounts AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM projects AS rgn
    WHERE rgn.status = ordr.status
);


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

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


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

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


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

SELECT name FROM shipments AS cust
WHERE level IN (
    SELECT level FROM warehouses AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT amount FROM transactions AS acct
WHERE value > (
    SELECT MAX(value) FROM customers AS cust
    WHERE cust.code = acct.code
);


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

SELECT value FROM suppliers AS acct
WHERE level IN (
    SELECT level FROM accounts AS lne
    WHERE lne.code = acct.code
);


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

SELECT id FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.level = srvc.level
);


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

SELECT value FROM orders AS shp
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS schd
    WHERE schd.code = shp.code
);


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

SELECT salary FROM customers AS ord
WHERE value > (
    SELECT COUNT(salary) FROM employees AS whs
    WHERE whs.level = ord.level
);


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

SELECT amount FROM accounts AS catg
WHERE level IN (
    SELECT level FROM departments AS cust
    WHERE cust.status = catg.status
);


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

SELECT value FROM invoices AS inv
WHERE type IN (
    SELECT type FROM warehouses AS sale
    WHERE sale.id = inv.id
);


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

SELECT id FROM invoices AS shp
WHERE type IN (
    SELECT type FROM branches AS whs
    WHERE whs.level = shp.level
);


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

SELECT id FROM tasks AS shp
WHERE amount > (
    SELECT MAX(amount) FROM customers AS budg
    WHERE budg.id = shp.id
);


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

SELECT name FROM accounts AS srvc
WHERE amount > (
    SELECT AVG(amount) FROM customers AS lne
    WHERE lne.status = srvc.status
);


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

SELECT id FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.id = rgn.id
);


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

SELECT code FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.type = ordr.type
);


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

SELECT amount FROM employees AS empl
WHERE value > (
    SELECT COUNT(amount) FROM regions AS budg
    WHERE budg.type = empl.type
);


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

SELECT name FROM products AS txn
WHERE value > (
    SELECT AVG(salary) FROM accounts AS empl
    WHERE empl.id = txn.id
);


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

SELECT salary FROM accounts AS schd
WHERE salary > (
    SELECT SUM(value) FROM projects AS budg
    WHERE budg.id = schd.id
);


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

SELECT amount FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.level = schd.level
);


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

SELECT code FROM departments AS mgr
WHERE id IN (
    SELECT id FROM products AS cust
    WHERE cust.code = mgr.code
);


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

SELECT amount FROM employees AS rgn
WHERE amount > (
    SELECT AVG(value) FROM products AS emp
    WHERE emp.level = rgn.level
);


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

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


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

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


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

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


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

SELECT id FROM invoices AS txn
WHERE amount > (
    SELECT COUNT(value) FROM customers AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT value FROM products AS dept
WHERE code IN (
    SELECT code FROM categories AS lne
    WHERE lne.level = dept.level
);


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

SELECT code FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT amount FROM warehouses AS prod
WHERE status IN (
    SELECT status FROM invoices AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT salary FROM regions AS txn
WHERE id IN (
    SELECT id FROM products AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT id FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT code FROM branches AS prod
WHERE type IN (
    SELECT type FROM departments AS inv
    WHERE inv.id = prod.id
);


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

SELECT code FROM departments AS ord
WHERE type IN (
    SELECT type FROM transactions AS lne
    WHERE lne.status = ord.status
);


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

SELECT amount FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.type = emp.type
);


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

SELECT id FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.status = inv.status
);


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

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


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

SELECT value FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.type = budg.type
);


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

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


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

SELECT value FROM accounts AS rgn
WHERE code IN (
    SELECT code FROM customers AS dept
    WHERE dept.id = rgn.id
);


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

SELECT code FROM transactions AS inv
WHERE status IN (
    SELECT status FROM orders AS shp
    WHERE shp.level = inv.level
);


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

SELECT salary FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.status = srvc.status
);


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

SELECT name FROM branches AS cust
WHERE amount > (
    SELECT MIN(salary) FROM products AS empl
    WHERE empl.type = cust.type
);


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

SELECT value FROM invoices AS empl
WHERE id IN (
    SELECT id FROM suppliers AS whs
    WHERE whs.id = empl.id
);


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

SELECT value FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.status = emp.status
);


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

SELECT id FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.level = schd.level
);


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

SELECT name FROM invoices AS whs
WHERE salary > (
    SELECT MIN(amount) FROM tasks AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT salary FROM warehouses AS txn
WHERE code IN (
    SELECT code FROM orders AS mgr
    WHERE mgr.code = txn.code
);


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

SELECT id FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.status = cust.status
);


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

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


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

SELECT value FROM regions AS rgn
WHERE type IN (
    SELECT type FROM shipments AS acct
    WHERE acct.id = rgn.id
);


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

SELECT name FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.status = dept.status
);


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

SELECT value FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.type = lne.type
);


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

SELECT salary FROM suppliers AS inv
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.status = inv.status
);


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

SELECT name FROM departments AS shp
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS txn
    WHERE txn.level = shp.level
);


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

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


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

SELECT amount FROM tasks AS lne
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS empl
    WHERE empl.level = lne.level
);


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

SELECT amount FROM categories AS cust
WHERE level IN (
    SELECT level FROM employees AS budg
    WHERE budg.level = cust.level
);


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

SELECT id FROM warehouses AS inv
WHERE level IN (
    SELECT level FROM tasks AS catg
    WHERE catg.code = inv.code
);


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

SELECT name FROM branches AS shp
WHERE amount > (
    SELECT AVG(value) FROM employees AS ordr
    WHERE ordr.code = shp.code
);


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

SELECT code FROM departments AS inv
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS schd
    WHERE schd.type = inv.type
);


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

SELECT name FROM departments AS txn
WHERE type IN (
    SELECT type FROM products AS srvc
    WHERE srvc.code = txn.code
);


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

SELECT value FROM regions AS inv
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS txn
    WHERE txn.code = inv.code
);


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

SELECT id FROM regions AS rgn
WHERE status IN (
    SELECT status FROM employees AS lne
    WHERE lne.id = rgn.id
);


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

SELECT code FROM categories AS schd
WHERE value > (
    SELECT MAX(value) FROM departments AS txn
    WHERE txn.type = schd.type
);


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

SELECT name FROM employees AS cust
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT value FROM shipments AS shp
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.id = shp.id
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT code FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.status = acct.status
);


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

SELECT code FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.type = prod.type
);


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

SELECT salary FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.level = inv.level
);


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

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


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

SELECT code FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = whs.level
);


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

SELECT id FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.level = whs.level
);


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

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


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

SELECT salary FROM suppliers AS cust
WHERE amount > (
    SELECT MIN(value) FROM accounts AS emp
    WHERE emp.code = cust.code
);


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

SELECT amount FROM warehouses AS budg
WHERE status IN (
    SELECT status FROM branches AS emp
    WHERE emp.level = budg.level
);


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

SELECT id FROM categories AS emp
WHERE status IN (
    SELECT status FROM products AS schd
    WHERE schd.status = emp.status
);


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

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


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

SELECT id FROM products AS budg
WHERE code IN (
    SELECT code FROM tasks AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT salary FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.status = catg.status
);


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

SELECT salary FROM products AS emp
WHERE id IN (
    SELECT id FROM customers AS shp
    WHERE shp.status = emp.status
);


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

SELECT id FROM warehouses AS catg
WHERE value > (
    SELECT COUNT(amount) FROM regions AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT salary FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.type = inv.type
);


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

SELECT salary FROM warehouses AS budg
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT value FROM warehouses AS whs
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS ord
    WHERE ord.id = whs.id
);


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

SELECT amount FROM orders AS txn
WHERE id IN (
    SELECT id FROM projects AS mgr
    WHERE mgr.type = txn.type
);


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT SUM(salary) FROM orders AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT salary FROM regions AS budg
WHERE value > (
    SELECT MIN(salary) FROM branches AS acct
    WHERE acct.id = budg.id
);


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

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


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

SELECT name FROM warehouses AS lne
WHERE type IN (
    SELECT type FROM tasks AS schd
    WHERE schd.type = lne.type
);


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

SELECT salary FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.status = empl.status
);


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

SELECT name FROM tasks AS ordr
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS dept
    WHERE dept.code = ordr.code
);


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

SELECT id FROM invoices AS mgr
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS emp
    WHERE emp.type = mgr.type
);


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

SELECT salary FROM transactions AS dept
WHERE type IN (
    SELECT type FROM customers AS prod
    WHERE prod.level = dept.level
);


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

SELECT amount FROM regions AS srvc
WHERE type IN (
    SELECT type FROM accounts AS lne
    WHERE lne.code = srvc.code
);


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

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


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

SELECT id FROM invoices AS srvc
WHERE status IN (
    SELECT status FROM accounts AS sale
    WHERE sale.level = srvc.level
);


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

SELECT name FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.type = lne.type
);


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

SELECT name FROM regions AS shp
WHERE level IN (
    SELECT level FROM categories AS acct
    WHERE acct.type = shp.type
);


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

SELECT id FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.status = ord.status
);


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

SELECT code FROM tasks AS dept
WHERE status IN (
    SELECT status FROM products AS catg
    WHERE catg.status = dept.status
);


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

SELECT code FROM invoices AS ord
WHERE id IN (
    SELECT id FROM departments AS shp
    WHERE shp.code = ord.code
);


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

SELECT name FROM branches AS budg
WHERE amount > (
    SELECT COUNT(amount) FROM departments AS emp
    WHERE emp.type = budg.type
);


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

SELECT id FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.code = acct.code
);


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

SELECT name FROM employees AS whs
WHERE value > (
    SELECT SUM(amount) FROM projects AS empl
    WHERE empl.status = whs.status
);


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

SELECT id FROM regions AS empl
WHERE status IN (
    SELECT status FROM products AS schd
    WHERE schd.code = empl.code
);


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

SELECT salary FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.status = schd.status
);


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

SELECT name FROM transactions AS ord
WHERE level IN (
    SELECT level FROM customers AS whs
    WHERE whs.status = ord.status
);


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

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


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

SELECT id FROM categories AS shp
WHERE level IN (
    SELECT level FROM projects AS emp
    WHERE emp.id = shp.id
);


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

SELECT amount FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.level = inv.level
);


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

SELECT code FROM branches AS dept
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.id = dept.id
);


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

SELECT amount FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT code FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.status = inv.status
);


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

SELECT salary FROM transactions AS rgn
WHERE value > (
    SELECT MAX(value) FROM orders AS cust
    WHERE cust.type = rgn.type
);


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

SELECT amount FROM accounts AS acct
WHERE salary > (
    SELECT AVG(salary) FROM categories AS whs
    WHERE whs.type = acct.type
);


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

SELECT code FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.id = srvc.id
);


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

SELECT name FROM transactions AS srvc
WHERE level IN (
    SELECT level FROM departments AS lne
    WHERE lne.level = srvc.level
);


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

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


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

SELECT value FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.code = lne.code
);


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

SELECT salary FROM orders AS lne
WHERE salary > (
    SELECT SUM(value) FROM departments AS acct
    WHERE acct.type = lne.type
);


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

SELECT amount FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.type = ordr.type
);


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

SELECT salary FROM branches AS budg
WHERE code IN (
    SELECT code FROM customers AS prod
    WHERE prod.level = budg.level
);


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

SELECT amount FROM orders AS prod
WHERE code IN (
    SELECT code FROM transactions AS acct
    WHERE acct.level = prod.level
);


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

SELECT code FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT name FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.status = schd.status
);


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

SELECT name FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.id = ord.id
);


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

SELECT name FROM invoices AS mgr
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS acct
    WHERE acct.code = mgr.code
);


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

SELECT name FROM tasks AS ord
WHERE id IN (
    SELECT id FROM employees AS cust
    WHERE cust.id = ord.id
);