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

SELECT salary FROM regions AS whs
WHERE type IN (
    SELECT type FROM warehouses AS ord
    WHERE ord.type = whs.type
);


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

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


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

SELECT code FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = schd.type
);


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

SELECT salary FROM categories AS acct
WHERE type IN (
    SELECT type FROM warehouses AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT name FROM accounts AS txn
WHERE salary > (
    SELECT SUM(value) FROM shipments AS sale
    WHERE sale.code = txn.code
);


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

SELECT amount FROM projects AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM customers AS dept
    WHERE dept.status = catg.status
);


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

SELECT code FROM branches AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS ord
    WHERE ord.id = whs.id
);


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

SELECT code FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.type = schd.type
);


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

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


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

SELECT id FROM invoices AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS empl
    WHERE empl.status = catg.status
);


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

SELECT name FROM shipments AS mgr
WHERE type IN (
    SELECT type FROM projects AS cust
    WHERE cust.level = mgr.level
);


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

SELECT salary FROM projects AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS cust
    WHERE cust.status = ordr.status
);


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

SELECT code FROM customers AS acct
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.level = acct.level
);


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

SELECT name FROM categories AS sale
WHERE value > (
    SELECT COUNT(value) FROM regions AS catg
    WHERE catg.status = sale.status
);


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

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


Prompt:
Schema:
  regions (alias: mgr)(type, code, id, salary)
  employees(type, salary, date, code)
Task: Find id from regions where status appears in employees entries with matching type.
SQL:

SELECT id FROM regions AS mgr
WHERE status IN (
    SELECT status FROM employees AS emp
    WHERE emp.type = mgr.type
);


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

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


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

SELECT amount FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT amount FROM transactions AS schd
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS budg
    WHERE budg.status = schd.status
);


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

SELECT salary FROM transactions AS emp
WHERE value > (
    SELECT COUNT(value) FROM invoices AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT salary FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.id = dept.id
);


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

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


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

SELECT amount FROM shipments AS sale
WHERE level IN (
    SELECT level FROM tasks AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT name FROM shipments AS txn
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.status = txn.status
);


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

SELECT salary FROM transactions AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT amount FROM products AS rgn
WHERE level IN (
    SELECT level FROM projects AS prod
    WHERE prod.code = rgn.code
);


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

SELECT salary FROM shipments AS ord
WHERE value > (
    SELECT MIN(amount) FROM orders AS srvc
    WHERE srvc.id = ord.id
);


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

SELECT amount FROM categories AS txn
WHERE status IN (
    SELECT status FROM departments AS budg
    WHERE budg.code = txn.code
);


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

SELECT salary FROM products AS ord
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS budg
    WHERE budg.type = ord.type
);


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

SELECT id FROM regions AS acct
WHERE amount > (
    SELECT COUNT(value) FROM suppliers AS ord
    WHERE ord.id = acct.id
);


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

SELECT salary FROM customers AS lne
WHERE level IN (
    SELECT level FROM warehouses AS budg
    WHERE budg.code = lne.code
);


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

SELECT id FROM invoices AS prod
WHERE value > (
    SELECT SUM(value) FROM warehouses AS cust
    WHERE cust.id = prod.id
);


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

SELECT name FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.type = catg.type
);


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

SELECT value FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.status = mgr.status
);


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

SELECT code FROM products AS empl
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.type = empl.type
);


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

SELECT name FROM employees AS whs
WHERE type IN (
    SELECT type FROM tasks AS emp
    WHERE emp.type = whs.type
);


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

SELECT code FROM employees AS shp
WHERE status IN (
    SELECT status FROM customers AS lne
    WHERE lne.level = shp.level
);


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

SELECT amount FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = dept.level
);


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

SELECT code FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.level = whs.level
);


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

SELECT id FROM products AS lne
WHERE id IN (
    SELECT id FROM categories AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT value FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.type = catg.type
);


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

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


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

SELECT amount FROM categories AS dept
WHERE id IN (
    SELECT id FROM tasks AS catg
    WHERE catg.id = dept.id
);


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

SELECT name FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT amount FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT value FROM categories AS shp
WHERE salary > (
    SELECT MIN(value) FROM invoices AS whs
    WHERE whs.id = shp.id
);


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

SELECT name FROM categories AS sale
WHERE type IN (
    SELECT type FROM warehouses AS inv
    WHERE inv.level = sale.level
);


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

SELECT code FROM customers AS ord
WHERE value > (
    SELECT SUM(salary) FROM employees AS mgr
    WHERE mgr.type = ord.type
);


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

SELECT amount FROM orders AS schd
WHERE level IN (
    SELECT level FROM transactions AS prod
    WHERE prod.level = schd.level
);


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

SELECT salary FROM warehouses AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS txn
    WHERE txn.type = lne.type
);


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

SELECT code FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.type = schd.type
);


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

SELECT value FROM regions AS emp
WHERE code IN (
    SELECT code FROM suppliers AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT salary FROM categories AS rgn
WHERE status IN (
    SELECT status FROM departments AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT salary FROM invoices AS srvc
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS empl
    WHERE empl.id = srvc.id
);


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

SELECT amount FROM transactions AS inv
WHERE code IN (
    SELECT code FROM shipments AS sale
    WHERE sale.id = inv.id
);


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

SELECT salary FROM orders AS shp
WHERE status IN (
    SELECT status FROM categories AS txn
    WHERE txn.id = shp.id
);


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

SELECT value FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.status = ordr.status
);


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

SELECT amount FROM orders AS ord
WHERE value > (
    SELECT MIN(salary) FROM suppliers AS catg
    WHERE catg.type = ord.type
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.status = prod.status
);


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

SELECT code FROM tasks AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS emp
    WHERE emp.id = acct.id
);


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

SELECT amount FROM shipments AS ordr
WHERE code IN (
    SELECT code FROM projects AS budg
    WHERE budg.status = ordr.status
);


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

SELECT salary FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.type = catg.type
);


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

SELECT salary FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.id = acct.id
);


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

SELECT code FROM invoices AS empl
WHERE salary > (
    SELECT MIN(salary) FROM orders AS shp
    WHERE shp.level = empl.level
);


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

SELECT amount FROM orders AS budg
WHERE code IN (
    SELECT code FROM products AS catg
    WHERE catg.status = budg.status
);


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

SELECT name FROM departments AS cust
WHERE salary > (
    SELECT MIN(amount) FROM employees AS txn
    WHERE txn.code = cust.code
);


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

SELECT name FROM customers AS shp
WHERE status IN (
    SELECT status FROM shipments AS emp
    WHERE emp.code = shp.code
);


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

SELECT value FROM branches AS budg
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS rgn
    WHERE rgn.id = budg.id
);


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

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


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

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


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

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


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

SELECT value FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.id = catg.id
);


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

SELECT amount FROM transactions AS lne
WHERE id IN (
    SELECT id FROM shipments AS ordr
    WHERE ordr.id = lne.id
);


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

SELECT amount FROM employees AS shp
WHERE id IN (
    SELECT id FROM warehouses AS cust
    WHERE cust.status = shp.status
);


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

SELECT amount FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.id = lne.id
);


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

SELECT name FROM customers AS acct
WHERE level IN (
    SELECT level FROM tasks AS mgr
    WHERE mgr.status = acct.status
);


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

SELECT code FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT name FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT amount FROM branches AS sale
WHERE id IN (
    SELECT id FROM transactions AS dept
    WHERE dept.status = sale.status
);


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

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


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

SELECT amount FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.id = mgr.id
);


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

SELECT value FROM regions AS inv
WHERE amount > (
    SELECT MAX(amount) FROM categories AS prod
    WHERE prod.code = inv.code
);


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

SELECT name FROM branches AS lne
WHERE id IN (
    SELECT id FROM orders AS shp
    WHERE shp.type = lne.type
);


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

SELECT name FROM products AS txn
WHERE status IN (
    SELECT status FROM branches AS ordr
    WHERE ordr.type = txn.type
);


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

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


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

SELECT salary FROM products AS lne
WHERE id IN (
    SELECT id FROM warehouses AS sale
    WHERE sale.level = lne.level
);


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

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


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

SELECT salary FROM customers AS txn
WHERE id IN (
    SELECT id FROM projects AS whs
    WHERE whs.status = txn.status
);


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

SELECT name FROM tasks AS rgn
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS sale
    WHERE sale.code = rgn.code
);


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

SELECT amount FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.level = mgr.level
);


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

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


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

SELECT code FROM departments AS dept
WHERE type IN (
    SELECT type FROM regions AS inv
    WHERE inv.level = dept.level
);


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

SELECT salary FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.code = lne.code
);


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

SELECT id FROM regions AS cust
WHERE salary > (
    SELECT MAX(amount) FROM departments AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT code FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.id = ord.id
);


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

SELECT amount FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.id = emp.id
);


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

SELECT salary FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.type = sale.type
);


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.id = emp.id
);


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

SELECT salary FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.type = txn.type
);


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

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


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

SELECT amount FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = budg.level
);


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

SELECT name FROM transactions AS mgr
WHERE code IN (
    SELECT code FROM tasks AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT code FROM warehouses AS acct
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS ord
    WHERE ord.type = acct.type
);


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

SELECT value FROM suppliers AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM employees AS empl
    WHERE empl.level = whs.level
);


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

SELECT id FROM tasks AS whs
WHERE id IN (
    SELECT id FROM warehouses AS empl
    WHERE empl.type = whs.type
);


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

SELECT name FROM suppliers AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM employees AS emp
    WHERE emp.code = mgr.code
);


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

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


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

SELECT value FROM employees AS dept
WHERE status IN (
    SELECT status FROM accounts AS prod
    WHERE prod.level = dept.level
);


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

SELECT amount FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = mgr.code
);


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

SELECT name FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.level = inv.level
);


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

SELECT name FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.level = inv.level
);


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

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


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

SELECT amount FROM accounts AS budg
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS acct
    WHERE acct.level = budg.level
);


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

SELECT salary FROM customers AS rgn
WHERE amount > (
    SELECT MIN(value) FROM shipments AS ord
    WHERE ord.status = rgn.status
);


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

SELECT amount FROM shipments AS schd
WHERE amount > (
    SELECT AVG(amount) FROM categories AS prod
    WHERE prod.status = schd.status
);


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

SELECT salary FROM shipments AS txn
WHERE salary > (
    SELECT MAX(salary) FROM orders AS mgr
    WHERE mgr.type = txn.type
);


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

SELECT amount FROM projects AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS budg
    WHERE budg.code = schd.code
);


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

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


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

SELECT name FROM customers AS ord
WHERE value > (
    SELECT MAX(amount) FROM products AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT salary FROM regions AS schd
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.level = schd.level
);


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

SELECT name FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = ord.type
);


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

SELECT id FROM departments AS mgr
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.type = mgr.type
);


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

SELECT name FROM departments AS schd
WHERE code IN (
    SELECT code FROM branches AS txn
    WHERE txn.type = schd.type
);


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

SELECT code FROM products AS lne
WHERE id IN (
    SELECT id FROM shipments AS emp
    WHERE emp.level = lne.level
);


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

SELECT code FROM categories AS dept
WHERE salary > (
    SELECT MAX(salary) FROM branches AS txn
    WHERE txn.code = dept.code
);


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

SELECT value FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.id = srvc.id
);


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

SELECT amount FROM transactions AS empl
WHERE level IN (
    SELECT level FROM shipments AS whs
    WHERE whs.level = empl.level
);


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

SELECT code FROM branches AS cust
WHERE type IN (
    SELECT type FROM regions AS lne
    WHERE lne.code = cust.code
);


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

SELECT code FROM transactions AS ordr
WHERE amount > (
    SELECT MIN(value) FROM tasks AS ord
    WHERE ord.code = ordr.code
);


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

SELECT code FROM departments AS dept
WHERE level IN (
    SELECT level FROM transactions AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT name FROM branches AS acct
WHERE salary > (
    SELECT MIN(amount) FROM departments AS shp
    WHERE shp.type = acct.type
);


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

SELECT value FROM suppliers AS whs
WHERE id IN (
    SELECT id FROM branches AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT code FROM regions AS inv
WHERE value > (
    SELECT SUM(value) FROM categories AS schd
    WHERE schd.status = inv.status
);


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

SELECT code FROM accounts AS srvc
WHERE status IN (
    SELECT status FROM employees AS prod
    WHERE prod.level = srvc.level
);


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

SELECT id FROM products AS cust
WHERE value > (
    SELECT AVG(value) FROM customers AS acct
    WHERE acct.code = cust.code
);


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

SELECT name FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.id = whs.id
);


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

SELECT amount FROM employees AS prod
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS txn
    WHERE txn.level = prod.level
);


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

SELECT amount FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.id = emp.id
);


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

SELECT id FROM suppliers AS empl
WHERE value > (
    SELECT COUNT(salary) FROM regions AS cust
    WHERE cust.type = empl.type
);


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

SELECT value FROM invoices AS mgr
WHERE type IN (
    SELECT type FROM tasks AS lne
    WHERE lne.status = mgr.status
);


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

SELECT value FROM regions AS prod
WHERE value > (
    SELECT AVG(salary) FROM employees AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT amount FROM shipments AS whs
WHERE amount > (
    SELECT AVG(salary) FROM orders AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT salary FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.status = shp.status
);


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

SELECT value FROM suppliers AS whs
WHERE type IN (
    SELECT type FROM invoices AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT salary FROM departments AS empl
WHERE status IN (
    SELECT status FROM regions AS shp
    WHERE shp.type = empl.type
);


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

SELECT id FROM customers AS rgn
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS catg
    WHERE catg.code = rgn.code
);


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

SELECT name FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.id = srvc.id
);


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

SELECT salary FROM transactions AS emp
WHERE level IN (
    SELECT level FROM projects AS catg
    WHERE catg.type = emp.type
);


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

SELECT salary FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.type = prod.type
);


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

SELECT amount FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.id = cust.id
);


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

SELECT name FROM projects AS ordr
WHERE type IN (
    SELECT type FROM orders AS dept
    WHERE dept.id = ordr.id
);


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

SELECT salary FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.type = ordr.type
);


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

SELECT salary FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.status = ordr.status
);


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

SELECT name FROM transactions AS inv
WHERE status IN (
    SELECT status FROM warehouses AS dept
    WHERE dept.level = inv.level
);


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

SELECT id FROM products AS sale
WHERE salary > (
    SELECT MIN(value) FROM shipments AS acct
    WHERE acct.id = sale.id
);


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

SELECT name FROM suppliers AS srvc
WHERE code IN (
    SELECT code FROM employees AS prod
    WHERE prod.type = srvc.type
);


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

SELECT salary FROM categories AS empl
WHERE salary > (
    SELECT MIN(value) FROM projects AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT id FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.code = prod.code
);


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

SELECT id FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.status = schd.status
);


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

SELECT salary FROM shipments AS empl
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS whs
    WHERE whs.type = empl.type
);


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

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


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

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


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

SELECT salary FROM branches AS empl
WHERE value > (
    SELECT COUNT(value) FROM categories AS lne
    WHERE lne.level = empl.level
);


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

SELECT salary FROM employees AS txn
WHERE value > (
    SELECT MIN(amount) FROM accounts AS emp
    WHERE emp.status = txn.status
);


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

SELECT code FROM categories AS sale
WHERE id IN (
    SELECT id FROM employees AS shp
    WHERE shp.type = sale.type
);


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

SELECT id FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = ord.status
);


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

SELECT id FROM tasks AS empl
WHERE salary > (
    SELECT COUNT(value) FROM products AS whs
    WHERE whs.code = empl.code
);


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

SELECT value FROM customers AS mgr
WHERE amount > (
    SELECT MAX(value) FROM branches AS budg
    WHERE budg.type = mgr.type
);


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

SELECT value FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.level = prod.level
);


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

SELECT id FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = empl.id
);


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

SELECT code FROM invoices AS shp
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS schd
    WHERE schd.type = shp.type
);


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

SELECT amount FROM branches AS lne
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.id = lne.id
);


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

SELECT amount FROM invoices AS empl
WHERE level IN (
    SELECT level FROM customers AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT salary FROM products AS catg
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.level = catg.level
);


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

SELECT code FROM suppliers AS schd
WHERE code IN (
    SELECT code FROM customers AS acct
    WHERE acct.code = schd.code
);


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

SELECT amount FROM customers AS lne
WHERE type IN (
    SELECT type FROM products AS sale
    WHERE sale.level = lne.level
);


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

SELECT name FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.code = sale.code
);


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

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


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

SELECT value FROM products AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM transactions AS prod
    WHERE prod.type = mgr.type
);


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

SELECT name FROM suppliers AS whs
WHERE status IN (
    SELECT status FROM accounts AS cust
    WHERE cust.code = whs.code
);


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

SELECT name FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT name FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.code = schd.code
);


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

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


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

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


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

SELECT code FROM departments AS lne
WHERE value > (
    SELECT SUM(value) FROM warehouses AS empl
    WHERE empl.code = lne.code
);


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

SELECT salary FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT value FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT amount FROM invoices AS ordr
WHERE amount > (
    SELECT MAX(amount) FROM departments AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT name FROM customers AS cust
WHERE code IN (
    SELECT code FROM tasks AS acct
    WHERE acct.status = cust.status
);


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

SELECT code FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.status = emp.status
);


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

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


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

SELECT code FROM invoices AS whs
WHERE type IN (
    SELECT type FROM projects AS schd
    WHERE schd.status = whs.status
);


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

SELECT amount FROM orders AS lne
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.type = lne.type
);


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

SELECT salary FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.type = inv.type
);


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

SELECT id FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.code = prod.code
);


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

SELECT id FROM employees AS mgr
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS schd
    WHERE schd.level = mgr.level
);


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

SELECT amount FROM products AS ord
WHERE code IN (
    SELECT code FROM projects AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = dept.status
);


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

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


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

SELECT name FROM transactions AS inv
WHERE status IN (
    SELECT status FROM products AS schd
    WHERE schd.level = inv.level
);


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

SELECT salary FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.level = budg.level
);


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

SELECT id FROM transactions AS prod
WHERE status IN (
    SELECT status FROM suppliers AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT code FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.type = cust.type
);


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

SELECT salary FROM branches AS catg
WHERE salary > (
    SELECT AVG(salary) FROM customers AS acct
    WHERE acct.status = catg.status
);


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

SELECT id FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.status = budg.status
);


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

SELECT code FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = ordr.level
);


Prompt:
Schema:
  tasks (alias: shp)(name, date, level, amount)
  branches(id, code, level, amount)
Task: Select id from tasks where code exists in branches for the same level.
SQL:

SELECT id FROM tasks AS shp
WHERE code IN (
    SELECT code FROM branches AS inv
    WHERE inv.level = shp.level
);


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

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


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

SELECT id FROM warehouses AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM orders AS prod
    WHERE prod.status = ordr.status
);


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

SELECT code FROM categories AS catg
WHERE type IN (
    SELECT type FROM suppliers AS inv
    WHERE inv.status = catg.status
);


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

SELECT code FROM accounts AS dept
WHERE salary > (
    SELECT MIN(salary) FROM branches AS sale
    WHERE sale.code = dept.code
);


Prompt:
Schema:
  employees (alias: acct)(status, amount, name, type)
  orders(id, name, status, type)
Task: Retrieve value from employees with value above the MAX(amount) of orders rows sharing the same type.
SQL:

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


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

SELECT name FROM projects AS empl
WHERE status IN (
    SELECT status FROM orders AS cust
    WHERE cust.code = empl.code
);


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

SELECT salary FROM tasks AS dept
WHERE status IN (
    SELECT status FROM shipments AS lne
    WHERE lne.type = dept.type
);


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

SELECT amount FROM orders AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT code FROM projects AS whs
WHERE value > (
    SELECT MIN(value) FROM suppliers AS prod
    WHERE prod.level = whs.level
);


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

SELECT salary FROM projects AS emp
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS sale
    WHERE sale.id = emp.id
);


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

SELECT value FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.level = txn.level
);


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

SELECT code FROM departments AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM branches AS sale
    WHERE sale.code = ordr.code
);


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

SELECT id FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.code = lne.code
);


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

SELECT amount FROM branches AS ord
WHERE status IN (
    SELECT status FROM categories AS shp
    WHERE shp.type = ord.type
);


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

SELECT name FROM departments AS cust
WHERE code IN (
    SELECT code FROM categories AS prod
    WHERE prod.id = cust.id
);


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

SELECT amount FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.type = txn.type
);


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

SELECT value FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.status = lne.status
);


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

SELECT salary FROM suppliers AS empl
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT amount FROM projects AS emp
WHERE level IN (
    SELECT level FROM orders AS ordr
    WHERE ordr.id = emp.id
);


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

SELECT id FROM regions AS sale
WHERE amount > (
    SELECT AVG(salary) FROM branches AS budg
    WHERE budg.code = sale.code
);


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

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


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

SELECT value FROM regions AS lne
WHERE salary > (
    SELECT MIN(salary) FROM products AS ordr
    WHERE ordr.code = lne.code
);


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

SELECT name FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.status = ord.status
);


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

SELECT code FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.type = whs.type
);


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

SELECT salary FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.type = catg.type
);


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

SELECT amount FROM accounts AS budg
WHERE id IN (
    SELECT id FROM transactions AS prod
    WHERE prod.code = budg.code
);


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

SELECT name FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.level = cust.level
);


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

SELECT amount FROM orders AS ord
WHERE salary > (
    SELECT MAX(value) FROM accounts AS inv
    WHERE inv.status = ord.status
);


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

SELECT code FROM branches AS txn
WHERE code IN (
    SELECT code FROM employees AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT value FROM employees AS shp
WHERE value > (
    SELECT COUNT(value) FROM projects AS emp
    WHERE emp.type = shp.type
);


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

SELECT amount FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.code = schd.code
);


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

SELECT amount FROM warehouses AS lne
WHERE level IN (
    SELECT level FROM suppliers AS prod
    WHERE prod.code = lne.code
);


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

SELECT code FROM branches AS empl
WHERE id IN (
    SELECT id FROM projects AS schd
    WHERE schd.status = empl.status
);


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

SELECT value FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.status = empl.status
);


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

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


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

SELECT name FROM transactions AS acct
WHERE code IN (
    SELECT code FROM branches AS budg
    WHERE budg.status = acct.status
);


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

SELECT id FROM transactions AS budg
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS empl
    WHERE empl.id = budg.id
);


Prompt:
Schema:
  departments (alias: sale)(status, value, name, amount)
  invoices(status, value, code, amount)
Task: Retrieve code from departments with amount above the MIN(value) of invoices rows sharing the same code.
SQL:

SELECT code FROM departments AS sale
WHERE amount > (
    SELECT MIN(value) FROM invoices AS catg
    WHERE catg.code = sale.code
);


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

SELECT amount FROM invoices AS shp
WHERE status IN (
    SELECT status FROM products AS schd
    WHERE schd.code = shp.code
);


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

SELECT code FROM employees AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT code FROM customers AS ord
WHERE value > (
    SELECT AVG(salary) FROM transactions AS whs
    WHERE whs.status = ord.status
);


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

SELECT amount FROM transactions AS empl
WHERE level IN (
    SELECT level FROM accounts AS shp
    WHERE shp.level = empl.level
);


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

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


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

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


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

SELECT id FROM tasks AS budg
WHERE id IN (
    SELECT id FROM projects AS sale
    WHERE sale.status = budg.status
);


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

SELECT salary FROM customers AS rgn
WHERE code IN (
    SELECT code FROM categories AS shp
    WHERE shp.id = rgn.id
);


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

SELECT value FROM tasks AS budg
WHERE id IN (
    SELECT id FROM regions AS shp
    WHERE shp.id = budg.id
);


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

SELECT id FROM departments AS txn
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS prod
    WHERE prod.code = txn.code
);


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

SELECT amount FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT amount FROM regions AS mgr
WHERE level IN (
    SELECT level FROM categories AS whs
    WHERE whs.status = mgr.status
);


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

SELECT code FROM transactions AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM employees AS budg
    WHERE budg.code = ordr.code
);


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

SELECT salary FROM products AS budg
WHERE type IN (
    SELECT type FROM branches AS schd
    WHERE schd.id = budg.id
);


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

SELECT name FROM warehouses AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS cust
    WHERE cust.type = whs.type
);


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

SELECT code FROM employees AS sale
WHERE type IN (
    SELECT type FROM warehouses AS empl
    WHERE empl.type = sale.type
);


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

SELECT id FROM regions AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM invoices AS prod
    WHERE prod.level = catg.level
);


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

SELECT code FROM categories AS empl
WHERE type IN (
    SELECT type FROM products AS cust
    WHERE cust.code = empl.code
);


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

SELECT id FROM departments AS ord
WHERE level IN (
    SELECT level FROM employees AS sale
    WHERE sale.code = ord.code
);


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

SELECT amount FROM shipments AS txn
WHERE status IN (
    SELECT status FROM employees AS shp
    WHERE shp.code = txn.code
);


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

SELECT amount FROM invoices AS schd
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS rgn
    WHERE rgn.id = schd.id
);


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

SELECT amount FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.code = prod.code
);


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

SELECT value FROM invoices AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS cust
    WHERE cust.id = ord.id
);


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

SELECT code FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.level = sale.level
);


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

SELECT value FROM accounts AS sale
WHERE amount > (
    SELECT MIN(salary) FROM employees AS empl
    WHERE empl.level = sale.level
);


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

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


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

SELECT code FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.level = acct.level
);


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

SELECT salary FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT id FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.code = whs.code
);


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

SELECT id FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = txn.type
);


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

SELECT code FROM departments AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM branches AS inv
    WHERE inv.code = mgr.code
);


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

SELECT name FROM suppliers AS inv
WHERE value > (
    SELECT COUNT(amount) FROM warehouses AS dept
    WHERE dept.id = inv.id
);


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

SELECT id FROM branches AS dept
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS cust
    WHERE cust.id = dept.id
);


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

SELECT value FROM orders AS ord
WHERE id IN (
    SELECT id FROM transactions AS shp
    WHERE shp.status = ord.status
);


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

SELECT id FROM transactions AS srvc
WHERE level IN (
    SELECT level FROM warehouses AS mgr
    WHERE mgr.type = srvc.type
);


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

SELECT name FROM branches AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS ordr
    WHERE ordr.code = txn.code
);


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

SELECT amount FROM departments AS sale
WHERE value > (
    SELECT MAX(value) FROM employees AS ord
    WHERE ord.status = sale.status
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.type = emp.type
);


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

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


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

SELECT value FROM products AS budg
WHERE salary > (
    SELECT MIN(salary) FROM categories AS inv
    WHERE inv.status = budg.status
);


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

SELECT name FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.status = whs.status
);


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

SELECT amount FROM accounts AS whs
WHERE status IN (
    SELECT status FROM employees AS dept
    WHERE dept.status = whs.status
);


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

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


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

SELECT value FROM warehouses AS dept
WHERE type IN (
    SELECT type FROM departments AS ord
    WHERE ord.type = dept.type
);


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

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