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

SELECT value FROM suppliers AS inv
WHERE level IN (
    SELECT level FROM categories AS budg
    WHERE budg.id = inv.id
);


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

SELECT value FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = lne.id
);


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

SELECT id FROM projects AS ordr
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.id = ordr.id
);


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

SELECT amount FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.level = whs.level
);


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

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


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

SELECT name FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.type = budg.type
);


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

SELECT code FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.code = srvc.code
);


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

SELECT name FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.status = dept.status
);


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

SELECT code FROM invoices AS acct
WHERE type IN (
    SELECT type FROM orders AS whs
    WHERE whs.id = acct.id
);


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

SELECT value FROM warehouses AS whs
WHERE type IN (
    SELECT type FROM accounts AS txn
    WHERE txn.level = whs.level
);


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

SELECT amount FROM products AS cust
WHERE type IN (
    SELECT type FROM shipments AS budg
    WHERE budg.id = cust.id
);


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

SELECT value FROM tasks AS schd
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS ord
    WHERE ord.code = schd.code
);


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

SELECT id FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.level = budg.level
);


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

SELECT salary FROM branches AS acct
WHERE level IN (
    SELECT level FROM tasks AS budg
    WHERE budg.type = acct.type
);


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

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


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

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


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

SELECT value FROM employees AS acct
WHERE salary > (
    SELECT MIN(value) FROM tasks AS ord
    WHERE ord.level = acct.level
);


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

SELECT amount FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT name FROM transactions AS dept
WHERE salary > (
    SELECT AVG(value) FROM customers AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT id FROM orders AS lne
WHERE value > (
    SELECT COUNT(value) FROM transactions AS inv
    WHERE inv.status = lne.status
);


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

SELECT id FROM categories AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM branches AS shp
    WHERE shp.level = mgr.level
);


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

SELECT name FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.type = inv.type
);


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

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


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

SELECT salary FROM transactions AS budg
WHERE level IN (
    SELECT level FROM branches AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT name FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.id = cust.id
);


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

SELECT value FROM warehouses AS whs
WHERE value > (
    SELECT MAX(value) FROM tasks AS ordr
    WHERE ordr.id = whs.id
);


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

SELECT amount FROM departments AS shp
WHERE amount > (
    SELECT MAX(amount) FROM categories AS prod
    WHERE prod.level = shp.level
);


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

SELECT name FROM transactions AS inv
WHERE type IN (
    SELECT type FROM tasks AS ord
    WHERE ord.code = inv.code
);


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

SELECT amount FROM accounts AS cust
WHERE amount > (
    SELECT MIN(value) FROM employees AS whs
    WHERE whs.code = cust.code
);


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

SELECT value FROM shipments AS catg
WHERE code IN (
    SELECT code FROM warehouses AS budg
    WHERE budg.id = catg.id
);


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

SELECT id FROM projects AS rgn
WHERE code IN (
    SELECT code FROM invoices AS lne
    WHERE lne.code = rgn.code
);


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

SELECT salary FROM branches AS emp
WHERE value > (
    SELECT MIN(salary) FROM invoices AS lne
    WHERE lne.level = emp.level
);


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

SELECT id FROM regions AS txn
WHERE amount > (
    SELECT AVG(salary) FROM warehouses AS whs
    WHERE whs.status = txn.status
);


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

SELECT salary FROM categories AS inv
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS catg
    WHERE catg.code = inv.code
);


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

SELECT amount FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.status = prod.status
);


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

SELECT code FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.status = cust.status
);


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

SELECT code FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.level = emp.level
);


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

SELECT value FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.type = srvc.type
);


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

SELECT salary FROM orders AS emp
WHERE amount > (
    SELECT MAX(value) FROM transactions AS dept
    WHERE dept.code = emp.code
);


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

SELECT value FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM suppliers AS acct
    WHERE acct.type = mgr.type
);


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

SELECT name FROM accounts AS prod
WHERE level IN (
    SELECT level FROM invoices AS inv
    WHERE inv.status = prod.status
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.code = dept.code
);


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

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


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

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


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

SELECT code FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.type = rgn.type
);


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

SELECT amount FROM regions AS cust
WHERE salary > (
    SELECT MAX(amount) FROM categories AS sale
    WHERE sale.status = cust.status
);


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

SELECT amount FROM transactions AS cust
WHERE status IN (
    SELECT status FROM accounts AS prod
    WHERE prod.type = cust.type
);


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

SELECT value FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.type = shp.type
);


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

SELECT name FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT amount FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.status = whs.status
);


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

SELECT id FROM regions AS budg
WHERE amount > (
    SELECT COUNT(value) FROM orders AS schd
    WHERE schd.code = budg.code
);


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

SELECT amount FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.status = rgn.status
);


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

SELECT id FROM products AS ordr
WHERE value > (
    SELECT COUNT(value) FROM tasks AS lne
    WHERE lne.status = ordr.status
);


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

SELECT salary FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.status = emp.status
);


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

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


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

SELECT amount FROM customers AS cust
WHERE level IN (
    SELECT level FROM tasks AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT code FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.status = mgr.status
);


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

SELECT amount FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.code = empl.code
);


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

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


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

SELECT salary FROM shipments AS empl
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS cust
    WHERE cust.status = empl.status
);


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

SELECT value FROM departments AS ord
WHERE amount > (
    SELECT SUM(salary) FROM regions AS shp
    WHERE shp.status = ord.status
);


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

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


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

SELECT code FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.status = sale.status
);


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

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


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

SELECT salary FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.type = srvc.type
);


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

SELECT name FROM employees AS txn
WHERE status IN (
    SELECT status FROM invoices AS ord
    WHERE ord.level = txn.level
);


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

SELECT id FROM orders AS shp
WHERE id IN (
    SELECT id FROM accounts AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT salary FROM transactions AS shp
WHERE id IN (
    SELECT id FROM projects AS rgn
    WHERE rgn.type = shp.type
);


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

SELECT salary FROM customers AS rgn
WHERE id IN (
    SELECT id FROM orders AS empl
    WHERE empl.code = rgn.code
);


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

SELECT name FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT value FROM branches AS shp
WHERE level IN (
    SELECT level FROM shipments AS sale
    WHERE sale.type = shp.type
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.id = whs.id
);


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

SELECT id FROM projects AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM customers AS empl
    WHERE empl.level = mgr.level
);


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

SELECT id FROM shipments AS ord
WHERE amount > (
    SELECT SUM(value) FROM categories AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT name FROM accounts AS whs
WHERE type IN (
    SELECT type FROM customers AS ord
    WHERE ord.code = whs.code
);


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

SELECT salary FROM regions AS budg
WHERE code IN (
    SELECT code FROM warehouses AS schd
    WHERE schd.id = budg.id
);


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

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


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

SELECT amount FROM suppliers AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS inv
    WHERE inv.status = rgn.status
);


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

SELECT amount FROM products AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT salary FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.type = inv.type
);


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

SELECT amount FROM departments AS empl
WHERE salary > (
    SELECT SUM(salary) FROM employees AS inv
    WHERE inv.code = empl.code
);


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

SELECT amount FROM products AS inv
WHERE salary > (
    SELECT COUNT(value) FROM warehouses AS schd
    WHERE schd.level = inv.level
);


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

SELECT name FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.id = catg.id
);


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

SELECT salary FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = whs.level
);


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

SELECT code FROM invoices AS srvc
WHERE salary > (
    SELECT AVG(value) FROM transactions AS schd
    WHERE schd.code = srvc.code
);


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

SELECT code FROM categories AS inv
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS catg
    WHERE catg.status = inv.status
);


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

SELECT amount FROM departments AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS prod
    WHERE prod.status = ordr.status
);


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

SELECT value FROM transactions AS prod
WHERE amount > (
    SELECT SUM(salary) FROM warehouses AS sale
    WHERE sale.type = prod.type
);


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

SELECT value FROM shipments AS emp
WHERE code IN (
    SELECT code FROM orders AS catg
    WHERE catg.status = emp.status
);


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

SELECT amount FROM projects AS cust
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS inv
    WHERE inv.status = cust.status
);


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

SELECT id FROM projects AS shp
WHERE amount > (
    SELECT AVG(value) FROM branches AS sale
    WHERE sale.level = shp.level
);


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

SELECT salary FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.level = emp.level
);


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

SELECT name FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.type = acct.type
);


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

SELECT value FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.type = rgn.type
);


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

SELECT amount FROM suppliers AS ordr
WHERE code IN (
    SELECT code FROM projects AS shp
    WHERE shp.status = ordr.status
);


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

SELECT code FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = inv.type
);


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

SELECT amount FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.id = ordr.id
);


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

SELECT value FROM regions AS budg
WHERE value > (
    SELECT MAX(salary) FROM departments AS txn
    WHERE txn.id = budg.id
);


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

SELECT code FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.level = whs.level
);


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

SELECT code FROM accounts AS empl
WHERE id IN (
    SELECT id FROM orders AS emp
    WHERE emp.id = empl.id
);


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

SELECT value FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT salary FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.type = rgn.type
);


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

SELECT name FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.code = inv.code
);


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

SELECT id FROM projects AS rgn
WHERE type IN (
    SELECT type FROM branches AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT id FROM regions AS lne
WHERE salary > (
    SELECT SUM(amount) FROM employees AS whs
    WHERE whs.status = lne.status
);


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

SELECT code FROM orders AS srvc
WHERE value > (
    SELECT COUNT(salary) FROM warehouses AS inv
    WHERE inv.status = srvc.status
);


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

SELECT name FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.id = lne.id
);


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

SELECT id FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.level = prod.level
);


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

SELECT code FROM categories AS mgr
WHERE type IN (
    SELECT type FROM branches AS schd
    WHERE schd.id = mgr.id
);


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

SELECT code FROM shipments AS srvc
WHERE level IN (
    SELECT level FROM warehouses AS sale
    WHERE sale.id = srvc.id
);


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

SELECT name FROM departments AS empl
WHERE level IN (
    SELECT level FROM customers AS txn
    WHERE txn.type = empl.type
);


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

SELECT name FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.level = budg.level
);


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

SELECT id FROM departments AS budg
WHERE salary > (
    SELECT MAX(amount) FROM employees AS lne
    WHERE lne.level = budg.level
);


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

SELECT name FROM transactions AS ord
WHERE level IN (
    SELECT level FROM employees AS whs
    WHERE whs.code = ord.code
);


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

SELECT name FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.status = empl.status
);


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

SELECT id FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = ordr.type
);


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

SELECT amount FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.level = prod.level
);


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

SELECT salary FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.code = catg.code
);


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

SELECT name FROM categories AS empl
WHERE salary > (
    SELECT COUNT(amount) FROM orders AS prod
    WHERE prod.level = empl.level
);


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

SELECT salary FROM accounts AS inv
WHERE amount > (
    SELECT MAX(salary) FROM departments AS catg
    WHERE catg.level = inv.level
);


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

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


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

SELECT amount FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.status = ordr.status
);


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

SELECT amount FROM invoices AS txn
WHERE id IN (
    SELECT id FROM customers AS shp
    WHERE shp.type = txn.type
);


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

SELECT salary FROM invoices AS schd
WHERE status IN (
    SELECT status FROM employees AS sale
    WHERE sale.id = schd.id
);


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

SELECT salary FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = empl.status
);


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

SELECT amount FROM transactions AS ordr
WHERE salary > (
    SELECT AVG(value) FROM invoices AS acct
    WHERE acct.level = ordr.level
);


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

SELECT code FROM employees AS catg
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.type = catg.type
);


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

SELECT code FROM regions AS schd
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS shp
    WHERE shp.code = schd.code
);


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

SELECT value FROM customers AS cust
WHERE salary > (
    SELECT COUNT(amount) FROM warehouses AS ordr
    WHERE ordr.code = cust.code
);


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

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


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

SELECT amount FROM regions AS empl
WHERE salary > (
    SELECT SUM(salary) FROM branches AS cust
    WHERE cust.type = empl.type
);


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

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


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

SELECT id FROM accounts AS srvc
WHERE id IN (
    SELECT id FROM shipments AS dept
    WHERE dept.id = srvc.id
);


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

SELECT id FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.status = whs.status
);


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

SELECT value FROM shipments AS shp
WHERE code IN (
    SELECT code FROM products AS sale
    WHERE sale.type = shp.type
);


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

SELECT id FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.level = srvc.level
);


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

SELECT salary FROM orders AS ord
WHERE id IN (
    SELECT id FROM categories AS shp
    WHERE shp.type = ord.type
);


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

SELECT name FROM products AS lne
WHERE code IN (
    SELECT code FROM warehouses AS sale
    WHERE sale.id = lne.id
);


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

SELECT id FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.id = mgr.id
);


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

SELECT id FROM transactions AS prod
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS ord
    WHERE ord.level = prod.level
);


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

SELECT salary FROM transactions AS cust
WHERE code IN (
    SELECT code FROM invoices AS schd
    WHERE schd.type = cust.type
);


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

SELECT amount FROM warehouses AS shp
WHERE code IN (
    SELECT code FROM employees AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT value FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.code = srvc.code
);


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

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


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

SELECT salary FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = acct.code
);


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

SELECT name FROM transactions AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS empl
    WHERE empl.code = lne.code
);


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

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


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

SELECT code FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.code = catg.code
);


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

SELECT id FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = acct.id
);


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

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


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

SELECT amount FROM customers AS mgr
WHERE level IN (
    SELECT level FROM suppliers AS whs
    WHERE whs.status = mgr.status
);


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

SELECT salary FROM accounts AS inv
WHERE salary > (
    SELECT SUM(salary) FROM products AS cust
    WHERE cust.status = inv.status
);


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

SELECT amount FROM invoices AS budg
WHERE id IN (
    SELECT id FROM categories AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT name FROM projects AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS empl
    WHERE empl.type = sale.type
);


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

SELECT code FROM warehouses AS dept
WHERE code IN (
    SELECT code FROM employees AS catg
    WHERE catg.code = dept.code
);


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

SELECT id FROM invoices AS emp
WHERE level IN (
    SELECT level FROM tasks AS cust
    WHERE cust.level = emp.level
);


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

SELECT salary FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.status = ordr.status
);


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

SELECT salary FROM tasks AS srvc
WHERE id IN (
    SELECT id FROM customers AS lne
    WHERE lne.level = srvc.level
);


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

SELECT salary FROM orders AS acct
WHERE status IN (
    SELECT status FROM transactions AS prod
    WHERE prod.type = acct.type
);


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

SELECT name FROM products AS srvc
WHERE value > (
    SELECT AVG(amount) FROM categories AS lne
    WHERE lne.type = srvc.type
);


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

SELECT name FROM projects AS srvc
WHERE value > (
    SELECT MAX(salary) FROM customers AS txn
    WHERE txn.id = srvc.id
);


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

SELECT amount FROM transactions AS rgn
WHERE code IN (
    SELECT code FROM regions AS prod
    WHERE prod.level = rgn.level
);


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

SELECT value FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.id = cust.id
);


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

SELECT amount FROM transactions AS schd
WHERE status IN (
    SELECT status FROM departments AS prod
    WHERE prod.id = schd.id
);


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

SELECT salary FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.id = srvc.id
);


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

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


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

SELECT code FROM projects AS cust
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS whs
    WHERE whs.status = cust.status
);


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

SELECT code FROM suppliers AS acct
WHERE value > (
    SELECT MAX(value) FROM accounts AS catg
    WHERE catg.type = acct.type
);


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

SELECT code FROM shipments AS catg
WHERE level IN (
    SELECT level FROM transactions AS lne
    WHERE lne.id = catg.id
);


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

SELECT id FROM branches AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM warehouses AS dept
    WHERE dept.code = mgr.code
);


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

SELECT id FROM orders AS prod
WHERE status IN (
    SELECT status FROM branches AS emp
    WHERE emp.status = prod.status
);


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

SELECT id FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.code = txn.code
);


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

SELECT salary FROM tasks AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT amount FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT id FROM transactions AS srvc
WHERE status IN (
    SELECT status FROM branches AS whs
    WHERE whs.level = srvc.level
);


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

SELECT salary FROM suppliers AS empl
WHERE level IN (
    SELECT level FROM products AS whs
    WHERE whs.type = empl.type
);


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

SELECT id FROM tasks AS srvc
WHERE type IN (
    SELECT type FROM employees AS schd
    WHERE schd.level = srvc.level
);


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

SELECT code FROM branches AS whs
WHERE code IN (
    SELECT code FROM accounts AS catg
    WHERE catg.code = whs.code
);


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

SELECT salary FROM transactions AS ord
WHERE salary > (
    SELECT SUM(value) FROM shipments AS acct
    WHERE acct.code = ord.code
);


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

SELECT amount FROM customers AS srvc
WHERE status IN (
    SELECT status FROM transactions AS sale
    WHERE sale.level = srvc.level
);


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

SELECT value FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.status = ordr.status
);


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

SELECT value FROM products AS acct
WHERE level IN (
    SELECT level FROM branches AS dept
    WHERE dept.code = acct.code
);


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

SELECT value FROM orders AS sale
WHERE type IN (
    SELECT type FROM shipments AS budg
    WHERE budg.id = sale.id
);


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

SELECT amount FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT amount FROM orders AS prod
WHERE type IN (
    SELECT type FROM regions AS srvc
    WHERE srvc.level = prod.level
);


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

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


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

SELECT id FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.level = rgn.level
);


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

SELECT salary FROM employees AS catg
WHERE status IN (
    SELECT status FROM projects AS lne
    WHERE lne.id = catg.id
);


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

SELECT code FROM branches AS sale
WHERE code IN (
    SELECT code FROM orders AS cust
    WHERE cust.level = sale.level
);


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

SELECT value FROM suppliers AS mgr
WHERE code IN (
    SELECT code FROM projects AS budg
    WHERE budg.id = mgr.id
);


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

SELECT code FROM products AS prod
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.type = prod.type
);


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

SELECT salary FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.type = dept.type
);


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

SELECT amount FROM regions AS srvc
WHERE value > (
    SELECT MIN(salary) FROM warehouses AS acct
    WHERE acct.code = srvc.code
);


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

SELECT salary FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT name FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.status = mgr.status
);


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

SELECT amount FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.code = lne.code
);


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

SELECT code FROM shipments AS empl
WHERE id IN (
    SELECT id FROM employees AS srvc
    WHERE srvc.type = empl.type
);


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

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


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

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


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

SELECT salary FROM products AS dept
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS mgr
    WHERE mgr.code = dept.code
);


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

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


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

SELECT value FROM suppliers AS txn
WHERE value > (
    SELECT MIN(value) FROM departments AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT amount FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.level = ordr.level
);


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

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


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

SELECT code FROM customers AS emp
WHERE type IN (
    SELECT type FROM regions AS prod
    WHERE prod.status = emp.status
);


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

SELECT id FROM tasks AS inv
WHERE id IN (
    SELECT id FROM invoices AS sale
    WHERE sale.id = inv.id
);


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

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


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

SELECT salary FROM warehouses AS prod
WHERE level IN (
    SELECT level FROM transactions AS budg
    WHERE budg.id = prod.id
);


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

SELECT salary FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = lne.id
);


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

SELECT salary FROM shipments AS shp
WHERE amount > (
    SELECT AVG(amount) FROM accounts AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT value FROM orders AS emp
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS acct
    WHERE acct.code = emp.code
);


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

SELECT amount FROM tasks AS ord
WHERE value > (
    SELECT MIN(amount) FROM departments AS dept
    WHERE dept.status = ord.status
);


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

SELECT id FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.type = whs.type
);


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

SELECT value FROM invoices AS catg
WHERE value > (
    SELECT MIN(value) FROM suppliers AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT code FROM departments AS inv
WHERE code IN (
    SELECT code FROM customers AS catg
    WHERE catg.status = inv.status
);


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

SELECT name FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT value FROM accounts AS budg
WHERE value > (
    SELECT MAX(value) FROM products AS shp
    WHERE shp.code = budg.code
);


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

SELECT value FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT salary FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.status = txn.status
);


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

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


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

SELECT code FROM categories AS dept
WHERE value > (
    SELECT MAX(salary) FROM departments AS srvc
    WHERE srvc.code = dept.code
);


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

SELECT value FROM categories AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM products AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT value FROM branches AS dept
WHERE value > (
    SELECT MAX(salary) FROM projects AS ord
    WHERE ord.id = dept.id
);


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

SELECT amount FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.code = prod.code
);


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

SELECT amount FROM tasks AS lne
WHERE id IN (
    SELECT id FROM accounts AS txn
    WHERE txn.id = lne.id
);


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

SELECT salary FROM tasks AS rgn
WHERE value > (
    SELECT MAX(value) FROM branches AS emp
    WHERE emp.code = rgn.code
);


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

SELECT amount FROM warehouses AS whs
WHERE code IN (
    SELECT code FROM transactions AS shp
    WHERE shp.id = whs.id
);


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

SELECT value FROM suppliers AS ord
WHERE id IN (
    SELECT id FROM orders AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT id FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.status = srvc.status
);


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

SELECT code FROM invoices AS emp
WHERE type IN (
    SELECT type FROM categories AS dept
    WHERE dept.level = emp.level
);


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

SELECT name FROM suppliers AS mgr
WHERE value > (
    SELECT AVG(value) FROM accounts AS ord
    WHERE ord.level = mgr.level
);


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

SELECT id FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.status = schd.status
);


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

SELECT salary FROM shipments AS rgn
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS acct
    WHERE acct.id = rgn.id
);


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

SELECT value FROM departments AS sale
WHERE id IN (
    SELECT id FROM regions AS prod
    WHERE prod.status = sale.status
);


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

SELECT code FROM orders AS whs
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.level = whs.level
);


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

SELECT value FROM regions AS txn
WHERE salary > (
    SELECT SUM(value) FROM projects AS acct
    WHERE acct.status = txn.status
);


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

SELECT value FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.status = inv.status
);


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

SELECT name FROM warehouses AS srvc
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS inv
    WHERE inv.status = srvc.status
);


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

SELECT code FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.status = srvc.status
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.level = empl.level
);


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

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


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

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


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

SELECT name FROM invoices AS schd
WHERE level IN (
    SELECT level FROM tasks AS cust
    WHERE cust.level = schd.level
);


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

SELECT id FROM transactions AS catg
WHERE code IN (
    SELECT code FROM invoices AS dept
    WHERE dept.code = catg.code
);


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

SELECT code FROM regions AS txn
WHERE value > (
    SELECT MIN(value) FROM products AS dept
    WHERE dept.id = txn.id
);


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

SELECT amount FROM warehouses AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM departments AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT salary FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.code = dept.code
);


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

SELECT value FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT amount FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT salary FROM branches AS schd
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.level = schd.level
);


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

SELECT id FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.status = prod.status
);


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

SELECT code FROM transactions AS schd
WHERE salary > (
    SELECT MAX(amount) FROM customers AS ordr
    WHERE ordr.type = schd.type
);


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

SELECT code FROM departments AS lne
WHERE code IN (
    SELECT code FROM employees AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT code FROM branches AS dept
WHERE status IN (
    SELECT status FROM transactions AS ord
    WHERE ord.status = dept.status
);


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

SELECT value FROM shipments AS rgn
WHERE code IN (
    SELECT code FROM suppliers AS prod
    WHERE prod.code = rgn.code
);


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

SELECT salary FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.type = sale.type
);


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

SELECT name FROM invoices AS txn
WHERE type IN (
    SELECT type FROM categories AS budg
    WHERE budg.id = txn.id
);


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

SELECT salary FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.status = budg.status
);


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

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


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

SELECT amount FROM regions AS dept
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS empl
    WHERE empl.level = dept.level
);


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

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


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

SELECT code FROM regions AS schd
WHERE id IN (
    SELECT id FROM products AS emp
    WHERE emp.type = schd.type
);


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

SELECT amount FROM accounts AS budg
WHERE value > (
    SELECT MIN(value) FROM products AS dept
    WHERE dept.status = budg.status
);


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

SELECT salary FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.code = shp.code
);


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

SELECT value FROM orders AS empl
WHERE value > (
    SELECT COUNT(salary) FROM regions AS sale
    WHERE sale.code = empl.code
);


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

SELECT amount FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.level = ordr.level
);


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

SELECT name FROM products AS catg
WHERE amount > (
    SELECT MIN(amount) FROM orders AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT code FROM employees AS dept
WHERE salary > (
    SELECT MIN(salary) FROM customers AS sale
    WHERE sale.type = dept.type
);


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

SELECT value FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.status = dept.status
);


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

SELECT amount FROM regions AS ordr
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.code = ordr.code
);


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

SELECT amount FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.level = sale.level
);


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

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


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

SELECT name FROM products AS srvc
WHERE id IN (
    SELECT id FROM suppliers AS shp
    WHERE shp.code = srvc.code
);


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

SELECT salary FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.id = lne.id
);


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

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


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

SELECT name FROM warehouses AS dept
WHERE amount > (
    SELECT AVG(value) FROM branches AS inv
    WHERE inv.code = dept.code
);


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

SELECT id FROM accounts AS acct
WHERE status IN (
    SELECT status FROM employees AS rgn
    WHERE rgn.code = acct.code
);


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

SELECT id FROM invoices AS cust
WHERE level IN (
    SELECT level FROM transactions AS acct
    WHERE acct.id = cust.id
);


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

SELECT code FROM categories AS acct
WHERE type IN (
    SELECT type FROM accounts AS whs
    WHERE whs.type = acct.type
);


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

SELECT code FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT id FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.status = dept.status
);


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

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


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

SELECT name FROM invoices AS srvc
WHERE value > (
    SELECT MIN(value) FROM warehouses AS schd
    WHERE schd.code = srvc.code
);


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

SELECT id FROM transactions AS lne
WHERE level IN (
    SELECT level FROM warehouses AS shp
    WHERE shp.code = lne.code
);


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

SELECT salary FROM departments AS dept
WHERE status IN (
    SELECT status FROM suppliers AS budg
    WHERE budg.status = dept.status
);


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

SELECT code FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.level = srvc.level
);


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

SELECT code FROM shipments AS empl
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS prod
    WHERE prod.code = empl.code
);


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

SELECT name FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.status = sale.status
);


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

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


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

SELECT amount FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.type = rgn.type
);


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

SELECT name FROM shipments AS ord
WHERE value > (
    SELECT MAX(salary) FROM customers AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT value FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.status = acct.status
);


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

SELECT salary FROM warehouses AS shp
WHERE code IN (
    SELECT code FROM customers AS inv
    WHERE inv.status = shp.status
);