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

SELECT name FROM accounts AS rgn
WHERE value > (
    SELECT MAX(salary) FROM projects AS empl
    WHERE empl.type = rgn.type
);


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

SELECT id FROM warehouses AS acct
WHERE status IN (
    SELECT status FROM departments AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT id FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = inv.level
);


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

SELECT code FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.status = catg.status
);


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

SELECT name FROM departments AS sale
WHERE status IN (
    SELECT status FROM suppliers AS shp
    WHERE shp.code = sale.code
);


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

SELECT code FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.type = shp.type
);


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

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


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

SELECT salary FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.code = lne.code
);


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

SELECT id FROM branches AS srvc
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS ordr
    WHERE ordr.code = srvc.code
);


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

SELECT id FROM projects AS cust
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS budg
    WHERE budg.code = cust.code
);


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

SELECT amount FROM tasks AS ord
WHERE value > (
    SELECT MIN(salary) FROM shipments AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT name FROM projects AS catg
WHERE amount > (
    SELECT MIN(value) FROM accounts AS ordr
    WHERE ordr.status = catg.status
);


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

SELECT id FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.code = lne.code
);


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

SELECT code FROM customers AS empl
WHERE amount > (
    SELECT MIN(value) FROM suppliers AS prod
    WHERE prod.type = empl.type
);


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

SELECT id FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.id = txn.id
);


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

SELECT id FROM accounts AS mgr
WHERE status IN (
    SELECT status FROM shipments AS ord
    WHERE ord.level = mgr.level
);


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

SELECT name FROM orders AS emp
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.code = emp.code
);


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

SELECT amount FROM branches AS prod
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS txn
    WHERE txn.type = prod.type
);


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

SELECT id FROM tasks AS ord
WHERE value > (
    SELECT MAX(amount) FROM branches AS txn
    WHERE txn.code = ord.code
);


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

SELECT salary FROM orders AS whs
WHERE amount > (
    SELECT MIN(amount) FROM transactions AS inv
    WHERE inv.level = whs.level
);


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

SELECT name FROM transactions AS sale
WHERE level IN (
    SELECT level FROM suppliers AS whs
    WHERE whs.type = sale.type
);


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

SELECT salary FROM branches AS sale
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS empl
    WHERE empl.type = sale.type
);


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

SELECT amount FROM suppliers AS rgn
WHERE salary > (
    SELECT MAX(value) FROM accounts AS schd
    WHERE schd.status = rgn.status
);


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

SELECT code FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.level = emp.level
);


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

SELECT name FROM projects AS shp
WHERE level IN (
    SELECT level FROM products AS sale
    WHERE sale.type = shp.type
);


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

SELECT code FROM customers AS lne
WHERE level IN (
    SELECT level FROM shipments AS rgn
    WHERE rgn.code = lne.code
);


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

SELECT name FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.type = prod.type
);


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

SELECT id FROM suppliers AS cust
WHERE status IN (
    SELECT status FROM products AS ord
    WHERE ord.level = cust.level
);


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

SELECT amount FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT id FROM accounts AS ordr
WHERE id IN (
    SELECT id FROM transactions AS whs
    WHERE whs.id = ordr.id
);


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

SELECT salary FROM categories AS inv
WHERE salary > (
    SELECT MIN(salary) FROM tasks AS shp
    WHERE shp.id = inv.id
);


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

SELECT name FROM projects AS txn
WHERE salary > (
    SELECT SUM(salary) FROM customers AS dept
    WHERE dept.code = txn.code
);


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

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


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

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


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

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


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

SELECT value FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.status = budg.status
);


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

SELECT salary FROM tasks AS inv
WHERE status IN (
    SELECT status FROM products AS lne
    WHERE lne.id = inv.id
);


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

SELECT id FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.status = txn.status
);


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

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


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

SELECT value FROM regions AS emp
WHERE type IN (
    SELECT type FROM orders AS inv
    WHERE inv.type = emp.type
);


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

SELECT code FROM warehouses AS inv
WHERE id IN (
    SELECT id FROM shipments AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT salary FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.level = whs.level
);


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

SELECT value FROM shipments AS dept
WHERE value > (
    SELECT MAX(salary) FROM transactions AS emp
    WHERE emp.status = dept.status
);


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

SELECT id FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.code = catg.code
);


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

SELECT salary FROM invoices AS prod
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.type = prod.type
);


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

SELECT name FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.id = shp.id
);


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

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


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

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


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

SELECT name FROM tasks AS mgr
WHERE type IN (
    SELECT type FROM projects AS lne
    WHERE lne.id = mgr.id
);


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

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


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

SELECT id FROM categories AS txn
WHERE level IN (
    SELECT level FROM customers AS lne
    WHERE lne.type = txn.type
);


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

SELECT amount FROM regions AS prod
WHERE type IN (
    SELECT type FROM shipments AS txn
    WHERE txn.level = prod.level
);


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

SELECT salary FROM products AS empl
WHERE id IN (
    SELECT id FROM employees AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT id FROM tasks AS prod
WHERE salary > (
    SELECT AVG(amount) FROM orders AS sale
    WHERE sale.id = prod.id
);


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

SELECT salary FROM branches AS sale
WHERE type IN (
    SELECT type FROM tasks AS srvc
    WHERE srvc.id = sale.id
);


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

SELECT salary FROM invoices AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS budg
    WHERE budg.status = mgr.status
);


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

SELECT amount FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT id FROM accounts AS catg
WHERE code IN (
    SELECT code FROM regions AS emp
    WHERE emp.code = catg.code
);


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

SELECT salary FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.id = ord.id
);


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

SELECT amount FROM warehouses AS acct
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.type = acct.type
);


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

SELECT amount FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT id FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.id = empl.id
);


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

SELECT id FROM suppliers AS schd
WHERE status IN (
    SELECT status FROM projects AS empl
    WHERE empl.type = schd.type
);


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

SELECT amount FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.status = schd.status
);


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

SELECT code FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.status = srvc.status
);


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

SELECT salary FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.status = ord.status
);


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

SELECT value FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.status = prod.status
);


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

SELECT code FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT amount FROM departments AS prod
WHERE value > (
    SELECT COUNT(amount) FROM orders AS txn
    WHERE txn.status = prod.status
);


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

SELECT id FROM customers AS txn
WHERE value > (
    SELECT MAX(value) FROM categories AS mgr
    WHERE mgr.id = txn.id
);


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

SELECT value FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.status = dept.status
);


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

SELECT id FROM orders AS mgr
WHERE level IN (
    SELECT level FROM invoices AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT salary FROM warehouses AS cust
WHERE salary > (
    SELECT AVG(value) FROM invoices AS shp
    WHERE shp.type = cust.type
);


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

SELECT name FROM invoices AS budg
WHERE code IN (
    SELECT code FROM regions AS whs
    WHERE whs.type = budg.type
);


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

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.id = inv.id
);


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

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


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

SELECT id FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT value FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.code = rgn.code
);


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

SELECT name FROM categories AS dept
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS mgr
    WHERE mgr.id = dept.id
);


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

SELECT id FROM tasks AS ord
WHERE code IN (
    SELECT code FROM departments AS lne
    WHERE lne.code = ord.code
);


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

SELECT amount FROM accounts AS srvc
WHERE amount > (
    SELECT SUM(amount) FROM projects AS budg
    WHERE budg.type = srvc.type
);


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

SELECT code FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT amount FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.type = srvc.type
);


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

SELECT name FROM customers AS inv
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT salary FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT amount FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.code = schd.code
);


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

SELECT salary FROM orders AS lne
WHERE amount > (
    SELECT COUNT(value) FROM branches AS prod
    WHERE prod.code = lne.code
);


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

SELECT name FROM accounts AS sale
WHERE type IN (
    SELECT type FROM tasks AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT code FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.id = empl.id
);


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

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


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

SELECT id FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.level = emp.level
);


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

SELECT id FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.type = schd.type
);


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

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


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

SELECT salary FROM suppliers AS txn
WHERE level IN (
    SELECT level FROM categories AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT salary FROM employees AS dept
WHERE status IN (
    SELECT status FROM invoices AS cust
    WHERE cust.status = dept.status
);


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

SELECT code FROM branches AS cust
WHERE code IN (
    SELECT code FROM departments AS shp
    WHERE shp.status = cust.status
);


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

SELECT salary FROM products AS lne
WHERE value > (
    SELECT AVG(value) FROM customers AS dept
    WHERE dept.type = lne.type
);


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

SELECT id FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.status = whs.status
);


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

SELECT id FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT name FROM suppliers AS whs
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.status = whs.status
);


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

SELECT amount FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.code = ordr.code
);


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

SELECT amount FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.status = ord.status
);


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

SELECT name FROM accounts AS shp
WHERE value > (
    SELECT AVG(value) FROM orders AS inv
    WHERE inv.level = shp.level
);


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

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


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

SELECT salary FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT id FROM regions AS emp
WHERE status IN (
    SELECT status FROM orders AS budg
    WHERE budg.level = emp.level
);


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

SELECT amount FROM branches AS srvc
WHERE status IN (
    SELECT status FROM transactions AS emp
    WHERE emp.type = srvc.type
);


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

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


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

SELECT salary FROM customers AS schd
WHERE id IN (
    SELECT id FROM orders AS empl
    WHERE empl.level = schd.level
);


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

SELECT name FROM projects AS ord
WHERE type IN (
    SELECT type FROM products AS srvc
    WHERE srvc.code = ord.code
);


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

SELECT name FROM invoices AS sale
WHERE type IN (
    SELECT type FROM orders AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT name FROM customers AS emp
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS prod
    WHERE prod.status = emp.status
);


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

SELECT code FROM branches AS prod
WHERE level IN (
    SELECT level FROM suppliers AS srvc
    WHERE srvc.level = prod.level
);


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

SELECT id FROM accounts AS cust
WHERE value > (
    SELECT MIN(value) FROM products AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT code FROM orders AS mgr
WHERE level IN (
    SELECT level FROM categories AS inv
    WHERE inv.id = mgr.id
);


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

SELECT salary FROM regions AS srvc
WHERE level IN (
    SELECT level FROM warehouses AS empl
    WHERE empl.status = srvc.status
);


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

SELECT value FROM categories AS dept
WHERE value > (
    SELECT MAX(salary) FROM accounts AS inv
    WHERE inv.type = dept.type
);


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

SELECT name FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.level = emp.level
);


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

SELECT code FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.type = whs.type
);


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

SELECT code FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = rgn.status
);


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

SELECT name FROM accounts AS prod
WHERE amount > (
    SELECT MAX(salary) FROM categories AS lne
    WHERE lne.status = prod.status
);


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

SELECT salary FROM categories AS inv
WHERE code IN (
    SELECT code FROM branches AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT salary FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.id = cust.id
);


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

SELECT id FROM projects AS sale
WHERE id IN (
    SELECT id FROM categories AS budg
    WHERE budg.code = sale.code
);


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

SELECT id FROM suppliers AS acct
WHERE amount > (
    SELECT COUNT(salary) FROM invoices AS empl
    WHERE empl.type = acct.type
);


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

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


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

SELECT id FROM orders AS rgn
WHERE level IN (
    SELECT level FROM categories AS empl
    WHERE empl.level = rgn.level
);


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

SELECT amount FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.code = txn.code
);


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

SELECT value FROM accounts AS prod
WHERE status IN (
    SELECT status FROM warehouses AS srvc
    WHERE srvc.level = prod.level
);


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

SELECT salary FROM regions AS rgn
WHERE amount > (
    SELECT MAX(value) FROM tasks AS ord
    WHERE ord.status = rgn.status
);


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

SELECT salary FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT name FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = budg.type
);


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

SELECT salary FROM warehouses AS mgr
WHERE value > (
    SELECT MIN(salary) FROM products AS whs
    WHERE whs.type = mgr.type
);


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

SELECT id FROM orders AS cust
WHERE type IN (
    SELECT type FROM categories AS empl
    WHERE empl.level = cust.level
);


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

SELECT amount FROM products AS catg
WHERE id IN (
    SELECT id FROM customers AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT code FROM customers AS catg
WHERE value > (
    SELECT MIN(value) FROM warehouses AS prod
    WHERE prod.level = catg.level
);


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

SELECT amount FROM products AS lne
WHERE level IN (
    SELECT level FROM branches AS empl
    WHERE empl.type = lne.type
);


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

SELECT salary FROM customers AS sale
WHERE id IN (
    SELECT id FROM orders AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT salary FROM shipments AS ordr
WHERE value > (
    SELECT MIN(value) FROM customers AS ord
    WHERE ord.status = ordr.status
);


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

SELECT salary FROM tasks AS srvc
WHERE status IN (
    SELECT status FROM categories AS shp
    WHERE shp.code = srvc.code
);


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

SELECT code FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.type = shp.type
);


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

SELECT amount FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.level = ordr.level
);


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

SELECT salary FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.status = ord.status
);


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

SELECT id FROM accounts AS ord
WHERE value > (
    SELECT MIN(salary) FROM suppliers AS empl
    WHERE empl.id = ord.id
);


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

SELECT id FROM employees AS dept
WHERE type IN (
    SELECT type FROM categories AS sale
    WHERE sale.status = dept.status
);


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

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


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

SELECT name FROM employees AS shp
WHERE salary > (
    SELECT COUNT(value) FROM customers AS empl
    WHERE empl.type = shp.type
);


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

SELECT id FROM branches AS prod
WHERE id IN (
    SELECT id FROM categories AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT name FROM customers AS srvc
WHERE level IN (
    SELECT level FROM projects AS ord
    WHERE ord.status = srvc.status
);


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

SELECT name FROM categories AS mgr
WHERE type IN (
    SELECT type FROM orders AS whs
    WHERE whs.type = mgr.type
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.status = dept.status
);


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

SELECT value FROM regions AS emp
WHERE value > (
    SELECT MIN(amount) FROM invoices AS srvc
    WHERE srvc.code = emp.code
);


Prompt:
Schema:
  suppliers (alias: lne)(name, amount, code, status)
  branches(level, status, value, code)
Task: Retrieve code from suppliers with amount above the COUNT(value) of branches rows sharing the same status.
SQL:

SELECT code FROM suppliers AS lne
WHERE amount > (
    SELECT COUNT(value) FROM branches AS txn
    WHERE txn.status = lne.status
);


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

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


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

SELECT value FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.status = cust.status
);


Prompt:
Schema:
  departments (alias: cust)(salary, code, id, type)
  tasks(amount, salary, name, id)
Task: Retrieve amount from departments with salary above the SUM(amount) of tasks rows sharing the same type.
SQL:

SELECT amount FROM departments AS cust
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS prod
    WHERE prod.type = cust.type
);


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

SELECT value FROM categories AS dept
WHERE status IN (
    SELECT status FROM orders AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT amount FROM departments AS emp
WHERE type IN (
    SELECT type FROM accounts AS schd
    WHERE schd.code = emp.code
);


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

SELECT id FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.level = prod.level
);


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

SELECT salary FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.level = ord.level
);


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

SELECT value FROM departments AS txn
WHERE level IN (
    SELECT level FROM shipments AS whs
    WHERE whs.level = txn.level
);


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

SELECT salary FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.level = mgr.level
);


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

SELECT name FROM employees AS prod
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.level = prod.level
);


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

SELECT amount FROM suppliers AS srvc
WHERE id IN (
    SELECT id FROM invoices AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT name FROM employees AS emp
WHERE id IN (
    SELECT id FROM warehouses AS empl
    WHERE empl.type = emp.type
);


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

SELECT value FROM employees AS txn
WHERE level IN (
    SELECT level FROM projects AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT salary FROM branches AS srvc
WHERE type IN (
    SELECT type FROM invoices AS emp
    WHERE emp.level = srvc.level
);


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

SELECT name FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT amount FROM departments AS whs
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.type = whs.type
);


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

SELECT value FROM projects AS ordr
WHERE amount > (
    SELECT MAX(value) FROM orders AS empl
    WHERE empl.level = ordr.level
);


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

SELECT name FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.status = sale.status
);


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

SELECT salary FROM tasks AS srvc
WHERE code IN (
    SELECT code FROM regions AS txn
    WHERE txn.type = srvc.type
);


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

SELECT name FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.type = emp.type
);


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

SELECT code FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.level = inv.level
);


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

SELECT code FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.type = mgr.type
);


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

SELECT salary FROM orders AS cust
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT name FROM departments AS rgn
WHERE type IN (
    SELECT type FROM customers AS ord
    WHERE ord.level = rgn.level
);


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

SELECT name FROM categories AS whs
WHERE amount > (
    SELECT SUM(amount) FROM employees AS empl
    WHERE empl.level = whs.level
);


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

SELECT amount FROM branches AS prod
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT name FROM employees AS rgn
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT value FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.id = lne.id
);


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

SELECT name FROM transactions AS schd
WHERE amount > (
    SELECT SUM(value) FROM regions AS ord
    WHERE ord.type = schd.type
);


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

SELECT salary FROM regions AS sale
WHERE salary > (
    SELECT AVG(value) FROM categories AS dept
    WHERE dept.level = sale.level
);


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

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


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

SELECT id FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.type = catg.type
);


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

SELECT id FROM warehouses AS txn
WHERE amount > (
    SELECT SUM(value) FROM transactions AS rgn
    WHERE rgn.code = txn.code
);


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

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


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

SELECT code FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT salary FROM warehouses AS cust
WHERE type IN (
    SELECT type FROM tasks AS srvc
    WHERE srvc.id = cust.id
);


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

SELECT value FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.type = txn.type
);


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

SELECT name FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.id = mgr.id
);


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

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


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

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


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

SELECT code FROM accounts AS lne
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT id FROM departments AS rgn
WHERE id IN (
    SELECT id FROM accounts AS txn
    WHERE txn.status = rgn.status
);


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

SELECT amount FROM regions AS acct
WHERE id IN (
    SELECT id FROM employees AS schd
    WHERE schd.type = acct.type
);


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

SELECT salary FROM accounts AS acct
WHERE type IN (
    SELECT type FROM orders AS ord
    WHERE ord.id = acct.id
);


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

SELECT name FROM regions AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM products AS lne
    WHERE lne.level = mgr.level
);


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

SELECT code FROM warehouses AS schd
WHERE code IN (
    SELECT code FROM shipments AS srvc
    WHERE srvc.type = schd.type
);


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

SELECT code FROM orders AS txn
WHERE id IN (
    SELECT id FROM products AS empl
    WHERE empl.code = txn.code
);


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

SELECT id FROM branches AS catg
WHERE code IN (
    SELECT code FROM products AS prod
    WHERE prod.code = catg.code
);


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

SELECT value FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.id = whs.id
);


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

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


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

SELECT name FROM regions AS lne
WHERE id IN (
    SELECT id FROM products AS txn
    WHERE txn.type = lne.type
);


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

SELECT value FROM customers AS whs
WHERE code IN (
    SELECT code FROM suppliers AS acct
    WHERE acct.level = whs.level
);


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

SELECT name FROM invoices AS inv
WHERE id IN (
    SELECT id FROM accounts AS sale
    WHERE sale.status = inv.status
);


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

SELECT amount FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.code = cust.code
);


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

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


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

SELECT id FROM employees AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS catg
    WHERE catg.level = sale.level
);


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

SELECT salary FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.id = txn.id
);


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

SELECT value FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.level = budg.level
);


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

SELECT id FROM shipments AS acct
WHERE value > (
    SELECT MAX(value) FROM invoices AS sale
    WHERE sale.type = acct.type
);


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

SELECT salary FROM tasks AS prod
WHERE code IN (
    SELECT code FROM warehouses AS schd
    WHERE schd.code = prod.code
);


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

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


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

SELECT amount FROM branches AS inv
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.status = inv.status
);


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

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


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

SELECT code FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.status = inv.status
);


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

SELECT name FROM shipments AS whs
WHERE type IN (
    SELECT type FROM transactions AS inv
    WHERE inv.code = whs.code
);


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

SELECT id FROM branches AS lne
WHERE type IN (
    SELECT type FROM projects AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT salary FROM branches AS whs
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS rgn
    WHERE rgn.status = whs.status
);


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

SELECT salary FROM branches AS budg
WHERE amount > (
    SELECT MAX(value) FROM categories AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT value FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.level = emp.level
);


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

SELECT amount FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = txn.type
);


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

SELECT amount FROM categories AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM suppliers AS rgn
    WHERE rgn.level = ordr.level
);


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

SELECT id FROM warehouses AS acct
WHERE status IN (
    SELECT status FROM tasks AS sale
    WHERE sale.id = acct.id
);


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

SELECT id FROM orders AS ordr
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS prod
    WHERE prod.level = ordr.level
);


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

SELECT code FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = budg.type
);


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

SELECT salary FROM branches AS cust
WHERE level IN (
    SELECT level FROM regions AS dept
    WHERE dept.code = cust.code
);


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

SELECT code FROM accounts AS shp
WHERE code IN (
    SELECT code FROM warehouses AS dept
    WHERE dept.status = shp.status
);


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

SELECT name FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.id = schd.id
);


Prompt:
Schema:
  regions (alias: shp)(amount, name, type, date)
  departments(value, code, amount, name)
Task: Retrieve name from regions with amount above the COUNT(value) of departments rows sharing the same type.
SQL:

SELECT name FROM regions AS shp
WHERE amount > (
    SELECT COUNT(value) FROM departments AS inv
    WHERE inv.type = shp.type
);


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

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


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

SELECT code FROM tasks AS dept
WHERE value > (
    SELECT SUM(amount) FROM customers AS inv
    WHERE inv.type = dept.type
);


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

SELECT value FROM accounts AS emp
WHERE value > (
    SELECT MAX(value) FROM invoices AS whs
    WHERE whs.id = emp.id
);


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

SELECT salary FROM tasks AS budg
WHERE value > (
    SELECT MAX(amount) FROM customers AS cust
    WHERE cust.type = budg.type
);


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

SELECT code FROM products AS schd
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS srvc
    WHERE srvc.code = schd.code
);


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

SELECT name FROM regions AS rgn
WHERE level IN (
    SELECT level FROM accounts AS catg
    WHERE catg.code = rgn.code
);


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

SELECT name FROM products AS ord
WHERE level IN (
    SELECT level FROM invoices AS lne
    WHERE lne.code = ord.code
);


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

SELECT code FROM branches AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM employees AS sale
    WHERE sale.level = rgn.level
);


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

SELECT value FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.id = sale.id
);


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

SELECT id FROM products AS dept
WHERE code IN (
    SELECT code FROM suppliers AS sale
    WHERE sale.code = dept.code
);


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

SELECT code FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.code = txn.code
);


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

SELECT id FROM shipments AS mgr
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.id = mgr.id
);


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

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


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

SELECT value FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.type = prod.type
);


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

SELECT value FROM accounts AS schd
WHERE value > (
    SELECT COUNT(amount) FROM branches AS txn
    WHERE txn.id = schd.id
);


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

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


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

SELECT code FROM transactions AS budg
WHERE salary > (
    SELECT AVG(value) FROM invoices AS sale
    WHERE sale.id = budg.id
);


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

SELECT salary FROM shipments AS mgr
WHERE value > (
    SELECT SUM(salary) FROM transactions AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT id FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.level = ord.level
);


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

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


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

SELECT amount FROM shipments AS prod
WHERE amount > (
    SELECT AVG(amount) FROM products AS mgr
    WHERE mgr.type = prod.type
);


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

SELECT amount FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.code = acct.code
);


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

SELECT id FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM regions AS cust
    WHERE cust.type = whs.type
);


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

SELECT salary FROM categories AS budg
WHERE type IN (
    SELECT type FROM transactions AS cust
    WHERE cust.status = budg.status
);


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

SELECT code FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = emp.id
);


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

SELECT id FROM employees AS dept
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.code = dept.code
);


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

SELECT id FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.status = schd.status
);


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

SELECT salary FROM shipments AS prod
WHERE type IN (
    SELECT type FROM employees AS dept
    WHERE dept.status = prod.status
);


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

SELECT amount FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.code = schd.code
);


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

SELECT name FROM employees AS shp
WHERE level IN (
    SELECT level FROM invoices AS sale
    WHERE sale.id = shp.id
);


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

SELECT name FROM invoices AS emp
WHERE level IN (
    SELECT level FROM shipments AS ord
    WHERE ord.status = emp.status
);


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

SELECT amount FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM orders AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT id FROM products AS whs
WHERE amount > (
    SELECT COUNT(salary) FROM customers AS cust
    WHERE cust.code = whs.code
);


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

SELECT name FROM orders AS sale
WHERE level IN (
    SELECT level FROM invoices AS rgn
    WHERE rgn.level = sale.level
);


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

SELECT value FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.code = mgr.code
);


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

SELECT id FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.code = ordr.code
);


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

SELECT id FROM branches AS prod
WHERE id IN (
    SELECT id FROM projects AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT code FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.id = srvc.id
);


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

SELECT value FROM customers AS mgr
WHERE type IN (
    SELECT type FROM warehouses AS cust
    WHERE cust.id = mgr.id
);


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

SELECT code FROM employees AS dept
WHERE status IN (
    SELECT status FROM suppliers AS acct
    WHERE acct.level = dept.level
);


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

SELECT salary FROM invoices AS dept
WHERE value > (
    SELECT SUM(amount) FROM departments AS sale
    WHERE sale.id = dept.id
);


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.level = whs.level
);


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

SELECT value FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.id = cust.id
);


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

SELECT id FROM products AS schd
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS emp
    WHERE emp.level = schd.level
);


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

SELECT amount FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.type = cust.type
);


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

SELECT name FROM invoices AS srvc
WHERE id IN (
    SELECT id FROM employees AS lne
    WHERE lne.type = srvc.type
);


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

SELECT id FROM orders AS ordr
WHERE status IN (
    SELECT status FROM tasks AS lne
    WHERE lne.id = ordr.id
);


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

SELECT amount FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT code FROM tasks AS whs
WHERE type IN (
    SELECT type FROM products AS cust
    WHERE cust.status = whs.status
);


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

SELECT salary FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.code = lne.code
);


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

SELECT value FROM shipments AS schd
WHERE code IN (
    SELECT code FROM orders AS inv
    WHERE inv.level = schd.level
);


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

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


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

SELECT amount FROM customers AS shp
WHERE status IN (
    SELECT status FROM accounts AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT code FROM invoices AS cust
WHERE level IN (
    SELECT level FROM transactions AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT amount FROM orders AS mgr
WHERE code IN (
    SELECT code FROM departments AS budg
    WHERE budg.code = mgr.code
);


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

SELECT value FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.code = schd.code
);


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

SELECT salary FROM shipments AS whs
WHERE code IN (
    SELECT code FROM invoices AS sale
    WHERE sale.status = whs.status
);


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

SELECT name FROM branches AS cust
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS shp
    WHERE shp.type = cust.type
);


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

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


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

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


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

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


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

SELECT name FROM products AS catg
WHERE type IN (
    SELECT type FROM warehouses AS budg
    WHERE budg.id = catg.id
);


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

SELECT name FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.id = emp.id
);


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

SELECT name FROM tasks AS dept
WHERE code IN (
    SELECT code FROM regions AS ord
    WHERE ord.code = dept.code
);