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

SELECT name FROM regions AS srvc
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS shp
    WHERE shp.type = srvc.type
);


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

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


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

SELECT value FROM regions AS rgn
WHERE id IN (
    SELECT id FROM warehouses AS catg
    WHERE catg.code = rgn.code
);


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

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


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

SELECT code FROM orders AS dept
WHERE salary > (
    SELECT MIN(amount) FROM branches AS prod
    WHERE prod.type = dept.type
);


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

SELECT amount FROM transactions AS cust
WHERE level IN (
    SELECT level FROM departments AS shp
    WHERE shp.id = cust.id
);


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

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


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

SELECT amount FROM suppliers AS sale
WHERE code IN (
    SELECT code FROM customers AS catg
    WHERE catg.type = sale.type
);


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

SELECT code FROM employees AS srvc
WHERE id IN (
    SELECT id FROM branches AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT amount FROM projects AS acct
WHERE value > (
    SELECT MAX(amount) FROM employees AS whs
    WHERE whs.code = acct.code
);


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

SELECT amount FROM shipments AS schd
WHERE value > (
    SELECT SUM(value) FROM transactions AS shp
    WHERE shp.type = schd.type
);


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

SELECT name FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.code = mgr.code
);


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

SELECT code FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT id FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.type = sale.type
);


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

SELECT salary FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = catg.id
);


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

SELECT salary FROM orders AS cust
WHERE amount > (
    SELECT AVG(salary) FROM categories AS empl
    WHERE empl.status = cust.status
);


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

SELECT salary FROM projects AS acct
WHERE salary > (
    SELECT MIN(value) FROM employees AS whs
    WHERE whs.id = acct.id
);


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

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


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

SELECT id FROM customers AS catg
WHERE code IN (
    SELECT code FROM employees AS srvc
    WHERE srvc.level = catg.level
);


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

SELECT amount FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.status = schd.status
);


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

SELECT name FROM invoices AS lne
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.level = lne.level
);


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

SELECT name FROM branches AS emp
WHERE code IN (
    SELECT code FROM transactions AS ord
    WHERE ord.id = emp.id
);


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

SELECT amount FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.id = whs.id
);


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

SELECT id FROM orders AS catg
WHERE salary > (
    SELECT SUM(value) FROM shipments AS emp
    WHERE emp.code = catg.code
);


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

SELECT salary FROM suppliers AS empl
WHERE value > (
    SELECT MIN(value) FROM categories AS shp
    WHERE shp.type = empl.type
);


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

SELECT value FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT code FROM categories AS lne
WHERE value > (
    SELECT COUNT(value) FROM accounts AS empl
    WHERE empl.type = lne.type
);


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

SELECT amount FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.type = acct.type
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT salary FROM warehouses AS ordr
WHERE value > (
    SELECT MIN(salary) FROM departments AS txn
    WHERE txn.code = ordr.code
);


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

SELECT amount FROM invoices AS mgr
WHERE id IN (
    SELECT id FROM warehouses AS srvc
    WHERE srvc.status = mgr.status
);


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

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


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

SELECT amount FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.level = ordr.level
);


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

SELECT salary FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.type = sale.type
);


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

SELECT salary FROM accounts AS mgr
WHERE type IN (
    SELECT type FROM invoices AS catg
    WHERE catg.level = mgr.level
);


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

SELECT salary FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT id FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.type = schd.type
);


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

SELECT value FROM categories AS catg
WHERE type IN (
    SELECT type FROM orders AS sale
    WHERE sale.status = catg.status
);


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

SELECT value FROM projects AS acct
WHERE status IN (
    SELECT status FROM branches AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT code FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.id = dept.id
);


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

SELECT code FROM warehouses AS shp
WHERE amount > (
    SELECT AVG(amount) FROM accounts AS lne
    WHERE lne.type = shp.type
);


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

SELECT amount FROM transactions AS lne
WHERE amount > (
    SELECT MIN(value) FROM branches AS budg
    WHERE budg.type = lne.type
);


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

SELECT id FROM invoices AS empl
WHERE type IN (
    SELECT type FROM products AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT value FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT amount FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.type = lne.type
);


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

SELECT id FROM categories AS whs
WHERE value > (
    SELECT COUNT(amount) FROM branches AS cust
    WHERE cust.type = whs.type
);


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

SELECT salary FROM regions AS mgr
WHERE type IN (
    SELECT type FROM transactions AS dept
    WHERE dept.type = mgr.type
);


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

SELECT salary FROM branches AS ordr
WHERE code IN (
    SELECT code FROM accounts AS rgn
    WHERE rgn.level = ordr.level
);


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

SELECT salary FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT name FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.code = emp.code
);


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

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


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

SELECT code FROM transactions AS dept
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS shp
    WHERE shp.level = dept.level
);


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

SELECT amount FROM categories AS budg
WHERE value > (
    SELECT MAX(value) FROM warehouses AS shp
    WHERE shp.status = budg.status
);


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

SELECT name FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.type = inv.type
);


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

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


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

SELECT code FROM accounts AS budg
WHERE status IN (
    SELECT status FROM projects AS lne
    WHERE lne.id = budg.id
);


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

SELECT id FROM tasks AS empl
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS txn
    WHERE txn.code = empl.code
);


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

SELECT code FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.level = ordr.level
);


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

SELECT salary FROM employees AS acct
WHERE level IN (
    SELECT level FROM transactions AS dept
    WHERE dept.code = acct.code
);


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

SELECT id FROM orders AS sale
WHERE type IN (
    SELECT type FROM categories AS emp
    WHERE emp.level = sale.level
);


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

SELECT code FROM shipments AS rgn
WHERE status IN (
    SELECT status FROM branches AS ord
    WHERE ord.id = rgn.id
);


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

SELECT value FROM projects AS cust
WHERE type IN (
    SELECT type FROM accounts AS empl
    WHERE empl.level = cust.level
);


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

SELECT salary FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = ordr.status
);


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

SELECT id FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.type = schd.type
);


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

SELECT name FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = whs.status
);


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

SELECT code FROM regions AS srvc
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS whs
    WHERE whs.id = srvc.id
);


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

SELECT name FROM departments AS lne
WHERE id IN (
    SELECT id FROM orders AS txn
    WHERE txn.code = lne.code
);


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

SELECT amount FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.status = shp.status
);


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

SELECT name FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.type = srvc.type
);


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

SELECT name FROM departments AS schd
WHERE level IN (
    SELECT level FROM products AS ord
    WHERE ord.code = schd.code
);


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

SELECT code FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.type = ordr.type
);


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

SELECT value FROM projects AS sale
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS emp
    WHERE emp.status = sale.status
);


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

SELECT code FROM shipments AS dept
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS rgn
    WHERE rgn.id = dept.id
);


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

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


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

SELECT amount FROM invoices AS inv
WHERE status IN (
    SELECT status FROM customers AS whs
    WHERE whs.type = inv.type
);


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

SELECT id FROM products AS inv
WHERE salary > (
    SELECT SUM(value) FROM employees AS emp
    WHERE emp.id = inv.id
);


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

SELECT id FROM warehouses AS budg
WHERE value > (
    SELECT MIN(salary) FROM tasks AS acct
    WHERE acct.code = budg.code
);


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

SELECT salary FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT amount FROM accounts AS empl
WHERE status IN (
    SELECT status FROM products AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT salary FROM orders AS schd
WHERE amount > (
    SELECT MIN(value) FROM categories AS srvc
    WHERE srvc.level = schd.level
);


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

SELECT code FROM departments AS catg
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS budg
    WHERE budg.type = catg.type
);


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

SELECT amount FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.status = txn.status
);


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

SELECT salary FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT salary FROM shipments AS catg
WHERE amount > (
    SELECT SUM(amount) FROM categories AS sale
    WHERE sale.code = catg.code
);


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

SELECT id FROM employees AS sale
WHERE amount > (
    SELECT COUNT(value) FROM branches AS inv
    WHERE inv.type = sale.type
);


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

SELECT value FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT salary FROM warehouses AS ordr
WHERE id IN (
    SELECT id FROM transactions AS schd
    WHERE schd.id = ordr.id
);


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

SELECT name FROM projects AS prod
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS schd
    WHERE schd.code = prod.code
);


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

SELECT code FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.level = schd.level
);


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

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


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

SELECT value FROM departments AS srvc
WHERE status IN (
    SELECT status FROM accounts AS ordr
    WHERE ordr.type = srvc.type
);


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

SELECT code FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.type = empl.type
);


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

SELECT id FROM categories AS mgr
WHERE type IN (
    SELECT type FROM suppliers AS emp
    WHERE emp.code = mgr.code
);


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

SELECT code FROM departments AS dept
WHERE salary > (
    SELECT MIN(amount) FROM products AS txn
    WHERE txn.type = dept.type
);


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

SELECT amount FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.code = ord.code
);


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

SELECT salary FROM tasks AS schd
WHERE code IN (
    SELECT code FROM orders AS sale
    WHERE sale.code = schd.code
);


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

SELECT salary FROM tasks AS sale
WHERE type IN (
    SELECT type FROM branches AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT name FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.type = lne.type
);


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

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


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

SELECT id FROM accounts AS emp
WHERE level IN (
    SELECT level FROM employees AS prod
    WHERE prod.id = emp.id
);


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

SELECT amount FROM employees AS cust
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.status = cust.status
);


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

SELECT salary FROM suppliers AS schd
WHERE salary > (
    SELECT MAX(salary) FROM products AS acct
    WHERE acct.status = schd.status
);


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

SELECT value FROM customers AS cust
WHERE level IN (
    SELECT level FROM employees AS dept
    WHERE dept.level = cust.level
);


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

SELECT code FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.code = mgr.code
);


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

SELECT id FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.type = empl.type
);


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

SELECT id FROM categories AS srvc
WHERE salary > (
    SELECT SUM(value) FROM transactions AS lne
    WHERE lne.status = srvc.status
);


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

SELECT name FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.type = sale.type
);


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

SELECT id FROM shipments AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS budg
    WHERE budg.level = rgn.level
);


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

SELECT value FROM warehouses AS srvc
WHERE code IN (
    SELECT code FROM categories AS prod
    WHERE prod.status = srvc.status
);


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

SELECT amount FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT amount FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.code = txn.code
);


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

SELECT amount FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT value FROM products AS emp
WHERE code IN (
    SELECT code FROM tasks AS dept
    WHERE dept.type = emp.type
);


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

SELECT salary FROM customers AS whs
WHERE amount > (
    SELECT MAX(salary) FROM departments AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT code FROM orders AS inv
WHERE salary > (
    SELECT SUM(salary) FROM departments AS lne
    WHERE lne.level = inv.level
);


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

SELECT id FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.type = emp.type
);


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

SELECT value FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.level = lne.level
);


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

SELECT salary FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.id = lne.id
);


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

SELECT amount FROM departments AS shp
WHERE id IN (
    SELECT id FROM categories AS empl
    WHERE empl.status = shp.status
);


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

SELECT amount FROM transactions AS catg
WHERE status IN (
    SELECT status FROM branches AS prod
    WHERE prod.status = catg.status
);


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

SELECT salary FROM warehouses AS dept
WHERE value > (
    SELECT AVG(salary) FROM projects AS emp
    WHERE emp.code = dept.code
);


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

SELECT amount FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.code = ordr.code
);


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

SELECT id FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.level = shp.level
);


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

SELECT salary FROM regions AS lne
WHERE code IN (
    SELECT code FROM branches AS whs
    WHERE whs.id = lne.id
);


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

SELECT id FROM employees AS shp
WHERE type IN (
    SELECT type FROM departments AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT name FROM accounts AS ord
WHERE salary > (
    SELECT MIN(value) FROM branches AS whs
    WHERE whs.status = ord.status
);


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

SELECT code FROM orders AS ordr
WHERE id IN (
    SELECT id FROM customers AS prod
    WHERE prod.level = ordr.level
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = rgn.id
);


Prompt:
Schema:
  employees (alias: acct)(amount, date, salary, code)
  suppliers(amount, type, value, name)
Task: Retrieve name from employees with value above the MAX(value) of suppliers rows sharing the same type.
SQL:

SELECT name FROM employees AS acct
WHERE value > (
    SELECT MAX(value) FROM suppliers AS lne
    WHERE lne.type = acct.type
);


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

SELECT amount FROM customers AS ord
WHERE type IN (
    SELECT type FROM employees AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT salary FROM accounts AS ordr
WHERE status IN (
    SELECT status FROM regions AS inv
    WHERE inv.id = ordr.id
);


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

SELECT code FROM customers AS acct
WHERE amount > (
    SELECT AVG(value) FROM accounts AS inv
    WHERE inv.id = acct.id
);


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

SELECT name FROM regions AS budg
WHERE status IN (
    SELECT status FROM departments AS inv
    WHERE inv.level = budg.level
);


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = empl.type
);


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

SELECT value FROM shipments AS sale
WHERE salary > (
    SELECT MIN(salary) FROM orders AS whs
    WHERE whs.level = sale.level
);


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

SELECT salary FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.id = dept.id
);


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

SELECT code FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.status = ord.status
);


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

SELECT amount FROM transactions AS empl
WHERE salary > (
    SELECT MAX(value) FROM shipments AS sale
    WHERE sale.id = empl.id
);


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

SELECT id FROM accounts AS shp
WHERE id IN (
    SELECT id FROM shipments AS emp
    WHERE emp.status = shp.status
);


Prompt:
Schema:
  tasks (alias: rgn)(name, amount, code, date)
  customers(status, name, type, date)
Task: Retrieve salary from tasks with salary above the AVG(salary) of customers rows sharing the same status.
SQL:

SELECT salary FROM tasks AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM customers AS inv
    WHERE inv.status = rgn.status
);


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

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


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

SELECT value FROM orders AS empl
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS txn
    WHERE txn.status = empl.status
);


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

SELECT amount FROM employees AS whs
WHERE type IN (
    SELECT type FROM warehouses AS acct
    WHERE acct.type = whs.type
);


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

SELECT amount FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.level = rgn.level
);


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

SELECT code FROM orders AS catg
WHERE code IN (
    SELECT code FROM transactions AS lne
    WHERE lne.type = catg.type
);


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

SELECT name FROM invoices AS prod
WHERE type IN (
    SELECT type FROM suppliers AS acct
    WHERE acct.type = prod.type
);


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

SELECT amount FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.level = budg.level
);


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

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


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

SELECT name FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.type = schd.type
);


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

SELECT code FROM branches AS shp
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS lne
    WHERE lne.type = shp.type
);


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

SELECT code FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT name FROM invoices AS rgn
WHERE value > (
    SELECT SUM(value) FROM accounts AS emp
    WHERE emp.type = rgn.type
);


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

SELECT salary FROM warehouses AS sale
WHERE amount > (
    SELECT MAX(value) FROM invoices AS emp
    WHERE emp.level = sale.level
);


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

SELECT value FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = rgn.type
);


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

SELECT code FROM departments AS shp
WHERE level IN (
    SELECT level FROM warehouses AS schd
    WHERE schd.type = shp.type
);


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

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


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

SELECT amount FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.type = dept.type
);


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

SELECT value FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.code = acct.code
);


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

SELECT amount FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.id = prod.id
);


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

SELECT salary FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.type = srvc.type
);


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

SELECT id FROM customers AS rgn
WHERE amount > (
    SELECT MIN(value) FROM warehouses AS mgr
    WHERE mgr.status = rgn.status
);


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

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


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT code FROM tasks AS rgn
WHERE status IN (
    SELECT status FROM departments AS lne
    WHERE lne.type = rgn.type
);


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

SELECT amount FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT salary FROM invoices AS emp
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.level = emp.level
);


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

SELECT code FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.level = cust.level
);


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

SELECT salary FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.level = rgn.level
);


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

SELECT id FROM orders AS prod
WHERE value > (
    SELECT AVG(amount) FROM tasks AS cust
    WHERE cust.status = prod.status
);


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

SELECT value FROM employees AS ordr
WHERE status IN (
    SELECT status FROM shipments AS catg
    WHERE catg.status = ordr.status
);


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

SELECT salary FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.id = srvc.id
);


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

SELECT salary FROM suppliers AS txn
WHERE value > (
    SELECT AVG(value) FROM employees AS schd
    WHERE schd.status = txn.status
);


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

SELECT value FROM projects AS catg
WHERE id IN (
    SELECT id FROM regions AS rgn
    WHERE rgn.status = catg.status
);


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

SELECT salary FROM orders AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM suppliers AS inv
    WHERE inv.level = ordr.level
);


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

SELECT id FROM transactions AS acct
WHERE code IN (
    SELECT code FROM departments AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT name FROM shipments AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM customers AS schd
    WHERE schd.type = ordr.type
);


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

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


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

SELECT name FROM departments AS prod
WHERE type IN (
    SELECT type FROM shipments AS dept
    WHERE dept.id = prod.id
);


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

SELECT amount FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.level = ord.level
);


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

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


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

SELECT value FROM employees AS dept
WHERE level IN (
    SELECT level FROM categories AS shp
    WHERE shp.id = dept.id
);


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

SELECT name FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.level = empl.level
);


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

SELECT id FROM projects AS inv
WHERE code IN (
    SELECT code FROM employees AS catg
    WHERE catg.status = inv.status
);


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

SELECT name FROM regions AS acct
WHERE value > (
    SELECT MAX(salary) FROM categories AS shp
    WHERE shp.id = acct.id
);


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

SELECT code FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.id = inv.id
);


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

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


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

SELECT salary FROM departments AS budg
WHERE level IN (
    SELECT level FROM invoices AS schd
    WHERE schd.type = budg.type
);


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

SELECT amount FROM suppliers AS ordr
WHERE value > (
    SELECT MIN(salary) FROM shipments AS sale
    WHERE sale.level = ordr.level
);


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

SELECT salary FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = schd.level
);


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

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


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

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


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

SELECT code FROM accounts AS sale
WHERE level IN (
    SELECT level FROM products AS budg
    WHERE budg.level = sale.level
);


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

SELECT salary FROM regions AS srvc
WHERE type IN (
    SELECT type FROM customers AS lne
    WHERE lne.id = srvc.id
);


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

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


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

SELECT id FROM accounts AS empl
WHERE level IN (
    SELECT level FROM shipments AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = ord.level
);


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

SELECT id FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.code = txn.code
);


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

SELECT amount FROM departments AS ord
WHERE type IN (
    SELECT type FROM accounts AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT amount FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.status = budg.status
);


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

SELECT salary FROM customers AS emp
WHERE value > (
    SELECT SUM(value) FROM departments AS txn
    WHERE txn.type = emp.type
);


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

SELECT code FROM products AS whs
WHERE status IN (
    SELECT status FROM accounts AS empl
    WHERE empl.code = whs.code
);


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

SELECT id FROM suppliers AS ordr
WHERE value > (
    SELECT SUM(salary) FROM transactions AS schd
    WHERE schd.type = ordr.type
);


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

SELECT salary FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.level = catg.level
);


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

SELECT value FROM employees AS whs
WHERE id IN (
    SELECT id FROM projects AS txn
    WHERE txn.id = whs.id
);


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

SELECT amount FROM regions AS sale
WHERE level IN (
    SELECT level FROM invoices AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.status = cust.status
);


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

SELECT amount FROM warehouses AS catg
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT code FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.status = empl.status
);


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

SELECT name FROM categories AS catg
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.status = catg.status
);


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

SELECT name FROM regions AS rgn
WHERE salary > (
    SELECT COUNT(value) FROM transactions AS whs
    WHERE whs.status = rgn.status
);


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

SELECT name FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.level = ord.level
);


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

SELECT salary FROM invoices AS budg
WHERE level IN (
    SELECT level FROM regions AS whs
    WHERE whs.type = budg.type
);


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

SELECT code FROM departments AS shp
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.code = shp.code
);


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

SELECT salary FROM departments AS whs
WHERE id IN (
    SELECT id FROM branches AS acct
    WHERE acct.level = whs.level
);


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

SELECT name FROM departments AS prod
WHERE type IN (
    SELECT type FROM suppliers AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT name FROM warehouses AS empl
WHERE salary > (
    SELECT AVG(amount) FROM invoices AS ord
    WHERE ord.type = empl.type
);


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

SELECT id FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.code = lne.code
);


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

SELECT code FROM invoices AS prod
WHERE status IN (
    SELECT status FROM regions AS txn
    WHERE txn.level = prod.level
);


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

SELECT salary FROM shipments AS ord
WHERE status IN (
    SELECT status FROM branches AS dept
    WHERE dept.id = ord.id
);


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

SELECT amount FROM warehouses AS prod
WHERE value > (
    SELECT AVG(value) FROM projects AS txn
    WHERE txn.type = prod.type
);


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

SELECT id FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.level = lne.level
);


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

SELECT code FROM orders AS whs
WHERE salary > (
    SELECT MIN(value) FROM projects AS txn
    WHERE txn.id = whs.id
);


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

SELECT amount FROM shipments AS catg
WHERE amount > (
    SELECT MAX(value) FROM invoices AS shp
    WHERE shp.code = catg.code
);


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

SELECT name FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.code = budg.code
);


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

SELECT amount FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.id = budg.id
);


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

SELECT value FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.code = catg.code
);


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

SELECT value FROM projects AS sale
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.type = sale.type
);


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

SELECT value FROM transactions AS inv
WHERE level IN (
    SELECT level FROM categories AS prod
    WHERE prod.status = inv.status
);


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

SELECT salary FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = budg.type
);


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

SELECT salary FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.code = budg.code
);


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

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


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

SELECT name FROM customers AS inv
WHERE status IN (
    SELECT status FROM projects AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT value FROM tasks AS ordr
WHERE status IN (
    SELECT status FROM shipments AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT value FROM shipments AS cust
WHERE salary > (
    SELECT MAX(value) FROM regions AS emp
    WHERE emp.id = cust.id
);


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

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


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

SELECT salary FROM shipments AS whs
WHERE type IN (
    SELECT type FROM orders AS mgr
    WHERE mgr.status = whs.status
);


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

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


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

SELECT amount FROM categories AS shp
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS dept
    WHERE dept.status = shp.status
);


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

SELECT amount FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT value FROM tasks AS catg
WHERE amount > (
    SELECT AVG(value) FROM shipments AS inv
    WHERE inv.type = catg.type
);


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

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


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

SELECT code FROM employees AS sale
WHERE amount > (
    SELECT MIN(amount) FROM warehouses AS empl
    WHERE empl.id = sale.id
);


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

SELECT code FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.id = srvc.id
);


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

SELECT code FROM regions AS catg
WHERE value > (
    SELECT MAX(value) FROM transactions AS lne
    WHERE lne.type = catg.type
);


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

SELECT name FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.level = sale.level
);


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

SELECT id FROM projects AS schd
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS prod
    WHERE prod.code = schd.code
);


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

SELECT salary FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.id = budg.id
);


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

SELECT value FROM warehouses AS cust
WHERE type IN (
    SELECT type FROM tasks AS ord
    WHERE ord.code = cust.code
);


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

SELECT id FROM departments AS emp
WHERE value > (
    SELECT SUM(value) FROM products AS schd
    WHERE schd.level = emp.level
);


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

SELECT id FROM projects AS catg
WHERE id IN (
    SELECT id FROM tasks AS txn
    WHERE txn.code = catg.code
);


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

SELECT salary FROM shipments AS empl
WHERE level IN (
    SELECT level FROM transactions AS dept
    WHERE dept.id = empl.id
);


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

SELECT salary FROM shipments AS sale
WHERE id IN (
    SELECT id FROM employees AS catg
    WHERE catg.id = sale.id
);


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

SELECT amount FROM transactions AS inv
WHERE value > (
    SELECT AVG(amount) FROM categories AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT amount FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.code = srvc.code
);


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

SELECT id FROM categories AS emp
WHERE level IN (
    SELECT level FROM transactions AS lne
    WHERE lne.id = emp.id
);


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

SELECT value FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.status = schd.status
);


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

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


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

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


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

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


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

SELECT name FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT name FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = prod.id
);


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

SELECT value FROM employees AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM orders AS ord
    WHERE ord.type = rgn.type
);


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

SELECT value FROM customers AS srvc
WHERE code IN (
    SELECT code FROM transactions AS lne
    WHERE lne.status = srvc.status
);


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

SELECT amount FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.id = lne.id
);


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

SELECT amount FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.code = catg.code
);


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

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


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

SELECT code FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.level = budg.level
);


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

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


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

SELECT amount FROM branches AS srvc
WHERE type IN (
    SELECT type FROM orders AS acct
    WHERE acct.status = srvc.status
);


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

SELECT id FROM products AS inv
WHERE value > (
    SELECT AVG(salary) FROM orders AS acct
    WHERE acct.code = inv.code
);


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

SELECT salary FROM branches AS ord
WHERE amount > (
    SELECT MIN(salary) FROM projects AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT amount FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.code = empl.code
);


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

SELECT value FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT name FROM suppliers AS inv
WHERE amount > (
    SELECT AVG(amount) FROM accounts AS txn
    WHERE txn.status = inv.status
);


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.type = whs.type
);


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

SELECT id FROM invoices AS srvc
WHERE amount > (
    SELECT MIN(amount) FROM categories AS empl
    WHERE empl.level = srvc.level
);


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

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


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

SELECT salary FROM departments AS inv
WHERE type IN (
    SELECT type FROM orders AS budg
    WHERE budg.code = inv.code
);


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

SELECT id FROM orders AS whs
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.code = whs.code
);


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

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


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

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


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = dept.level
);


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

SELECT name FROM warehouses AS catg
WHERE salary > (
    SELECT AVG(value) FROM projects AS dept
    WHERE dept.level = catg.level
);


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

SELECT amount FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.status = shp.status
);


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

SELECT name FROM projects AS acct
WHERE code IN (
    SELECT code FROM departments AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT amount FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.type = whs.type
);


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

SELECT salary FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.id = inv.id
);


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

SELECT amount FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.id = budg.id
);


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

SELECT amount FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.status = budg.status
);


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

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


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

SELECT name FROM departments AS shp
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.code = shp.code
);


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

SELECT code FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT code FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.status = inv.status
);