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

SELECT id FROM shipments AS acct
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS budg
    WHERE budg.type = acct.type
);


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

SELECT name FROM orders AS dept
WHERE code IN (
    SELECT code FROM tasks AS schd
    WHERE schd.status = dept.status
);


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

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


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

SELECT id FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.type = lne.type
);


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

SELECT value FROM warehouses AS schd
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.type = schd.type
);


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

SELECT amount FROM products AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM transactions AS acct
    WHERE acct.type = whs.type
);


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

SELECT name FROM warehouses AS catg
WHERE id IN (
    SELECT id FROM employees AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT amount FROM shipments AS shp
WHERE id IN (
    SELECT id FROM warehouses AS rgn
    WHERE rgn.type = shp.type
);


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

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


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

SELECT name FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.id = inv.id
);


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

SELECT amount FROM projects AS empl
WHERE value > (
    SELECT SUM(amount) FROM regions AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT id FROM projects AS cust
WHERE amount > (
    SELECT SUM(value) FROM departments AS acct
    WHERE acct.id = cust.id
);


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

SELECT value FROM departments AS whs
WHERE status IN (
    SELECT status FROM branches AS dept
    WHERE dept.status = whs.status
);


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

SELECT id FROM branches AS catg
WHERE value > (
    SELECT SUM(value) FROM shipments AS sale
    WHERE sale.status = catg.status
);


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

SELECT value FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.id = budg.id
);


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

SELECT salary FROM invoices AS emp
WHERE value > (
    SELECT AVG(amount) FROM categories AS prod
    WHERE prod.level = emp.level
);


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

SELECT code FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = emp.level
);


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

SELECT salary FROM projects AS schd
WHERE level IN (
    SELECT level FROM accounts AS lne
    WHERE lne.level = schd.level
);


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

SELECT id FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.level = shp.level
);


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

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


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

SELECT amount FROM transactions AS acct
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS shp
    WHERE shp.code = acct.code
);


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

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


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

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


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

SELECT amount FROM tasks AS txn
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS whs
    WHERE whs.status = txn.status
);


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

SELECT value FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.code = catg.code
);


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

SELECT salary FROM warehouses AS empl
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS schd
    WHERE schd.type = empl.type
);


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

SELECT id FROM regions AS schd
WHERE salary > (
    SELECT MAX(value) FROM suppliers AS sale
    WHERE sale.status = schd.status
);


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

SELECT value FROM accounts AS whs
WHERE type IN (
    SELECT type FROM products AS acct
    WHERE acct.level = whs.level
);


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

SELECT id FROM employees AS ordr
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT name FROM suppliers AS cust
WHERE salary > (
    SELECT SUM(value) FROM shipments AS txn
    WHERE txn.level = cust.level
);


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

SELECT name FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.code = mgr.code
);


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

SELECT value FROM suppliers AS emp
WHERE status IN (
    SELECT status FROM branches AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT code FROM suppliers AS dept
WHERE level IN (
    SELECT level FROM accounts AS whs
    WHERE whs.id = dept.id
);


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

SELECT amount FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.status = emp.status
);


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

SELECT code FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.level = whs.level
);


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

SELECT value FROM employees AS rgn
WHERE type IN (
    SELECT type FROM warehouses AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT code FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.level = budg.level
);


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

SELECT id FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.type = rgn.type
);


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

SELECT name FROM categories AS ord
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.status = ord.status
);


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

SELECT id FROM shipments AS rgn
WHERE level IN (
    SELECT level FROM departments AS inv
    WHERE inv.code = rgn.code
);


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

SELECT salary FROM employees AS dept
WHERE salary > (
    SELECT MAX(salary) FROM projects AS catg
    WHERE catg.type = dept.type
);


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

SELECT id FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.id = ordr.id
);


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

SELECT name FROM products AS ordr
WHERE code IN (
    SELECT code FROM transactions AS dept
    WHERE dept.status = ordr.status
);


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

SELECT code FROM shipments AS emp
WHERE amount > (
    SELECT AVG(amount) FROM orders AS catg
    WHERE catg.code = emp.code
);


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

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


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

SELECT id FROM transactions AS cust
WHERE value > (
    SELECT SUM(amount) FROM invoices AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT value FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.type = acct.type
);


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

SELECT code FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.code = prod.code
);


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

SELECT salary FROM products AS sale
WHERE amount > (
    SELECT AVG(salary) FROM projects AS ord
    WHERE ord.level = sale.level
);


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

SELECT code FROM regions AS budg
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS prod
    WHERE prod.code = budg.code
);


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

SELECT id FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.code = srvc.code
);


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

SELECT name FROM employees AS prod
WHERE value > (
    SELECT SUM(value) FROM invoices AS lne
    WHERE lne.code = prod.code
);


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

SELECT value FROM warehouses AS sale
WHERE salary > (
    SELECT MAX(salary) FROM products AS ordr
    WHERE ordr.level = sale.level
);


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

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


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

SELECT value FROM invoices AS shp
WHERE amount > (
    SELECT SUM(amount) FROM transactions AS whs
    WHERE whs.status = shp.status
);


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

SELECT code FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.code = ordr.code
);


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

SELECT salary FROM regions AS empl
WHERE salary > (
    SELECT AVG(value) FROM tasks AS cust
    WHERE cust.type = empl.type
);


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

SELECT amount FROM projects AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM invoices AS catg
    WHERE catg.type = rgn.type
);


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

SELECT id FROM departments AS catg
WHERE value > (
    SELECT COUNT(salary) FROM categories AS empl
    WHERE empl.type = catg.type
);


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

SELECT id FROM transactions AS prod
WHERE salary > (
    SELECT SUM(salary) FROM departments AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT value FROM products AS shp
WHERE value > (
    SELECT COUNT(value) FROM orders AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT amount FROM customers AS inv
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS lne
    WHERE lne.status = inv.status
);


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

SELECT name FROM transactions AS sale
WHERE amount > (
    SELECT MAX(amount) FROM categories AS inv
    WHERE inv.code = sale.code
);


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

SELECT id FROM invoices AS sale
WHERE type IN (
    SELECT type FROM branches AS ord
    WHERE ord.level = sale.level
);


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

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


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

SELECT name FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.code = lne.code
);


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

SELECT amount FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.id = rgn.id
);


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

SELECT salary FROM departments AS emp
WHERE id IN (
    SELECT id FROM transactions AS catg
    WHERE catg.code = emp.code
);


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

SELECT salary FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT amount FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.code = emp.code
);


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

SELECT salary FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.level = schd.level
);


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

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


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

SELECT amount FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.type = ord.type
);


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

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


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

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


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

SELECT name FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM orders AS dept
    WHERE dept.id = ordr.id
);


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

SELECT code FROM invoices AS acct
WHERE status IN (
    SELECT status FROM customers AS mgr
    WHERE mgr.code = acct.code
);


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

SELECT code FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.type = inv.type
);


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

SELECT salary FROM tasks AS txn
WHERE status IN (
    SELECT status FROM categories AS shp
    WHERE shp.level = txn.level
);


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

SELECT salary FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.id = prod.id
);


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

SELECT name FROM accounts AS prod
WHERE type IN (
    SELECT type FROM regions AS schd
    WHERE schd.status = prod.status
);


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

SELECT code FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.level = empl.level
);


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

SELECT name FROM shipments AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS sale
    WHERE sale.type = ord.type
);


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

SELECT value FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT code FROM branches AS dept
WHERE amount > (
    SELECT COUNT(value) FROM orders AS ord
    WHERE ord.code = dept.code
);


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

SELECT name FROM accounts AS emp
WHERE value > (
    SELECT AVG(value) FROM suppliers AS shp
    WHERE shp.id = emp.id
);


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

SELECT id FROM branches AS prod
WHERE id IN (
    SELECT id FROM orders AS lne
    WHERE lne.level = prod.level
);


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

SELECT value FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.level = prod.level
);


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

SELECT code FROM transactions AS whs
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS empl
    WHERE empl.id = whs.id
);


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

SELECT name FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = shp.type
);


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

SELECT amount FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.type = shp.type
);


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

SELECT value FROM projects AS catg
WHERE value > (
    SELECT AVG(amount) FROM categories AS inv
    WHERE inv.status = catg.status
);


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

SELECT name FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.id = txn.id
);


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

SELECT id FROM regions AS sale
WHERE type IN (
    SELECT type FROM transactions AS prod
    WHERE prod.level = sale.level
);


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

SELECT salary FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.code = acct.code
);


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

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


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

SELECT amount FROM projects AS prod
WHERE salary > (
    SELECT MAX(amount) FROM suppliers AS empl
    WHERE empl.type = prod.type
);


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

SELECT value FROM orders AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM categories AS dept
    WHERE dept.type = rgn.type
);


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

SELECT value FROM accounts AS dept
WHERE level IN (
    SELECT level FROM products AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT name FROM tasks AS schd
WHERE amount > (
    SELECT SUM(value) FROM accounts AS txn
    WHERE txn.id = schd.id
);


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

SELECT value FROM categories AS emp
WHERE salary > (
    SELECT MIN(value) FROM departments AS catg
    WHERE catg.status = emp.status
);


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

SELECT salary FROM departments AS empl
WHERE value > (
    SELECT MAX(amount) FROM products AS srvc
    WHERE srvc.level = empl.level
);


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

SELECT amount FROM projects AS lne
WHERE value > (
    SELECT MIN(value) FROM orders AS whs
    WHERE whs.status = lne.status
);


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

SELECT salary FROM warehouses AS schd
WHERE salary > (
    SELECT MAX(value) FROM shipments AS ord
    WHERE ord.level = schd.level
);


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

SELECT amount FROM accounts AS mgr
WHERE code IN (
    SELECT code FROM invoices AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT code FROM orders AS dept
WHERE value > (
    SELECT AVG(value) FROM tasks AS empl
    WHERE empl.type = dept.type
);


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

SELECT id FROM orders AS ord
WHERE amount > (
    SELECT AVG(salary) FROM transactions AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT code FROM employees AS schd
WHERE level IN (
    SELECT level FROM products AS catg
    WHERE catg.level = schd.level
);


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

SELECT id FROM customers AS lne
WHERE amount > (
    SELECT MIN(value) FROM transactions AS cust
    WHERE cust.status = lne.status
);


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

SELECT salary FROM employees AS prod
WHERE value > (
    SELECT MAX(salary) FROM invoices AS whs
    WHERE whs.code = prod.code
);


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

SELECT code FROM projects AS catg
WHERE value > (
    SELECT COUNT(salary) FROM employees AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT name FROM departments AS ord
WHERE salary > (
    SELECT MIN(value) FROM transactions AS sale
    WHERE sale.level = ord.level
);


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

SELECT salary FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.id = cust.id
);


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

SELECT name FROM accounts AS catg
WHERE salary > (
    SELECT MIN(amount) FROM branches AS inv
    WHERE inv.code = catg.code
);


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

SELECT id FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.code = ord.code
);


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

SELECT salary FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT salary FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = budg.type
);


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

SELECT id FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.status = ordr.status
);


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

SELECT salary FROM employees AS srvc
WHERE salary > (
    SELECT AVG(amount) FROM customers AS catg
    WHERE catg.id = srvc.id
);


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

SELECT name FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.status = ord.status
);


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

SELECT amount FROM regions AS inv
WHERE salary > (
    SELECT COUNT(value) FROM shipments AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT salary FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT amount FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.type = empl.type
);


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

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


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

SELECT amount FROM orders AS txn
WHERE salary > (
    SELECT MIN(value) FROM branches AS ordr
    WHERE ordr.code = txn.code
);


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

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


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

SELECT salary FROM categories AS rgn
WHERE amount > (
    SELECT MIN(value) FROM tasks AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT amount FROM tasks AS ord
WHERE value > (
    SELECT AVG(value) FROM customers AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT amount FROM accounts AS acct
WHERE type IN (
    SELECT type FROM tasks AS cust
    WHERE cust.level = acct.level
);


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

SELECT amount FROM warehouses AS cust
WHERE amount > (
    SELECT COUNT(salary) FROM tasks AS sale
    WHERE sale.code = cust.code
);


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

SELECT amount FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.status = srvc.status
);


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

SELECT code FROM warehouses AS mgr
WHERE level IN (
    SELECT level FROM transactions AS schd
    WHERE schd.id = mgr.id
);


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

SELECT amount FROM branches AS catg
WHERE code IN (
    SELECT code FROM shipments AS prod
    WHERE prod.code = catg.code
);


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

SELECT name FROM products AS ordr
WHERE code IN (
    SELECT code FROM accounts AS prod
    WHERE prod.code = ordr.code
);


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

SELECT amount FROM categories AS rgn
WHERE salary > (
    SELECT MAX(amount) FROM regions AS empl
    WHERE empl.id = rgn.id
);


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

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


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

SELECT name FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.id = prod.id
);


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

SELECT id FROM branches AS prod
WHERE level IN (
    SELECT level FROM warehouses AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT salary FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.type = acct.type
);


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

SELECT value FROM customers AS emp
WHERE id IN (
    SELECT id FROM departments AS schd
    WHERE schd.id = emp.id
);


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

SELECT amount FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = dept.id
);


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

SELECT value FROM branches AS cust
WHERE value > (
    SELECT MAX(amount) FROM departments AS lne
    WHERE lne.id = cust.id
);


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

SELECT name FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.status = srvc.status
);


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

SELECT code FROM regions AS empl
WHERE value > (
    SELECT COUNT(salary) FROM branches AS srvc
    WHERE srvc.level = empl.level
);


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

SELECT salary FROM regions AS budg
WHERE type IN (
    SELECT type FROM products AS emp
    WHERE emp.type = budg.type
);


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

SELECT salary FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.type = whs.type
);


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

SELECT id FROM tasks AS rgn
WHERE id IN (
    SELECT id FROM customers AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT id FROM branches AS lne
WHERE amount > (
    SELECT AVG(amount) FROM departments AS inv
    WHERE inv.code = lne.code
);


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

SELECT salary FROM projects AS whs
WHERE status IN (
    SELECT status FROM customers AS ordr
    WHERE ordr.type = whs.type
);


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

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


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

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


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

SELECT value FROM regions AS srvc
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS empl
    WHERE empl.status = srvc.status
);


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

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


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

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


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

SELECT amount FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.code = whs.code
);


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

SELECT salary FROM products AS schd
WHERE amount > (
    SELECT SUM(salary) FROM departments AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT MIN(amount) FROM orders AS txn
    WHERE txn.level = dept.level
);


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

SELECT name FROM orders AS catg
WHERE value > (
    SELECT MAX(amount) FROM departments AS empl
    WHERE empl.level = catg.level
);


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

SELECT salary FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.type = lne.type
);


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

SELECT amount FROM invoices AS emp
WHERE salary > (
    SELECT MIN(value) FROM transactions AS sale
    WHERE sale.code = emp.code
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.status = dept.status
);


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

SELECT salary FROM warehouses AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS schd
    WHERE schd.status = txn.status
);


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

SELECT code FROM regions AS ord
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.status = ord.status
);


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

SELECT value FROM employees AS dept
WHERE status IN (
    SELECT status FROM categories AS ord
    WHERE ord.type = dept.type
);


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

SELECT amount FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.code = mgr.code
);


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

SELECT code FROM categories AS emp
WHERE amount > (
    SELECT AVG(salary) FROM shipments AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT name FROM employees AS sale
WHERE amount > (
    SELECT AVG(salary) FROM branches AS txn
    WHERE txn.code = sale.code
);


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

SELECT code FROM customers AS ord
WHERE code IN (
    SELECT code FROM branches AS sale
    WHERE sale.type = ord.type
);


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

SELECT value FROM orders AS whs
WHERE value > (
    SELECT SUM(salary) FROM transactions AS schd
    WHERE schd.level = whs.level
);


Prompt:
Schema:
  customers (alias: lne)(code, level, id, date)
  accounts(code, date, amount, type)
Task: Retrieve amount from customers with amount above the SUM(value) of accounts rows sharing the same id.
SQL:

SELECT amount FROM customers AS lne
WHERE amount > (
    SELECT SUM(value) FROM accounts AS schd
    WHERE schd.id = lne.id
);


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

SELECT salary FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.id = mgr.id
);


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

SELECT id FROM accounts AS ord
WHERE salary > (
    SELECT MIN(salary) FROM employees AS sale
    WHERE sale.status = ord.status
);


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

SELECT id FROM branches AS schd
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS srvc
    WHERE srvc.id = schd.id
);


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

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


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

SELECT amount FROM departments AS ord
WHERE level IN (
    SELECT level FROM employees AS sale
    WHERE sale.type = ord.type
);


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

SELECT code FROM branches AS prod
WHERE value > (
    SELECT SUM(salary) FROM regions AS catg
    WHERE catg.level = prod.level
);


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

SELECT value FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.status = ord.status
);


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

SELECT name FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.type = dept.type
);


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

SELECT value FROM categories AS schd
WHERE value > (
    SELECT SUM(amount) FROM departments AS ordr
    WHERE ordr.type = schd.type
);


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

SELECT salary FROM suppliers AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS whs
    WHERE whs.level = mgr.level
);


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

SELECT code FROM warehouses AS txn
WHERE amount > (
    SELECT MAX(amount) FROM employees AS budg
    WHERE budg.id = txn.id
);


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

SELECT name FROM warehouses AS ord
WHERE code IN (
    SELECT code FROM invoices AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT amount FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.type = catg.type
);


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

SELECT id FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.code = mgr.code
);


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

SELECT name FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.id = dept.id
);


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

SELECT id FROM categories AS inv
WHERE salary > (
    SELECT MAX(salary) FROM branches AS schd
    WHERE schd.level = inv.level
);


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

SELECT amount FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.code = sale.code
);


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

SELECT value FROM branches AS schd
WHERE type IN (
    SELECT type FROM transactions AS prod
    WHERE prod.code = schd.code
);


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

SELECT id FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.level = rgn.level
);


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

SELECT value FROM invoices AS schd
WHERE id IN (
    SELECT id FROM shipments AS whs
    WHERE whs.level = schd.level
);


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

SELECT code FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = emp.level
);


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

SELECT id FROM categories AS mgr
WHERE status IN (
    SELECT status FROM tasks AS cust
    WHERE cust.code = mgr.code
);


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

SELECT code FROM warehouses AS ord
WHERE status IN (
    SELECT status FROM tasks AS emp
    WHERE emp.level = ord.level
);


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

SELECT value FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = budg.level
);


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

SELECT amount FROM employees AS inv
WHERE amount > (
    SELECT MAX(value) FROM accounts AS dept
    WHERE dept.code = inv.code
);


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

SELECT id FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.id = sale.id
);


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

SELECT salary FROM projects AS catg
WHERE code IN (
    SELECT code FROM tasks AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT amount FROM employees AS catg
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS ordr
    WHERE ordr.status = catg.status
);


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

SELECT salary FROM categories AS srvc
WHERE salary > (
    SELECT SUM(value) FROM accounts AS inv
    WHERE inv.status = srvc.status
);


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

SELECT salary FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.level = srvc.level
);


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

SELECT id FROM employees AS srvc
WHERE status IN (
    SELECT status FROM regions AS ordr
    WHERE ordr.status = srvc.status
);


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

SELECT amount FROM customers AS whs
WHERE id IN (
    SELECT id FROM invoices AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT name FROM suppliers AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM orders AS emp
    WHERE emp.code = rgn.code
);


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

SELECT id FROM invoices AS ordr
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS txn
    WHERE txn.type = ordr.type
);


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

SELECT amount FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.type = dept.type
);


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

SELECT id FROM regions AS txn
WHERE value > (
    SELECT MIN(value) FROM invoices AS lne
    WHERE lne.level = txn.level
);


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

SELECT amount FROM transactions AS srvc
WHERE amount > (
    SELECT SUM(amount) FROM departments AS ord
    WHERE ord.status = srvc.status
);


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

SELECT salary FROM projects AS inv
WHERE type IN (
    SELECT type FROM invoices AS whs
    WHERE whs.type = inv.type
);


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

SELECT code FROM products AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM projects AS acct
    WHERE acct.level = rgn.level
);


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

SELECT code FROM warehouses AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS schd
    WHERE schd.status = ord.status
);


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

SELECT salary FROM categories AS empl
WHERE type IN (
    SELECT type FROM accounts AS schd
    WHERE schd.status = empl.status
);


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

SELECT code FROM products AS mgr
WHERE salary > (
    SELECT AVG(salary) FROM projects AS inv
    WHERE inv.type = mgr.type
);


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

SELECT code FROM invoices AS cust
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.level = cust.level
);


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

SELECT value FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.level = lne.level
);


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

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


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

SELECT code FROM regions AS budg
WHERE type IN (
    SELECT type FROM categories AS emp
    WHERE emp.level = budg.level
);


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

SELECT salary FROM customers AS shp
WHERE salary > (
    SELECT COUNT(amount) FROM warehouses AS catg
    WHERE catg.type = shp.type
);


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

SELECT amount FROM tasks AS ordr
WHERE amount > (
    SELECT MAX(amount) FROM regions AS ord
    WHERE ord.id = ordr.id
);


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

SELECT name FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.status = sale.status
);


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

SELECT salary FROM transactions AS budg
WHERE amount > (
    SELECT SUM(value) FROM regions AS sale
    WHERE sale.code = budg.code
);


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

SELECT value FROM orders AS srvc
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS catg
    WHERE catg.status = srvc.status
);


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

SELECT code FROM products AS empl
WHERE status IN (
    SELECT status FROM departments AS inv
    WHERE inv.code = empl.code
);


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

SELECT amount FROM invoices AS cust
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT value FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.type = rgn.type
);


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

SELECT name FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.type = acct.type
);


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

SELECT salary FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.id = dept.id
);


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

SELECT name FROM orders AS prod
WHERE amount > (
    SELECT COUNT(salary) FROM products AS whs
    WHERE whs.id = prod.id
);


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

SELECT id FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = prod.level
);


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

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


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

SELECT name FROM branches AS inv
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT value FROM employees AS lne
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS catg
    WHERE catg.code = lne.code
);


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

SELECT code FROM regions AS cust
WHERE status IN (
    SELECT status FROM tasks AS dept
    WHERE dept.type = cust.type
);


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

SELECT amount FROM tasks AS prod
WHERE status IN (
    SELECT status FROM projects AS ord
    WHERE ord.type = prod.type
);


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

SELECT value FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = ord.type
);


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

SELECT value FROM warehouses AS schd
WHERE value > (
    SELECT COUNT(value) FROM accounts AS cust
    WHERE cust.type = schd.type
);


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

SELECT id FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.id = budg.id
);


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

SELECT name FROM products AS txn
WHERE level IN (
    SELECT level FROM accounts AS empl
    WHERE empl.level = txn.level
);


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

SELECT amount FROM products AS mgr
WHERE code IN (
    SELECT code FROM suppliers AS budg
    WHERE budg.status = mgr.status
);


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

SELECT code FROM projects AS ord
WHERE type IN (
    SELECT type FROM orders AS whs
    WHERE whs.level = ord.level
);


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

SELECT salary FROM invoices AS catg
WHERE amount > (
    SELECT COUNT(value) FROM suppliers AS budg
    WHERE budg.type = catg.type
);


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

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


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

SELECT salary FROM departments AS prod
WHERE amount > (
    SELECT AVG(value) FROM projects AS cust
    WHERE cust.type = prod.type
);


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

SELECT code FROM projects AS txn
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT amount FROM accounts AS sale
WHERE id IN (
    SELECT id FROM branches AS ord
    WHERE ord.type = sale.type
);


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

SELECT salary FROM shipments AS whs
WHERE salary > (
    SELECT MIN(amount) FROM customers AS budg
    WHERE budg.code = whs.code
);


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

SELECT name FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.type = lne.type
);


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

SELECT amount FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.level = srvc.level
);


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

SELECT value FROM employees AS budg
WHERE salary > (
    SELECT MIN(salary) FROM tasks AS srvc
    WHERE srvc.code = budg.code
);


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

SELECT amount FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.status = sale.status
);


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

SELECT amount FROM employees AS budg
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS whs
    WHERE whs.code = budg.code
);


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

SELECT salary FROM transactions AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM tasks AS shp
    WHERE shp.type = empl.type
);


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

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


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

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


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

SELECT value FROM shipments AS emp
WHERE status IN (
    SELECT status FROM tasks AS catg
    WHERE catg.id = emp.id
);


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

SELECT name FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT value FROM products AS empl
WHERE level IN (
    SELECT level FROM transactions AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT salary FROM departments AS budg
WHERE salary > (
    SELECT MIN(salary) FROM branches AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT salary FROM customers AS cust
WHERE salary > (
    SELECT MIN(amount) FROM regions AS emp
    WHERE emp.status = cust.status
);


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

SELECT code FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.code = ordr.code
);


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

SELECT salary FROM shipments AS lne
WHERE value > (
    SELECT MAX(salary) FROM accounts AS cust
    WHERE cust.type = lne.type
);


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

SELECT code FROM regions AS dept
WHERE salary > (
    SELECT COUNT(value) FROM categories AS inv
    WHERE inv.type = dept.type
);


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

SELECT amount FROM invoices AS catg
WHERE id IN (
    SELECT id FROM regions AS rgn
    WHERE rgn.id = catg.id
);


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

SELECT code FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.type = shp.type
);


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

SELECT salary FROM products AS budg
WHERE salary > (
    SELECT MAX(amount) FROM employees AS schd
    WHERE schd.code = budg.code
);


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

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT MIN(amount) FROM projects AS whs
    WHERE whs.code = shp.code
);


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

SELECT id FROM categories AS acct
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS schd
    WHERE schd.level = acct.level
);


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

SELECT name FROM tasks AS emp
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS cust
    WHERE cust.type = emp.type
);


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

SELECT id FROM orders AS mgr
WHERE amount > (
    SELECT MIN(value) FROM warehouses AS ord
    WHERE ord.code = mgr.code
);


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

SELECT amount FROM employees AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS shp
    WHERE shp.status = mgr.status
);


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

SELECT name FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.status = budg.status
);


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

SELECT id FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.status = rgn.status
);


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

SELECT value FROM suppliers AS schd
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS acct
    WHERE acct.status = schd.status
);


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

SELECT value FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.type = sale.type
);


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

SELECT id FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = schd.level
);


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

SELECT id FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.code = mgr.code
);


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

SELECT code FROM shipments AS inv
WHERE salary > (
    SELECT AVG(salary) FROM orders AS whs
    WHERE whs.code = inv.code
);


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

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


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

SELECT id FROM shipments AS dept
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS inv
    WHERE inv.id = dept.id
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.status = inv.status
);


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

SELECT amount FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.id = ordr.id
);


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

SELECT value FROM products AS sale
WHERE id IN (
    SELECT id FROM orders AS prod
    WHERE prod.type = sale.type
);


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

SELECT salary FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT code FROM branches AS catg
WHERE level IN (
    SELECT level FROM products AS lne
    WHERE lne.level = catg.level
);


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

SELECT id FROM customers AS empl
WHERE level IN (
    SELECT level FROM branches AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT code FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT name FROM projects AS srvc
WHERE status IN (
    SELECT status FROM departments AS budg
    WHERE budg.code = srvc.code
);


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

SELECT id FROM categories AS rgn
WHERE salary > (
    SELECT COUNT(salary) FROM employees AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT value FROM shipments AS empl
WHERE code IN (
    SELECT code FROM employees AS schd
    WHERE schd.status = empl.status
);


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

SELECT value FROM accounts AS whs
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT name FROM products AS acct
WHERE salary > (
    SELECT COUNT(amount) FROM orders AS sale
    WHERE sale.type = acct.type
);


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

SELECT code FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.id = rgn.id
);


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

SELECT amount FROM warehouses AS schd
WHERE code IN (
    SELECT code FROM transactions AS ord
    WHERE ord.level = schd.level
);