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

SELECT value FROM projects AS empl
WHERE salary > (
    SELECT MIN(value) FROM departments AS ord
    WHERE ord.level = empl.level
);


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

SELECT amount FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.id = dept.id
);


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

SELECT value FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.id = emp.id
);


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

SELECT code FROM accounts AS shp
WHERE status IN (
    SELECT status FROM departments AS srvc
    WHERE srvc.code = shp.code
);


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

SELECT amount FROM regions AS dept
WHERE level IN (
    SELECT level FROM orders AS acct
    WHERE acct.id = dept.id
);


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

SELECT value FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.id = srvc.id
);


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

SELECT value FROM regions AS cust
WHERE value > (
    SELECT SUM(salary) FROM shipments AS whs
    WHERE whs.type = cust.type
);


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

SELECT code FROM warehouses AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM suppliers AS inv
    WHERE inv.code = ordr.code
);


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

SELECT id FROM departments AS cust
WHERE amount > (
    SELECT MIN(value) FROM accounts AS catg
    WHERE catg.type = cust.type
);


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

SELECT id FROM invoices AS acct
WHERE level IN (
    SELECT level FROM categories AS mgr
    WHERE mgr.status = acct.status
);


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

SELECT id FROM customers AS acct
WHERE value > (
    SELECT MIN(value) FROM orders AS ord
    WHERE ord.code = acct.code
);


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

SELECT code FROM accounts AS cust
WHERE status IN (
    SELECT status FROM categories AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT salary FROM customers AS cust
WHERE level IN (
    SELECT level FROM employees AS ordr
    WHERE ordr.code = cust.code
);


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

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


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

SELECT code FROM categories AS schd
WHERE id IN (
    SELECT id FROM accounts AS dept
    WHERE dept.type = schd.type
);


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

SELECT name FROM categories AS lne
WHERE value > (
    SELECT SUM(value) FROM suppliers AS dept
    WHERE dept.id = lne.id
);


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

SELECT value FROM branches AS acct
WHERE code IN (
    SELECT code FROM employees AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT value FROM warehouses AS sale
WHERE code IN (
    SELECT code FROM shipments AS emp
    WHERE emp.level = sale.level
);


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

SELECT id FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = whs.status
);


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

SELECT salary FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.status = acct.status
);


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

SELECT id FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.level = emp.level
);


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

SELECT amount FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.type = prod.type
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.code = shp.code
);


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

SELECT amount FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.status = inv.status
);


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

SELECT salary FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.type = ord.type
);


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

SELECT amount FROM invoices AS sale
WHERE value > (
    SELECT MAX(value) FROM accounts AS txn
    WHERE txn.status = sale.status
);


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

SELECT salary FROM employees AS srvc
WHERE level IN (
    SELECT level FROM shipments AS ordr
    WHERE ordr.id = srvc.id
);


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

SELECT name FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.level = catg.level
);


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

SELECT code FROM warehouses AS whs
WHERE id IN (
    SELECT id FROM shipments AS emp
    WHERE emp.id = whs.id
);


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

SELECT name FROM warehouses AS cust
WHERE id IN (
    SELECT id FROM suppliers AS catg
    WHERE catg.id = cust.id
);


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

SELECT amount FROM employees AS txn
WHERE amount > (
    SELECT SUM(value) FROM departments AS ord
    WHERE ord.type = txn.type
);


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

SELECT salary FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.status = prod.status
);


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

SELECT amount FROM warehouses AS schd
WHERE salary > (
    SELECT MIN(value) FROM products AS catg
    WHERE catg.id = schd.id
);


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

SELECT salary FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.type = inv.type
);


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

SELECT id FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = txn.type
);


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

SELECT id FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.level = srvc.level
);


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

SELECT code FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.id = acct.id
);


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

SELECT code FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = mgr.type
);


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

SELECT code FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.status = inv.status
);


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

SELECT salary FROM transactions AS catg
WHERE value > (
    SELECT MAX(amount) FROM invoices AS emp
    WHERE emp.id = catg.id
);


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

SELECT value FROM warehouses AS lne
WHERE value > (
    SELECT AVG(amount) FROM regions AS shp
    WHERE shp.level = lne.level
);


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

SELECT id FROM departments AS shp
WHERE type IN (
    SELECT type FROM orders AS cust
    WHERE cust.level = shp.level
);


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

SELECT code FROM employees AS sale
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS lne
    WHERE lne.type = sale.type
);


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

SELECT id FROM customers AS whs
WHERE type IN (
    SELECT type FROM shipments AS prod
    WHERE prod.id = whs.id
);


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

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


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

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


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

SELECT value FROM employees AS ordr
WHERE level IN (
    SELECT level FROM warehouses AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT amount FROM shipments AS rgn
WHERE status IN (
    SELECT status FROM transactions AS sale
    WHERE sale.level = rgn.level
);


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

SELECT name FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.code = rgn.code
);


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

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


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

SELECT code FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.type = budg.type
);


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

SELECT name FROM projects AS prod
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.code = prod.code
);


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

SELECT amount FROM accounts AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS catg
    WHERE catg.code = ordr.code
);


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

SELECT value FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.type = dept.type
);


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

SELECT id FROM customers AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM suppliers AS shp
    WHERE shp.code = mgr.code
);


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

SELECT name FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = rgn.level
);


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

SELECT value FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.type = acct.type
);


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

SELECT code FROM categories AS schd
WHERE level IN (
    SELECT level FROM branches AS srvc
    WHERE srvc.code = schd.code
);


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

SELECT amount FROM shipments AS ord
WHERE salary > (
    SELECT MIN(amount) FROM projects AS catg
    WHERE catg.status = ord.status
);


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

SELECT amount FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.code = ord.code
);


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

SELECT salary FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.type = empl.type
);


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

SELECT name FROM accounts AS catg
WHERE value > (
    SELECT MAX(amount) FROM employees AS whs
    WHERE whs.status = catg.status
);


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

SELECT amount FROM categories AS acct
WHERE value > (
    SELECT MAX(value) FROM customers AS sale
    WHERE sale.id = acct.id
);


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

SELECT id FROM customers AS catg
WHERE id IN (
    SELECT id FROM categories AS sale
    WHERE sale.type = catg.type
);


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

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


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

SELECT id FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.type = inv.type
);


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

SELECT value FROM branches AS cust
WHERE status IN (
    SELECT status FROM categories AS lne
    WHERE lne.level = cust.level
);


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

SELECT code FROM employees AS sale
WHERE value > (
    SELECT COUNT(salary) FROM products AS whs
    WHERE whs.status = sale.status
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.type = rgn.type
);


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

SELECT id FROM products AS budg
WHERE amount > (
    SELECT SUM(amount) FROM projects AS catg
    WHERE catg.type = budg.type
);


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

SELECT value FROM shipments AS empl
WHERE status IN (
    SELECT status FROM branches AS dept
    WHERE dept.status = empl.status
);


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

SELECT salary FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.level = lne.level
);


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

SELECT salary FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.id = ordr.id
);


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

SELECT amount FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.status = empl.status
);


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

SELECT id FROM departments AS empl
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS emp
    WHERE emp.status = empl.status
);


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

SELECT salary FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.code = dept.code
);


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

SELECT salary FROM shipments AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS cust
    WHERE cust.level = empl.level
);


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

SELECT name FROM customers AS cust
WHERE id IN (
    SELECT id FROM departments AS prod
    WHERE prod.status = cust.status
);


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

SELECT id FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.type = rgn.type
);


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

SELECT name FROM projects AS mgr
WHERE id IN (
    SELECT id FROM regions AS shp
    WHERE shp.code = mgr.code
);


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

SELECT salary FROM suppliers AS budg
WHERE value > (
    SELECT SUM(value) FROM warehouses AS sale
    WHERE sale.status = budg.status
);


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

SELECT name FROM tasks AS schd
WHERE value > (
    SELECT MIN(value) FROM departments AS rgn
    WHERE rgn.type = schd.type
);


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

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


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

SELECT amount FROM transactions AS ord
WHERE amount > (
    SELECT SUM(amount) FROM regions AS shp
    WHERE shp.id = ord.id
);


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

SELECT salary FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.status = ord.status
);


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

SELECT amount FROM employees AS ordr
WHERE code IN (
    SELECT code FROM tasks AS inv
    WHERE inv.code = ordr.code
);


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

SELECT code FROM accounts AS lne
WHERE amount > (
    SELECT MAX(value) FROM shipments AS ordr
    WHERE ordr.id = lne.id
);


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

SELECT code FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.status = ordr.status
);


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

SELECT salary FROM products AS txn
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS ordr
    WHERE ordr.type = txn.type
);


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

SELECT value FROM customers AS dept
WHERE amount > (
    SELECT SUM(value) FROM orders AS acct
    WHERE acct.status = dept.status
);


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

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


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

SELECT amount FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = empl.status
);


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

SELECT code FROM tasks AS ord
WHERE code IN (
    SELECT code FROM products AS budg
    WHERE budg.code = ord.code
);


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

SELECT amount FROM projects AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM branches AS emp
    WHERE emp.code = ordr.code
);


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

SELECT value FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.id = acct.id
);


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

SELECT amount FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.status = catg.status
);


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

SELECT code FROM tasks AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM transactions AS sale
    WHERE sale.id = shp.id
);


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

SELECT amount FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.id = catg.id
);


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

SELECT code FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT value FROM customers AS emp
WHERE id IN (
    SELECT id FROM transactions AS sale
    WHERE sale.level = emp.level
);


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

SELECT salary FROM invoices AS catg
WHERE salary > (
    SELECT SUM(value) FROM customers AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT name FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.type = budg.type
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.type = emp.type
);


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

SELECT code FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.code = prod.code
);


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

SELECT id FROM suppliers AS catg
WHERE value > (
    SELECT AVG(salary) FROM regions AS cust
    WHERE cust.code = catg.code
);


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

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


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

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


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

SELECT name FROM employees AS budg
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS cust
    WHERE cust.id = budg.id
);


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

SELECT salary FROM invoices AS shp
WHERE type IN (
    SELECT type FROM transactions AS acct
    WHERE acct.status = shp.status
);


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

SELECT code FROM projects AS lne
WHERE id IN (
    SELECT id FROM categories AS prod
    WHERE prod.type = lne.type
);


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

SELECT id FROM departments AS empl
WHERE value > (
    SELECT COUNT(amount) FROM employees AS ordr
    WHERE ordr.type = empl.type
);


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

SELECT code FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.id = catg.id
);


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

SELECT value FROM employees AS cust
WHERE status IN (
    SELECT status FROM categories AS shp
    WHERE shp.level = cust.level
);


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

SELECT name FROM transactions AS cust
WHERE value > (
    SELECT MIN(amount) FROM warehouses AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT id FROM products AS whs
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS rgn
    WHERE rgn.level = whs.level
);


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

SELECT amount FROM categories AS lne
WHERE level IN (
    SELECT level FROM regions AS whs
    WHERE whs.type = lne.type
);


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

SELECT value FROM suppliers AS cust
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT name FROM suppliers AS dept
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS empl
    WHERE empl.type = dept.type
);


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

SELECT amount FROM shipments AS empl
WHERE id IN (
    SELECT id FROM suppliers AS ord
    WHERE ord.status = empl.status
);


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

SELECT id FROM shipments AS cust
WHERE level IN (
    SELECT level FROM orders AS whs
    WHERE whs.code = cust.code
);


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

SELECT value FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT amount FROM employees AS srvc
WHERE status IN (
    SELECT status FROM suppliers AS mgr
    WHERE mgr.id = srvc.id
);


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

SELECT code FROM customers AS mgr
WHERE id IN (
    SELECT id FROM employees AS cust
    WHERE cust.code = mgr.code
);


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

SELECT code FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.id = schd.id
);


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

SELECT value FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.code = prod.code
);


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

SELECT amount FROM categories AS prod
WHERE id IN (
    SELECT id FROM suppliers AS cust
    WHERE cust.type = prod.type
);


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

SELECT amount FROM branches AS catg
WHERE status IN (
    SELECT status FROM projects AS shp
    WHERE shp.type = catg.type
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.level = dept.level
);


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

SELECT salary FROM departments AS srvc
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS empl
    WHERE empl.code = srvc.code
);


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

SELECT name FROM transactions AS cust
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS acct
    WHERE acct.id = cust.id
);


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

SELECT amount FROM customers AS emp
WHERE salary > (
    SELECT AVG(salary) FROM regions AS shp
    WHERE shp.code = emp.code
);


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

SELECT code FROM customers AS mgr
WHERE amount > (
    SELECT MIN(salary) FROM orders AS ord
    WHERE ord.level = mgr.level
);


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

SELECT code FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.type = ord.type
);


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

SELECT code FROM tasks AS mgr
WHERE id IN (
    SELECT id FROM categories AS prod
    WHERE prod.type = mgr.type
);


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

SELECT name FROM orders AS catg
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT value FROM invoices AS budg
WHERE id IN (
    SELECT id FROM tasks AS catg
    WHERE catg.id = budg.id
);


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

SELECT amount FROM warehouses AS shp
WHERE status IN (
    SELECT status FROM orders AS schd
    WHERE schd.level = shp.level
);


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

SELECT code FROM tasks AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS whs
    WHERE whs.type = ordr.type
);


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

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


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

SELECT id FROM transactions AS whs
WHERE salary > (
    SELECT MIN(value) FROM regions AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT id FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.level = catg.level
);


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

SELECT amount FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.code = whs.code
);


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.code = cust.code
);


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

SELECT id FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT value FROM employees AS cust
WHERE salary > (
    SELECT MIN(salary) FROM branches AS whs
    WHERE whs.status = cust.status
);


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

SELECT code FROM customers AS txn
WHERE code IN (
    SELECT code FROM employees AS shp
    WHERE shp.id = txn.id
);


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

SELECT amount FROM shipments AS acct
WHERE amount > (
    SELECT MIN(value) FROM suppliers AS empl
    WHERE empl.level = acct.level
);


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

SELECT salary FROM suppliers AS emp
WHERE status IN (
    SELECT status FROM projects AS ordr
    WHERE ordr.id = emp.id
);


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

SELECT value FROM orders AS emp
WHERE salary > (
    SELECT MIN(salary) FROM categories AS inv
    WHERE inv.id = emp.id
);


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

SELECT amount FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.status = acct.status
);


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

SELECT value FROM accounts AS rgn
WHERE amount > (
    SELECT COUNT(salary) FROM customers AS lne
    WHERE lne.level = rgn.level
);


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

SELECT id FROM accounts AS srvc
WHERE salary > (
    SELECT MIN(value) FROM projects AS catg
    WHERE catg.type = srvc.type
);


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

SELECT amount FROM projects AS schd
WHERE type IN (
    SELECT type FROM tasks AS empl
    WHERE empl.code = schd.code
);


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

SELECT amount FROM invoices AS srvc
WHERE value > (
    SELECT SUM(salary) FROM shipments AS whs
    WHERE whs.id = srvc.id
);


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

SELECT value FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.id = ordr.id
);


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

SELECT code FROM invoices AS prod
WHERE status IN (
    SELECT status FROM customers AS dept
    WHERE dept.status = prod.status
);


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

SELECT value FROM regions AS acct
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS shp
    WHERE shp.level = acct.level
);


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

SELECT code FROM transactions AS sale
WHERE level IN (
    SELECT level FROM projects AS budg
    WHERE budg.status = sale.status
);


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

SELECT id FROM suppliers AS sale
WHERE type IN (
    SELECT type FROM projects AS prod
    WHERE prod.type = sale.type
);


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

SELECT value FROM accounts AS catg
WHERE code IN (
    SELECT code FROM suppliers AS ordr
    WHERE ordr.status = catg.status
);


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

SELECT id FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.code = cust.code
);


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

SELECT amount FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.level = mgr.level
);


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

SELECT value FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.level = catg.level
);


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

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


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

SELECT name FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.id = schd.id
);


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

SELECT salary FROM projects AS inv
WHERE id IN (
    SELECT id FROM regions AS ord
    WHERE ord.status = inv.status
);


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

SELECT value FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.level = catg.level
);


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

SELECT amount FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.type = sale.type
);


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

SELECT code FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.id = sale.id
);


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

SELECT salary FROM transactions AS rgn
WHERE value > (
    SELECT MIN(amount) FROM customers AS whs
    WHERE whs.type = rgn.type
);


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

SELECT id FROM shipments AS dept
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.type = dept.type
);


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

SELECT value FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.status = ord.status
);


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

SELECT amount FROM invoices AS whs
WHERE value > (
    SELECT AVG(value) FROM regions AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT salary FROM departments AS sale
WHERE id IN (
    SELECT id FROM accounts AS whs
    WHERE whs.type = sale.type
);


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

SELECT salary FROM categories AS mgr
WHERE id IN (
    SELECT id FROM branches AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT amount FROM shipments AS dept
WHERE salary > (
    SELECT SUM(amount) FROM categories AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT name FROM suppliers AS sale
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT amount FROM warehouses AS dept
WHERE amount > (
    SELECT MIN(amount) FROM branches AS empl
    WHERE empl.code = dept.code
);


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

SELECT amount FROM warehouses AS shp
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.code = shp.code
);


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

SELECT name FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.level = lne.level
);


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

SELECT code FROM tasks AS dept
WHERE status IN (
    SELECT status FROM warehouses AS txn
    WHERE txn.code = dept.code
);


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

SELECT name FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT amount FROM products AS lne
WHERE value > (
    SELECT MIN(salary) FROM tasks AS txn
    WHERE txn.id = lne.id
);


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

SELECT value FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.code = sale.code
);


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

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


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

SELECT salary FROM categories AS ord
WHERE level IN (
    SELECT level FROM customers AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT amount FROM tasks AS acct
WHERE amount > (
    SELECT COUNT(salary) FROM departments AS catg
    WHERE catg.id = acct.id
);


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

SELECT name FROM warehouses AS srvc
WHERE type IN (
    SELECT type FROM branches AS lne
    WHERE lne.code = srvc.code
);


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

SELECT name FROM transactions AS emp
WHERE value > (
    SELECT AVG(value) FROM departments AS cust
    WHERE cust.id = emp.id
);


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

SELECT code FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.type = emp.type
);


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

SELECT name FROM products AS cust
WHERE level IN (
    SELECT level FROM suppliers AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT value FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.id = prod.id
);


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

SELECT id FROM projects AS rgn
WHERE status IN (
    SELECT status FROM warehouses AS sale
    WHERE sale.code = rgn.code
);


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

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


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

SELECT salary FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.type = cust.type
);


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

SELECT code FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.type = cust.type
);


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

SELECT salary FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT code FROM branches AS catg
WHERE amount > (
    SELECT SUM(salary) FROM customers AS txn
    WHERE txn.code = catg.code
);


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

SELECT amount FROM suppliers AS sale
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT code FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.level = whs.level
);


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

SELECT amount FROM departments AS rgn
WHERE level IN (
    SELECT level FROM customers AS inv
    WHERE inv.id = rgn.id
);


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

SELECT code FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.level = sale.level
);


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

SELECT amount FROM accounts AS lne
WHERE amount > (
    SELECT MIN(salary) FROM branches AS catg
    WHERE catg.level = lne.level
);


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

SELECT value FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.level = emp.level
);


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

SELECT value FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.level = acct.level
);


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

SELECT value FROM customers AS budg
WHERE value > (
    SELECT AVG(amount) FROM accounts AS ordr
    WHERE ordr.code = budg.code
);


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

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


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

SELECT id FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT salary FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.type = acct.type
);


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

SELECT amount FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.status = txn.status
);


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

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


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

SELECT value FROM employees AS sale
WHERE level IN (
    SELECT level FROM invoices AS shp
    WHERE shp.code = sale.code
);


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

SELECT salary FROM employees AS dept
WHERE amount > (
    SELECT MIN(amount) FROM departments AS schd
    WHERE schd.type = dept.type
);


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

SELECT name FROM products AS lne
WHERE id IN (
    SELECT id FROM transactions AS shp
    WHERE shp.type = lne.type
);


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

SELECT salary FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.id = schd.id
);


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

SELECT salary FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM invoices AS shp
    WHERE shp.level = ordr.level
);


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

SELECT id FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.level = rgn.level
);


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

SELECT value FROM departments AS prod
WHERE amount > (
    SELECT MAX(salary) FROM suppliers AS cust
    WHERE cust.status = prod.status
);


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

SELECT amount FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = inv.status
);


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

SELECT name FROM regions AS txn
WHERE type IN (
    SELECT type FROM transactions AS srvc
    WHERE srvc.code = txn.code
);


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

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


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

SELECT code FROM shipments AS empl
WHERE type IN (
    SELECT type FROM invoices AS budg
    WHERE budg.level = empl.level
);


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

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


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

SELECT salary FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.status = ordr.status
);


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

SELECT id FROM warehouses AS inv
WHERE amount > (
    SELECT MIN(amount) FROM customers AS catg
    WHERE catg.level = inv.level
);


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

SELECT salary FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = inv.id
);


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

SELECT amount FROM shipments AS txn
WHERE code IN (
    SELECT code FROM warehouses AS ord
    WHERE ord.level = txn.level
);


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

SELECT code FROM regions AS srvc
WHERE type IN (
    SELECT type FROM invoices AS cust
    WHERE cust.level = srvc.level
);


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

SELECT code FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.level = budg.level
);


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

SELECT name FROM accounts AS schd
WHERE value > (
    SELECT SUM(salary) FROM orders AS empl
    WHERE empl.code = schd.code
);


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

SELECT amount FROM branches AS prod
WHERE value > (
    SELECT MAX(value) FROM products AS catg
    WHERE catg.code = prod.code
);


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

SELECT salary FROM invoices AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM products AS ord
    WHERE ord.id = shp.id
);


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

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


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

SELECT id FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.code = whs.code
);


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

SELECT id FROM shipments AS ordr
WHERE status IN (
    SELECT status FROM warehouses AS dept
    WHERE dept.status = ordr.status
);


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

SELECT amount FROM customers AS ordr
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS prod
    WHERE prod.code = ordr.code
);


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

SELECT id FROM projects AS catg
WHERE type IN (
    SELECT type FROM employees AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT value FROM departments AS mgr
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS shp
    WHERE shp.code = mgr.code
);


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

SELECT name FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.id = lne.id
);


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

SELECT salary FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.status = prod.status
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = prod.level
);


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

SELECT name FROM transactions AS budg
WHERE type IN (
    SELECT type FROM departments AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT amount FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.level = txn.level
);


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

SELECT salary FROM categories AS rgn
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT id FROM invoices AS whs
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.id = whs.id
);


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

SELECT amount FROM shipments AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM products AS shp
    WHERE shp.id = ordr.id
);


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

SELECT salary FROM employees AS inv
WHERE code IN (
    SELECT code FROM shipments AS ordr
    WHERE ordr.level = inv.level
);


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

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


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

SELECT id FROM customers AS whs
WHERE value > (
    SELECT AVG(value) FROM regions AS inv
    WHERE inv.id = whs.id
);


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

SELECT code FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.level = mgr.level
);


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

SELECT amount FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.id = acct.id
);


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

SELECT id FROM orders AS schd
WHERE salary > (
    SELECT MIN(salary) FROM employees AS inv
    WHERE inv.level = schd.level
);


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

SELECT value FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.level = lne.level
);


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

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


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

SELECT name FROM employees AS empl
WHERE value > (
    SELECT SUM(value) FROM departments AS inv
    WHERE inv.level = empl.level
);


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

SELECT salary FROM suppliers AS txn
WHERE code IN (
    SELECT code FROM regions AS schd
    WHERE schd.level = txn.level
);


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

SELECT salary FROM categories AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS catg
    WHERE catg.level = lne.level
);


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

SELECT id FROM shipments AS sale
WHERE id IN (
    SELECT id FROM warehouses AS shp
    WHERE shp.status = sale.status
);


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

SELECT amount FROM accounts AS ordr
WHERE code IN (
    SELECT code FROM warehouses AS dept
    WHERE dept.level = ordr.level
);


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

SELECT id FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT code FROM products AS emp
WHERE code IN (
    SELECT code FROM categories AS whs
    WHERE whs.type = emp.type
);


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

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


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

SELECT name FROM accounts AS rgn
WHERE id IN (
    SELECT id FROM transactions AS whs
    WHERE whs.type = rgn.type
);


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

SELECT id FROM customers AS srvc
WHERE salary > (
    SELECT MIN(amount) FROM orders AS budg
    WHERE budg.code = srvc.code
);


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

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


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

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


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

SELECT value FROM projects AS srvc
WHERE salary > (
    SELECT MIN(value) FROM branches AS shp
    WHERE shp.type = srvc.type
);


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

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


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

SELECT amount FROM employees AS prod
WHERE value > (
    SELECT SUM(value) FROM categories AS acct
    WHERE acct.type = prod.type
);


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

SELECT value FROM customers AS ord
WHERE code IN (
    SELECT code FROM transactions AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT name FROM shipments AS sale
WHERE level IN (
    SELECT level FROM warehouses AS whs
    WHERE whs.id = sale.id
);


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

SELECT salary FROM orders AS ordr
WHERE type IN (
    SELECT type FROM warehouses AS prod
    WHERE prod.level = ordr.level
);


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

SELECT id FROM regions AS budg
WHERE value > (
    SELECT SUM(value) FROM branches AS schd
    WHERE schd.code = budg.code
);


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

SELECT value FROM departments AS mgr
WHERE amount > (
    SELECT MIN(amount) FROM categories AS txn
    WHERE txn.level = mgr.level
);


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

SELECT salary FROM categories AS catg
WHERE value > (
    SELECT SUM(value) FROM invoices AS shp
    WHERE shp.status = catg.status
);


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

SELECT amount FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.status = emp.status
);


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

SELECT name FROM customers AS whs
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS lne
    WHERE lne.level = whs.level
);


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

SELECT amount FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.code = txn.code
);


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

SELECT amount FROM orders AS whs
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.id = whs.id
);


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

SELECT value FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = inv.level
);


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

SELECT code FROM branches AS schd
WHERE salary > (
    SELECT SUM(amount) FROM employees AS emp
    WHERE emp.level = schd.level
);


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

SELECT id FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.code = schd.code
);


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

SELECT name FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT amount FROM shipments AS ord
WHERE type IN (
    SELECT type FROM customers AS catg
    WHERE catg.status = ord.status
);


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

SELECT salary FROM departments AS cust
WHERE type IN (
    SELECT type FROM projects AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT name FROM regions AS mgr
WHERE level IN (
    SELECT level FROM suppliers AS catg
    WHERE catg.level = mgr.level
);


Prompt:
Schema:
  products (alias: acct)(salary, level, code, id)
  warehouses(level, salary, id, value)
Task: Retrieve id from products with salary above the COUNT(salary) of warehouses rows sharing the same status.
SQL:

SELECT id FROM products AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM warehouses AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT code FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.level = mgr.level
);


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

SELECT salary FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.id = rgn.id
);


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

SELECT code FROM branches AS empl
WHERE code IN (
    SELECT code FROM warehouses AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT amount FROM accounts AS rgn
WHERE value > (
    SELECT MAX(value) FROM branches AS prod
    WHERE prod.code = rgn.code
);


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

SELECT amount FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.type = catg.type
);