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

SELECT value FROM shipments AS txn
WHERE status IN (
    SELECT status FROM categories AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT salary FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.id = shp.id
);


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

SELECT salary FROM products AS whs
WHERE amount > (
    SELECT MAX(amount) FROM categories AS txn
    WHERE txn.level = whs.level
);


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

SELECT amount FROM suppliers AS ord
WHERE value > (
    SELECT COUNT(amount) FROM invoices AS schd
    WHERE schd.code = ord.code
);


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

SELECT amount FROM products AS whs
WHERE salary > (
    SELECT MIN(value) FROM invoices AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT id FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.status = txn.status
);


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

SELECT name FROM shipments AS emp
WHERE amount > (
    SELECT SUM(amount) FROM customers AS whs
    WHERE whs.status = emp.status
);


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

SELECT value FROM tasks AS lne
WHERE type IN (
    SELECT type FROM branches AS budg
    WHERE budg.status = lne.status
);


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

SELECT id FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.code = schd.code
);


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

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


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

SELECT value FROM projects AS ordr
WHERE level IN (
    SELECT level FROM departments AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT value FROM categories AS schd
WHERE code IN (
    SELECT code FROM suppliers AS acct
    WHERE acct.id = schd.id
);


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

SELECT name FROM warehouses AS inv
WHERE id IN (
    SELECT id FROM customers AS ord
    WHERE ord.status = inv.status
);


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

SELECT code FROM invoices AS acct
WHERE status IN (
    SELECT status FROM tasks AS inv
    WHERE inv.id = acct.id
);


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

SELECT salary FROM accounts AS budg
WHERE amount > (
    SELECT SUM(value) FROM shipments AS txn
    WHERE txn.id = budg.id
);


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

SELECT name FROM orders AS sale
WHERE id IN (
    SELECT id FROM suppliers AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT salary FROM branches AS lne
WHERE amount > (
    SELECT SUM(salary) FROM employees AS empl
    WHERE empl.level = lne.level
);


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

SELECT value FROM transactions AS lne
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.type = lne.type
);


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

SELECT salary FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.level = ordr.level
);


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

SELECT name FROM suppliers AS acct
WHERE level IN (
    SELECT level FROM projects AS empl
    WHERE empl.code = acct.code
);


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

SELECT name FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT id FROM invoices AS prod
WHERE status IN (
    SELECT status FROM orders AS shp
    WHERE shp.code = prod.code
);


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

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


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

SELECT id FROM departments AS cust
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS whs
    WHERE whs.type = cust.type
);


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

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


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

SELECT salary FROM orders AS empl
WHERE salary > (
    SELECT SUM(value) FROM warehouses AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT amount FROM transactions AS cust
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS prod
    WHERE prod.type = cust.type
);


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

SELECT id FROM branches AS schd
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS empl
    WHERE empl.status = schd.status
);


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

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


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

SELECT code FROM customers AS acct
WHERE level IN (
    SELECT level FROM shipments AS ord
    WHERE ord.level = acct.level
);


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

SELECT name FROM categories AS ord
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS txn
    WHERE txn.type = ord.type
);


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

SELECT amount FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.id = srvc.id
);


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

SELECT id FROM products AS ord
WHERE type IN (
    SELECT type FROM projects AS shp
    WHERE shp.id = ord.id
);


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

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


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

SELECT amount FROM shipments AS ordr
WHERE salary > (
    SELECT MIN(value) FROM warehouses AS empl
    WHERE empl.code = ordr.code
);


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

SELECT amount FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.id = budg.id
);


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

SELECT name FROM invoices AS txn
WHERE salary > (
    SELECT MIN(value) FROM employees AS emp
    WHERE emp.id = txn.id
);


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

SELECT salary FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.code = emp.code
);


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

SELECT salary FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.status = whs.status
);


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

SELECT code FROM categories AS schd
WHERE id IN (
    SELECT id FROM projects AS txn
    WHERE txn.id = schd.id
);


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

SELECT salary FROM products AS empl
WHERE value > (
    SELECT SUM(value) FROM warehouses AS budg
    WHERE budg.id = empl.id
);


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

SELECT id FROM departments AS whs
WHERE level IN (
    SELECT level FROM suppliers AS txn
    WHERE txn.level = whs.level
);


Prompt:
Schema:
  employees (alias: schd)(salary, level, value, id)
  shipments(salary, id, level, name)
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:
  tasks (alias: lne)(amount, value, name, status)
  shipments(date, status, code, level)
Task: Find amount from tasks where salary exceeds the average amount from shipments for the same status.
SQL:

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


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

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


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

SELECT name FROM products AS rgn
WHERE type IN (
    SELECT type FROM customers AS txn
    WHERE txn.id = rgn.id
);


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

SELECT code FROM transactions AS mgr
WHERE value > (
    SELECT MIN(value) FROM warehouses AS shp
    WHERE shp.level = mgr.level
);


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

SELECT amount FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.code = empl.code
);


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

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


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

SELECT name FROM categories AS acct
WHERE type IN (
    SELECT type FROM invoices AS budg
    WHERE budg.level = acct.level
);


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

SELECT code FROM tasks AS catg
WHERE value > (
    SELECT SUM(salary) FROM projects AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT name FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.type = shp.type
);


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

SELECT id FROM warehouses AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS inv
    WHERE inv.status = schd.status
);


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

SELECT amount FROM products AS acct
WHERE level IN (
    SELECT level FROM regions AS emp
    WHERE emp.status = acct.status
);


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

SELECT code FROM shipments AS inv
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.status = inv.status
);


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

SELECT amount FROM departments AS cust
WHERE status IN (
    SELECT status FROM products AS catg
    WHERE catg.id = cust.id
);


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

SELECT salary FROM regions AS ordr
WHERE type IN (
    SELECT type FROM warehouses AS sale
    WHERE sale.level = ordr.level
);


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

SELECT id FROM products AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM orders AS schd
    WHERE schd.type = srvc.type
);


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

SELECT code FROM suppliers AS catg
WHERE status IN (
    SELECT status FROM tasks AS srvc
    WHERE srvc.code = catg.code
);


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

SELECT id FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT value FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT value FROM branches AS sale
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS lne
    WHERE lne.code = sale.code
);


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

SELECT name FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.id = lne.id
);


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

SELECT amount FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.code = ord.code
);


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

SELECT salary FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.type = prod.type
);


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

SELECT amount FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.type = empl.type
);


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

SELECT name FROM orders AS emp
WHERE id IN (
    SELECT id FROM categories AS prod
    WHERE prod.type = emp.type
);


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

SELECT value FROM accounts AS lne
WHERE type IN (
    SELECT type FROM shipments AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT amount FROM departments AS prod
WHERE level IN (
    SELECT level FROM categories AS schd
    WHERE schd.status = prod.status
);


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

SELECT code FROM transactions AS rgn
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.status = rgn.status
);


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

SELECT name FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.level = prod.level
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.level = catg.level
);


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

SELECT value FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.status = catg.status
);


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

SELECT value FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.id = txn.id
);


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

SELECT value FROM products AS dept
WHERE value > (
    SELECT MAX(value) FROM accounts AS empl
    WHERE empl.id = dept.id
);


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

SELECT id FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.status = acct.status
);


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

SELECT code FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.id = schd.id
);


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

SELECT id FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.status = shp.status
);


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

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


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

SELECT salary FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.status = cust.status
);


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

SELECT code FROM products AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT id FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.type = ord.type
);


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

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


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

SELECT id FROM warehouses AS ord
WHERE type IN (
    SELECT type FROM invoices AS txn
    WHERE txn.status = ord.status
);


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

SELECT name FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.level = inv.level
);


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

SELECT name FROM tasks AS lne
WHERE value > (
    SELECT MIN(amount) FROM transactions AS cust
    WHERE cust.code = lne.code
);


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

SELECT name FROM shipments AS budg
WHERE amount > (
    SELECT SUM(value) FROM customers AS sale
    WHERE sale.level = budg.level
);


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

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


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

SELECT value FROM branches AS inv
WHERE amount > (
    SELECT COUNT(salary) FROM departments AS txn
    WHERE txn.id = inv.id
);


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

SELECT amount FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.code = dept.code
);


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

SELECT value FROM shipments AS schd
WHERE level IN (
    SELECT level FROM warehouses AS whs
    WHERE whs.type = schd.type
);


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

SELECT value FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.status = srvc.status
);


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

SELECT code FROM departments AS inv
WHERE code IN (
    SELECT code FROM tasks AS mgr
    WHERE mgr.level = inv.level
);


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

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


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

SELECT code FROM categories AS inv
WHERE status IN (
    SELECT status FROM branches AS ord
    WHERE ord.level = inv.level
);


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

SELECT value FROM shipments AS budg
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.id = budg.id
);


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

SELECT salary FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.id = schd.id
);


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

SELECT salary FROM warehouses AS mgr
WHERE code IN (
    SELECT code FROM employees AS dept
    WHERE dept.level = mgr.level
);


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

SELECT salary FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.status = budg.status
);


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

SELECT code FROM accounts AS prod
WHERE id IN (
    SELECT id FROM projects AS acct
    WHERE acct.level = prod.level
);


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

SELECT name FROM transactions AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM branches AS emp
    WHERE emp.level = ordr.level
);


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

SELECT id FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.status = whs.status
);


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

SELECT amount FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT value FROM invoices AS cust
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT value FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT name FROM employees AS mgr
WHERE level IN (
    SELECT level FROM branches AS shp
    WHERE shp.status = mgr.status
);


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

SELECT name FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.code = acct.code
);


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

SELECT code FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.type = inv.type
);


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

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


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

SELECT amount FROM employees AS lne
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.level = lne.level
);


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

SELECT amount FROM warehouses AS cust
WHERE salary > (
    SELECT SUM(salary) FROM orders AS acct
    WHERE acct.status = cust.status
);


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

SELECT name FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.status = mgr.status
);


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

SELECT code FROM products AS catg
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.id = catg.id
);


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

SELECT salary FROM orders AS acct
WHERE level IN (
    SELECT level FROM branches AS catg
    WHERE catg.code = acct.code
);


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

SELECT salary FROM orders AS prod
WHERE salary > (
    SELECT MAX(salary) FROM customers AS lne
    WHERE lne.type = prod.type
);


Prompt:
Schema:
  branches (alias: cust)(status, type, date, name)
  warehouses(date, status, amount, type)
Task: Retrieve code from branches with amount above the MAX(salary) of warehouses rows sharing the same code.
SQL:

SELECT code FROM branches AS cust
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS schd
    WHERE schd.code = cust.code
);


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

SELECT id FROM departments AS emp
WHERE amount > (
    SELECT COUNT(salary) FROM products AS ordr
    WHERE ordr.id = emp.id
);


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

SELECT name FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.status = inv.status
);


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

SELECT id FROM warehouses AS catg
WHERE type IN (
    SELECT type FROM branches AS txn
    WHERE txn.type = catg.type
);


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

SELECT value FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.type = inv.type
);


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

SELECT amount FROM warehouses AS lne
WHERE status IN (
    SELECT status FROM products AS shp
    WHERE shp.code = lne.code
);


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

SELECT salary FROM departments AS mgr
WHERE value > (
    SELECT AVG(salary) FROM employees AS shp
    WHERE shp.type = mgr.type
);


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

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM invoices AS schd
    WHERE schd.id = cust.id
);


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

SELECT code FROM branches AS catg
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT code FROM employees AS emp
WHERE salary > (
    SELECT MIN(salary) FROM products AS ord
    WHERE ord.status = emp.status
);


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

SELECT amount FROM warehouses AS mgr
WHERE code IN (
    SELECT code FROM suppliers AS acct
    WHERE acct.status = mgr.status
);


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

SELECT salary FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.status = emp.status
);


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

SELECT salary FROM suppliers AS inv
WHERE level IN (
    SELECT level FROM orders AS schd
    WHERE schd.code = inv.code
);


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

SELECT code FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT id FROM shipments AS whs
WHERE value > (
    SELECT AVG(salary) FROM categories AS acct
    WHERE acct.type = whs.type
);


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

SELECT code FROM transactions AS emp
WHERE type IN (
    SELECT type FROM departments AS acct
    WHERE acct.id = emp.id
);


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

SELECT amount FROM customers AS inv
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS mgr
    WHERE mgr.level = inv.level
);


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

SELECT id FROM employees AS catg
WHERE value > (
    SELECT SUM(value) FROM invoices AS dept
    WHERE dept.id = catg.id
);


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

SELECT id FROM branches AS emp
WHERE status IN (
    SELECT status FROM invoices AS dept
    WHERE dept.id = emp.id
);


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

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


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

SELECT salary FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.id = shp.id
);


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

SELECT id FROM regions AS prod
WHERE status IN (
    SELECT status FROM suppliers AS ordr
    WHERE ordr.level = prod.level
);


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

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


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

SELECT id FROM shipments AS schd
WHERE amount > (
    SELECT AVG(amount) FROM orders AS empl
    WHERE empl.status = schd.status
);


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

SELECT value FROM warehouses AS cust
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.type = cust.type
);


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

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


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

SELECT name FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.code = prod.code
);


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

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


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

SELECT amount FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT id FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.status = rgn.status
);


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

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


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

SELECT id FROM warehouses AS prod
WHERE code IN (
    SELECT code FROM tasks AS ord
    WHERE ord.id = prod.id
);


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

SELECT amount FROM accounts AS whs
WHERE level IN (
    SELECT level FROM orders AS inv
    WHERE inv.type = whs.type
);


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

SELECT code FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.status = schd.status
);


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

SELECT salary FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.type = lne.type
);


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

SELECT code FROM projects AS ordr
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS cust
    WHERE cust.type = ordr.type
);


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

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


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

SELECT code FROM categories AS shp
WHERE type IN (
    SELECT type FROM warehouses AS srvc
    WHERE srvc.id = shp.id
);


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

SELECT name FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT code FROM regions AS prod
WHERE id IN (
    SELECT id FROM categories AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT name FROM projects AS srvc
WHERE status IN (
    SELECT status FROM accounts AS catg
    WHERE catg.type = srvc.type
);


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

SELECT salary FROM projects AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM customers AS emp
    WHERE emp.status = rgn.status
);


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

SELECT salary FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.code = catg.code
);


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

SELECT id FROM transactions AS rgn
WHERE id IN (
    SELECT id FROM employees AS prod
    WHERE prod.code = rgn.code
);


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

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


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

SELECT salary FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.id = srvc.id
);


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

SELECT amount FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT amount FROM accounts AS whs
WHERE code IN (
    SELECT code FROM suppliers AS txn
    WHERE txn.level = whs.level
);


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

SELECT salary FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.id = txn.id
);


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

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


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

SELECT code FROM regions AS sale
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.type = sale.type
);


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

SELECT salary FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.type = dept.type
);


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

SELECT code FROM employees AS mgr
WHERE level IN (
    SELECT level FROM invoices AS prod
    WHERE prod.level = mgr.level
);


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

SELECT id FROM transactions AS txn
WHERE id IN (
    SELECT id FROM branches AS cust
    WHERE cust.level = txn.level
);


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

SELECT amount FROM suppliers AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM employees AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT value FROM departments AS schd
WHERE level IN (
    SELECT level FROM products AS shp
    WHERE shp.status = schd.status
);


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

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


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

SELECT value FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.code = ordr.code
);


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

SELECT code FROM customers AS txn
WHERE level IN (
    SELECT level FROM accounts AS ord
    WHERE ord.code = txn.code
);


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

SELECT id FROM accounts AS mgr
WHERE type IN (
    SELECT type FROM projects AS dept
    WHERE dept.type = mgr.type
);


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

SELECT value FROM suppliers AS rgn
WHERE code IN (
    SELECT code FROM tasks AS shp
    WHERE shp.type = rgn.type
);


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

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


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

SELECT amount FROM transactions AS cust
WHERE code IN (
    SELECT code FROM branches AS empl
    WHERE empl.status = cust.status
);


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

SELECT amount FROM branches AS cust
WHERE value > (
    SELECT COUNT(value) FROM tasks AS dept
    WHERE dept.id = cust.id
);


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

SELECT salary FROM invoices AS ord
WHERE code IN (
    SELECT code FROM departments AS acct
    WHERE acct.status = ord.status
);


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

SELECT amount FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.id = inv.id
);


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

SELECT salary FROM invoices AS ord
WHERE value > (
    SELECT MAX(value) FROM regions AS srvc
    WHERE srvc.level = ord.level
);


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

SELECT code FROM projects AS whs
WHERE value > (
    SELECT AVG(salary) FROM employees AS sale
    WHERE sale.code = whs.code
);


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

SELECT salary FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.code = budg.code
);


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

SELECT id FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.level = budg.level
);


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

SELECT value FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.status = prod.status
);


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

SELECT amount FROM warehouses AS txn
WHERE type IN (
    SELECT type FROM branches AS budg
    WHERE budg.type = txn.type
);


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

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


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

SELECT id FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.code = inv.code
);


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

SELECT id FROM categories AS shp
WHERE salary > (
    SELECT MIN(value) FROM accounts AS emp
    WHERE emp.status = shp.status
);


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

SELECT code FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.level = emp.level
);


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

SELECT amount FROM invoices AS whs
WHERE value > (
    SELECT MIN(amount) FROM accounts AS ordr
    WHERE ordr.id = whs.id
);


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

SELECT code FROM customers AS inv
WHERE id IN (
    SELECT id FROM branches AS txn
    WHERE txn.level = inv.level
);


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

SELECT id FROM orders AS mgr
WHERE status IN (
    SELECT status FROM warehouses AS budg
    WHERE budg.code = mgr.code
);


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

SELECT amount FROM regions AS txn
WHERE salary > (
    SELECT COUNT(value) FROM suppliers AS prod
    WHERE prod.type = txn.type
);


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

SELECT amount FROM warehouses AS whs
WHERE value > (
    SELECT AVG(value) FROM invoices AS dept
    WHERE dept.level = whs.level
);


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

SELECT code FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.id = cust.id
);


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

SELECT salary FROM products AS schd
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS inv
    WHERE inv.id = schd.id
);


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

SELECT salary FROM orders AS rgn
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.status = rgn.status
);


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

SELECT id FROM departments AS shp
WHERE level IN (
    SELECT level FROM categories AS catg
    WHERE catg.id = shp.id
);


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

SELECT code FROM departments AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM products AS txn
    WHERE txn.id = ordr.id
);


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

SELECT id FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.code = empl.code
);


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

SELECT code FROM categories AS empl
WHERE status IN (
    SELECT status FROM transactions AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT id FROM tasks AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM projects AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT value FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.level = txn.level
);


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

SELECT value FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.id = emp.id
);


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

SELECT id FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.code = sale.code
);


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

SELECT amount FROM suppliers AS mgr
WHERE salary > (
    SELECT SUM(value) FROM accounts AS cust
    WHERE cust.level = mgr.level
);


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

SELECT name FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.level = lne.level
);


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

SELECT value FROM regions AS acct
WHERE type IN (
    SELECT type FROM categories AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT salary FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.type = empl.type
);


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

SELECT salary FROM branches AS budg
WHERE amount > (
    SELECT MIN(amount) FROM departments AS lne
    WHERE lne.id = budg.id
);


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

SELECT salary FROM regions AS budg
WHERE salary > (
    SELECT AVG(amount) FROM invoices AS whs
    WHERE whs.code = budg.code
);


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

SELECT amount FROM categories AS dept
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS lne
    WHERE lne.code = dept.code
);


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

SELECT code FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.type = rgn.type
);


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

SELECT id FROM invoices AS catg
WHERE value > (
    SELECT MIN(salary) FROM products AS inv
    WHERE inv.type = catg.type
);


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

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


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

SELECT value FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.id = mgr.id
);


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

SELECT id FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.status = dept.status
);


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

SELECT value FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM projects AS inv
    WHERE inv.level = ordr.level
);


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

SELECT code FROM categories AS ord
WHERE type IN (
    SELECT type FROM transactions AS catg
    WHERE catg.type = ord.type
);


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

SELECT amount FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT code FROM transactions AS ordr
WHERE level IN (
    SELECT level FROM tasks AS empl
    WHERE empl.status = ordr.status
);


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

SELECT name FROM suppliers AS budg
WHERE id IN (
    SELECT id FROM tasks AS dept
    WHERE dept.level = budg.level
);


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

SELECT value FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.status = cust.status
);


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT amount FROM tasks AS dept
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS txn
    WHERE txn.level = dept.level
);


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

SELECT amount FROM tasks AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS rgn
    WHERE rgn.code = ordr.code
);


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

SELECT id FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.id = lne.id
);


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

SELECT salary FROM tasks AS catg
WHERE code IN (
    SELECT code FROM products AS lne
    WHERE lne.code = catg.code
);


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

SELECT id FROM branches AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS prod
    WHERE prod.id = ordr.id
);


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

SELECT code FROM warehouses AS dept
WHERE value > (
    SELECT MAX(value) FROM customers AS lne
    WHERE lne.type = dept.type
);


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

SELECT value FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.level = rgn.level
);


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

SELECT code FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.id = empl.id
);


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

SELECT amount FROM projects AS srvc
WHERE level IN (
    SELECT level FROM orders AS empl
    WHERE empl.status = srvc.status
);


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

SELECT code FROM shipments AS txn
WHERE level IN (
    SELECT level FROM employees AS cust
    WHERE cust.level = txn.level
);


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

SELECT code FROM accounts AS cust
WHERE level IN (
    SELECT level FROM employees AS sale
    WHERE sale.code = cust.code
);


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

SELECT value FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.status = shp.status
);


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

SELECT code FROM products AS srvc
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS ord
    WHERE ord.code = srvc.code
);


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

SELECT amount FROM orders AS ord
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT value FROM branches AS acct
WHERE level IN (
    SELECT level FROM regions AS budg
    WHERE budg.id = acct.id
);


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

SELECT code FROM products AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM projects AS acct
    WHERE acct.id = ordr.id
);


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

SELECT salary FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT id FROM products AS prod
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS schd
    WHERE schd.status = prod.status
);


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

SELECT amount FROM tasks AS inv
WHERE value > (
    SELECT SUM(salary) FROM transactions AS lne
    WHERE lne.code = inv.code
);


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

SELECT amount FROM categories AS ord
WHERE amount > (
    SELECT AVG(salary) FROM employees AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT name FROM shipments AS rgn
WHERE value > (
    SELECT AVG(value) FROM branches AS srvc
    WHERE srvc.type = rgn.type
);


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

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


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

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


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

SELECT value FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.level = budg.level
);


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

SELECT salary FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = cust.id
);


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

SELECT amount FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.status = txn.status
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.id = ord.id
);


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

SELECT id FROM regions AS shp
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.type = shp.type
);


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

SELECT salary FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.code = lne.code
);


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

SELECT name FROM employees AS txn
WHERE status IN (
    SELECT status FROM departments AS inv
    WHERE inv.id = txn.id
);


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

SELECT amount FROM customers AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS catg
    WHERE catg.id = txn.id
);


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

SELECT name FROM invoices AS lne
WHERE id IN (
    SELECT id FROM projects AS ord
    WHERE ord.id = lne.id
);


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

SELECT name FROM departments AS rgn
WHERE value > (
    SELECT MAX(salary) FROM suppliers AS ordr
    WHERE ordr.level = rgn.level
);


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

SELECT value FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT id FROM tasks AS dept
WHERE id IN (
    SELECT id FROM projects AS txn
    WHERE txn.level = dept.level
);


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

SELECT id FROM departments AS empl
WHERE amount > (
    SELECT MIN(salary) FROM projects AS txn
    WHERE txn.level = empl.level
);


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

SELECT value FROM transactions AS rgn
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.id = rgn.id
);


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

SELECT id FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.id = catg.id
);


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

SELECT id FROM products AS mgr
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT name FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.code = catg.code
);


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

SELECT code FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT id FROM shipments AS schd
WHERE amount > (
    SELECT MIN(amount) FROM departments AS inv
    WHERE inv.id = schd.id
);


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

SELECT name FROM shipments AS empl
WHERE amount > (
    SELECT MIN(salary) FROM orders AS schd
    WHERE schd.level = empl.level
);


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

SELECT id FROM employees AS emp
WHERE type IN (
    SELECT type FROM warehouses AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT id FROM categories AS mgr
WHERE salary > (
    SELECT AVG(value) FROM departments AS sale
    WHERE sale.code = mgr.code
);


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

SELECT value FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.id = mgr.id
);


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

SELECT amount FROM categories AS rgn
WHERE salary > (
    SELECT MAX(value) FROM invoices AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT salary FROM invoices AS inv
WHERE amount > (
    SELECT MIN(salary) FROM products AS emp
    WHERE emp.status = inv.status
);


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

SELECT name FROM customers AS budg
WHERE id IN (
    SELECT id FROM tasks AS acct
    WHERE acct.type = budg.type
);


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

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


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

SELECT code FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.status = txn.status
);


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

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


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

SELECT id FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.code = mgr.code
);


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

SELECT code FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.id = inv.id
);


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

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


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

SELECT amount FROM shipments AS ordr
WHERE status IN (
    SELECT status FROM departments AS sale
    WHERE sale.type = ordr.type
);


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

SELECT salary FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.code = schd.code
);


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

SELECT salary FROM customers AS txn
WHERE level IN (
    SELECT level FROM warehouses AS rgn
    WHERE rgn.level = txn.level
);


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

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


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

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


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

SELECT name FROM suppliers AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS acct
    WHERE acct.status = lne.status
);


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

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


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

SELECT name FROM shipments AS dept
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS schd
    WHERE schd.status = dept.status
);


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

SELECT amount FROM accounts AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.level = inv.level
);


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

SELECT amount FROM products AS sale
WHERE value > (
    SELECT MAX(salary) FROM tasks AS prod
    WHERE prod.status = sale.status
);


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

SELECT id FROM categories AS dept
WHERE code IN (
    SELECT code FROM employees AS ord
    WHERE ord.status = dept.status
);


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

SELECT name FROM shipments AS empl
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS prod
    WHERE prod.code = empl.code
);