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

SELECT amount FROM branches AS cust
WHERE salary > (
    SELECT AVG(value) FROM categories AS empl
    WHERE empl.type = cust.type
);


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

SELECT value FROM suppliers AS txn
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS acct
    WHERE acct.id = txn.id
);


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

SELECT id FROM products AS shp
WHERE value > (
    SELECT COUNT(value) FROM branches AS catg
    WHERE catg.status = shp.status
);


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

SELECT id FROM categories AS ord
WHERE salary > (
    SELECT SUM(salary) FROM products AS catg
    WHERE catg.level = ord.level
);


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

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


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

SELECT value FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.level = catg.level
);


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

SELECT id FROM invoices AS prod
WHERE level IN (
    SELECT level FROM products AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT value FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.level = sale.level
);


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

SELECT id FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.level = lne.level
);


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

SELECT id FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = emp.level
);


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

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


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

SELECT name FROM categories AS dept
WHERE amount > (
    SELECT MIN(value) FROM suppliers AS ord
    WHERE ord.id = dept.id
);


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

SELECT code FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT id FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = schd.type
);


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

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


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

SELECT code FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT value FROM transactions AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS inv
    WHERE inv.status = rgn.status
);


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

SELECT value FROM suppliers AS budg
WHERE level IN (
    SELECT level FROM projects AS txn
    WHERE txn.id = budg.id
);


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

SELECT name FROM tasks AS acct
WHERE type IN (
    SELECT type FROM departments AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT amount FROM accounts AS lne
WHERE level IN (
    SELECT level FROM warehouses AS ord
    WHERE ord.status = lne.status
);


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

SELECT value FROM regions AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM branches AS prod
    WHERE prod.id = rgn.id
);


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

SELECT salary FROM accounts AS shp
WHERE amount > (
    SELECT SUM(value) FROM products AS empl
    WHERE empl.id = shp.id
);


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

SELECT id FROM regions AS ord
WHERE value > (
    SELECT SUM(salary) FROM orders AS inv
    WHERE inv.status = ord.status
);


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

SELECT name FROM orders AS txn
WHERE level IN (
    SELECT level FROM categories AS sale
    WHERE sale.status = txn.status
);


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

SELECT value FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.level = mgr.level
);


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

SELECT value FROM regions AS prod
WHERE value > (
    SELECT MAX(value) FROM departments AS cust
    WHERE cust.level = prod.level
);


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

SELECT value FROM branches AS ord
WHERE code IN (
    SELECT code FROM tasks AS sale
    WHERE sale.status = ord.status
);


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

SELECT salary FROM projects AS empl
WHERE code IN (
    SELECT code FROM transactions AS cust
    WHERE cust.level = empl.level
);


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

SELECT name FROM shipments AS acct
WHERE code IN (
    SELECT code FROM employees AS inv
    WHERE inv.type = acct.type
);


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

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


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

SELECT id FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.id = txn.id
);


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

SELECT id FROM products AS catg
WHERE salary > (
    SELECT AVG(amount) FROM projects AS schd
    WHERE schd.status = catg.status
);


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

SELECT amount FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.code = shp.code
);


Prompt:
Schema:
  customers (alias: inv)(status, type, salary, amount)
  invoices(salary, type, amount, value)
Task: Retrieve value from customers with value above the MAX(amount) of invoices rows sharing the same status.
SQL:

SELECT value FROM customers AS inv
WHERE value > (
    SELECT MAX(amount) FROM invoices AS rgn
    WHERE rgn.status = inv.status
);


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

SELECT code FROM employees AS inv
WHERE amount > (
    SELECT AVG(value) FROM projects AS cust
    WHERE cust.type = inv.type
);


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

SELECT value FROM warehouses AS sale
WHERE value > (
    SELECT SUM(salary) FROM departments AS catg
    WHERE catg.type = sale.type
);


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

SELECT name FROM products AS ord
WHERE status IN (
    SELECT status FROM branches AS empl
    WHERE empl.code = ord.code
);


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

SELECT amount FROM customers AS cust
WHERE value > (
    SELECT MAX(salary) FROM categories AS ord
    WHERE ord.level = cust.level
);


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

SELECT amount FROM categories AS empl
WHERE level IN (
    SELECT level FROM shipments AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT name FROM warehouses AS txn
WHERE status IN (
    SELECT status FROM tasks AS inv
    WHERE inv.status = txn.status
);


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

SELECT amount FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT code FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.type = acct.type
);


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

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


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

SELECT amount FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = inv.level
);


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

SELECT id FROM employees AS txn
WHERE code IN (
    SELECT code FROM tasks AS whs
    WHERE whs.code = txn.code
);


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

SELECT name FROM departments AS sale
WHERE level IN (
    SELECT level FROM categories AS rgn
    WHERE rgn.type = sale.type
);


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

SELECT id FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT name FROM suppliers AS rgn
WHERE type IN (
    SELECT type FROM departments AS cust
    WHERE cust.level = rgn.level
);


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

SELECT value FROM departments AS mgr
WHERE type IN (
    SELECT type FROM tasks AS schd
    WHERE schd.type = mgr.type
);


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

SELECT amount FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.code = budg.code
);


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

SELECT name FROM invoices AS shp
WHERE amount > (
    SELECT AVG(value) FROM employees AS emp
    WHERE emp.code = shp.code
);


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

SELECT id FROM orders AS sale
WHERE code IN (
    SELECT code FROM transactions AS cust
    WHERE cust.type = sale.type
);


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

SELECT name FROM transactions AS mgr
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS schd
    WHERE schd.level = mgr.level
);


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

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


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

SELECT value FROM branches AS sale
WHERE level IN (
    SELECT level FROM warehouses AS budg
    WHERE budg.level = sale.level
);


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

SELECT amount FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.level = catg.level
);


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

SELECT code FROM categories AS schd
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT salary FROM products AS budg
WHERE type IN (
    SELECT type FROM transactions AS prod
    WHERE prod.type = budg.type
);


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

SELECT code FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.status = srvc.status
);


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

SELECT salary FROM departments AS txn
WHERE id IN (
    SELECT id FROM branches AS empl
    WHERE empl.id = txn.id
);


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

SELECT salary FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT code FROM transactions AS cust
WHERE code IN (
    SELECT code FROM projects AS lne
    WHERE lne.type = cust.type
);


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

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


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

SELECT salary FROM orders AS ordr
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS schd
    WHERE schd.id = ordr.id
);


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

SELECT code FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.id = budg.id
);


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

SELECT value FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.level = inv.level
);


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

SELECT name FROM invoices AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM employees AS emp
    WHERE emp.id = ordr.id
);


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

SELECT name FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT amount FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.id = empl.id
);


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

SELECT id FROM accounts AS empl
WHERE salary > (
    SELECT AVG(amount) FROM projects AS srvc
    WHERE srvc.level = empl.level
);


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

SELECT code FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.code = ord.code
);


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

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


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

SELECT code FROM warehouses AS shp
WHERE status IN (
    SELECT status FROM invoices AS emp
    WHERE emp.level = shp.level
);


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

SELECT code FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.id = catg.id
);


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

SELECT amount FROM tasks AS srvc
WHERE salary > (
    SELECT MIN(salary) FROM employees AS prod
    WHERE prod.id = srvc.id
);


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

SELECT id FROM branches AS rgn
WHERE code IN (
    SELECT code FROM departments AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT amount FROM branches AS srvc
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS ord
    WHERE ord.status = srvc.status
);


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

SELECT value FROM invoices AS ord
WHERE type IN (
    SELECT type FROM projects AS srvc
    WHERE srvc.id = ord.id
);


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

SELECT value FROM orders AS dept
WHERE value > (
    SELECT COUNT(salary) FROM suppliers AS shp
    WHERE shp.level = dept.level
);


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

SELECT id FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.type = prod.type
);


Prompt:
Schema:
  projects (alias: schd)(date, code, level, id)
  customers(type, status, code, salary)
Task: Retrieve salary from projects with salary above the MIN(salary) of customers rows sharing the same status.
SQL:

SELECT salary FROM projects AS schd
WHERE salary > (
    SELECT MIN(salary) FROM customers AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT salary FROM regions AS inv
WHERE type IN (
    SELECT type FROM orders AS whs
    WHERE whs.code = inv.code
);


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

SELECT id FROM transactions AS txn
WHERE type IN (
    SELECT type FROM regions AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT value FROM customers AS empl
WHERE value > (
    SELECT AVG(value) FROM branches AS catg
    WHERE catg.level = empl.level
);


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

SELECT id FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.level = mgr.level
);


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

SELECT salary FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.status = ordr.status
);


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

SELECT id FROM branches AS emp
WHERE type IN (
    SELECT type FROM accounts AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT id FROM accounts AS cust
WHERE amount > (
    SELECT SUM(amount) FROM orders AS inv
    WHERE inv.code = cust.code
);


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

SELECT value FROM departments AS whs
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS shp
    WHERE shp.level = whs.level
);


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

SELECT value FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.type = acct.type
);


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

SELECT value FROM warehouses AS cust
WHERE value > (
    SELECT SUM(amount) FROM products AS prod
    WHERE prod.type = cust.type
);


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

SELECT salary FROM warehouses AS ord
WHERE code IN (
    SELECT code FROM transactions AS sale
    WHERE sale.id = ord.id
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT value FROM projects AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = inv.id
);


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

SELECT amount FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.code = inv.code
);


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

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


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

SELECT salary FROM products AS prod
WHERE type IN (
    SELECT type FROM branches AS mgr
    WHERE mgr.type = prod.type
);


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

SELECT value FROM employees AS lne
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS dept
    WHERE dept.code = lne.code
);


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

SELECT id FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.level = schd.level
);


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

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


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

SELECT name FROM categories AS dept
WHERE amount > (
    SELECT MAX(salary) FROM branches AS inv
    WHERE inv.status = dept.status
);


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

SELECT id FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.level = rgn.level
);


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

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


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

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


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

SELECT id FROM tasks AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS srvc
    WHERE srvc.code = ord.code
);


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

SELECT id FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.code = lne.code
);


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

SELECT amount FROM regions AS mgr
WHERE id IN (
    SELECT id FROM customers AS sale
    WHERE sale.id = mgr.id
);


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

SELECT value FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT salary FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT value FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.id = mgr.id
);


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

SELECT amount FROM branches AS inv
WHERE amount > (
    SELECT MIN(amount) FROM warehouses AS catg
    WHERE catg.type = inv.type
);


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

SELECT id FROM orders AS catg
WHERE level IN (
    SELECT level FROM departments AS cust
    WHERE cust.type = catg.type
);


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

SELECT code FROM suppliers AS lne
WHERE status IN (
    SELECT status FROM customers AS ord
    WHERE ord.code = lne.code
);


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

SELECT id FROM projects AS lne
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS inv
    WHERE inv.level = lne.level
);


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

SELECT code FROM projects AS emp
WHERE type IN (
    SELECT type FROM shipments AS catg
    WHERE catg.code = emp.code
);


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

SELECT salary FROM suppliers AS mgr
WHERE type IN (
    SELECT type FROM invoices AS whs
    WHERE whs.status = mgr.status
);


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

SELECT value FROM departments AS txn
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS prod
    WHERE prod.code = txn.code
);


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

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


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

SELECT id FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.type = ordr.type
);


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

SELECT code FROM shipments AS sale
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS rgn
    WHERE rgn.level = sale.level
);


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

SELECT salary FROM employees AS srvc
WHERE value > (
    SELECT SUM(salary) FROM orders AS budg
    WHERE budg.id = srvc.id
);


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

SELECT id FROM projects AS catg
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS prod
    WHERE prod.code = catg.code
);


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

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


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

SELECT name FROM branches AS emp
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS srvc
    WHERE srvc.id = emp.id
);


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

SELECT code FROM accounts AS emp
WHERE status IN (
    SELECT status FROM employees AS empl
    WHERE empl.status = emp.status
);


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

SELECT id FROM shipments AS whs
WHERE amount > (
    SELECT SUM(amount) FROM employees AS emp
    WHERE emp.type = whs.type
);


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

SELECT code FROM transactions AS emp
WHERE amount > (
    SELECT AVG(value) FROM orders AS txn
    WHERE txn.level = emp.level
);


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

SELECT name FROM customers AS rgn
WHERE value > (
    SELECT SUM(salary) FROM tasks AS cust
    WHERE cust.code = rgn.code
);


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

SELECT value FROM orders AS ord
WHERE code IN (
    SELECT code FROM employees AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT salary FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.type = budg.type
);


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

SELECT amount FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.status = budg.status
);


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

SELECT value FROM accounts AS emp
WHERE code IN (
    SELECT code FROM warehouses AS inv
    WHERE inv.type = emp.type
);


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

SELECT id FROM shipments AS shp
WHERE type IN (
    SELECT type FROM transactions AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT code FROM shipments AS ordr
WHERE level IN (
    SELECT level FROM products AS empl
    WHERE empl.code = ordr.code
);


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

SELECT id FROM categories AS txn
WHERE code IN (
    SELECT code FROM departments AS inv
    WHERE inv.status = txn.status
);


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

SELECT name FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.status = dept.status
);


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

SELECT id FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.type = inv.type
);


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

SELECT value FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.level = cust.level
);


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

SELECT code FROM tasks AS srvc
WHERE value > (
    SELECT MIN(amount) FROM products AS acct
    WHERE acct.id = srvc.id
);


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

SELECT name FROM regions AS dept
WHERE value > (
    SELECT AVG(value) FROM transactions AS acct
    WHERE acct.level = dept.level
);


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

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


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

SELECT salary FROM regions AS lne
WHERE status IN (
    SELECT status FROM branches AS ordr
    WHERE ordr.level = lne.level
);


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

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


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

SELECT code FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.level = lne.level
);


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

SELECT amount FROM invoices AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM projects AS rgn
    WHERE rgn.level = ordr.level
);


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

SELECT id FROM warehouses AS acct
WHERE salary > (
    SELECT MIN(salary) FROM departments AS emp
    WHERE emp.id = acct.id
);


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

SELECT name FROM warehouses AS whs
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT id FROM shipments AS schd
WHERE id IN (
    SELECT id FROM employees AS budg
    WHERE budg.type = schd.type
);


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

SELECT value FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.status = prod.status
);


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

SELECT value FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.code = catg.code
);


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

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


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

SELECT salary FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.id = budg.id
);


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

SELECT code FROM departments AS srvc
WHERE id IN (
    SELECT id FROM suppliers AS dept
    WHERE dept.level = srvc.level
);


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

SELECT amount FROM employees AS inv
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.level = inv.level
);


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

SELECT value FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT code FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.id = ordr.id
);


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

SELECT code FROM projects AS empl
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS budg
    WHERE budg.id = empl.id
);


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

SELECT name FROM regions AS ordr
WHERE code IN (
    SELECT code FROM projects AS acct
    WHERE acct.level = ordr.level
);


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

SELECT salary FROM tasks AS emp
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.code = emp.code
);


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

SELECT amount FROM projects AS schd
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS dept
    WHERE dept.code = schd.code
);


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

SELECT salary FROM regions AS rgn
WHERE amount > (
    SELECT AVG(value) FROM transactions AS sale
    WHERE sale.level = rgn.level
);


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

SELECT amount FROM suppliers AS emp
WHERE id IN (
    SELECT id FROM tasks AS whs
    WHERE whs.code = emp.code
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.id = dept.id
);


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

SELECT salary FROM customers AS emp
WHERE value > (
    SELECT MIN(value) FROM departments AS empl
    WHERE empl.id = emp.id
);


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

SELECT code FROM branches AS inv
WHERE amount > (
    SELECT MAX(value) FROM transactions AS emp
    WHERE emp.status = inv.status
);


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

SELECT name FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.level = emp.level
);


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

SELECT salary FROM categories AS lne
WHERE status IN (
    SELECT status FROM shipments AS schd
    WHERE schd.id = lne.id
);


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

SELECT amount FROM customers AS lne
WHERE amount > (
    SELECT MAX(salary) FROM regions AS inv
    WHERE inv.status = lne.status
);


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

SELECT id FROM tasks AS budg
WHERE level IN (
    SELECT level FROM warehouses AS emp
    WHERE emp.code = budg.code
);


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

SELECT amount FROM suppliers AS catg
WHERE level IN (
    SELECT level FROM shipments AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT amount FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.code = acct.code
);


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

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


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

SELECT id FROM transactions AS ordr
WHERE type IN (
    SELECT type FROM employees AS budg
    WHERE budg.type = ordr.type
);


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

SELECT value FROM customers AS cust
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS acct
    WHERE acct.level = cust.level
);


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

SELECT salary FROM branches AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM regions AS empl
    WHERE empl.type = srvc.type
);


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

SELECT id FROM products AS rgn
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.level = rgn.level
);


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

SELECT id FROM departments AS mgr
WHERE value > (
    SELECT MIN(amount) FROM products AS prod
    WHERE prod.type = mgr.type
);


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

SELECT code FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.status = cust.status
);


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

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


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

SELECT code FROM orders AS lne
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS whs
    WHERE whs.id = lne.id
);


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

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


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

SELECT id FROM shipments AS acct
WHERE type IN (
    SELECT type FROM customers AS schd
    WHERE schd.status = acct.status
);


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

SELECT value FROM accounts AS cust
WHERE level IN (
    SELECT level FROM orders AS acct
    WHERE acct.status = cust.status
);


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

SELECT code FROM invoices AS txn
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS lne
    WHERE lne.type = txn.type
);


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

SELECT amount FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.level = mgr.level
);


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

SELECT id FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.type = cust.type
);


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

SELECT amount FROM projects AS cust
WHERE salary > (
    SELECT SUM(amount) FROM warehouses AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT code FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.status = txn.status
);


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

SELECT amount FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = whs.level
);


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

SELECT value FROM categories AS ordr
WHERE salary > (
    SELECT AVG(value) FROM employees AS whs
    WHERE whs.type = ordr.type
);


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

SELECT code FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT code FROM projects AS prod
WHERE type IN (
    SELECT type FROM customers AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT amount FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM departments AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT salary FROM transactions AS dept
WHERE value > (
    SELECT MIN(salary) FROM regions AS shp
    WHERE shp.level = dept.level
);


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

SELECT code FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.status = dept.status
);


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

SELECT code FROM categories AS shp
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT salary FROM branches AS ordr
WHERE value > (
    SELECT MAX(value) FROM categories AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT id FROM orders AS sale
WHERE type IN (
    SELECT type FROM departments AS whs
    WHERE whs.status = sale.status
);


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

SELECT value FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.status = ordr.status
);


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

SELECT value FROM tasks AS lne
WHERE salary > (
    SELECT SUM(value) FROM accounts AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT code FROM employees AS inv
WHERE level IN (
    SELECT level FROM regions AS whs
    WHERE whs.status = inv.status
);


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

SELECT name FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = acct.code
);


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

SELECT salary FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.status = mgr.status
);


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

SELECT id FROM categories AS sale
WHERE salary > (
    SELECT AVG(value) FROM customers AS cust
    WHERE cust.level = sale.level
);


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

SELECT amount FROM suppliers AS inv
WHERE code IN (
    SELECT code FROM warehouses AS budg
    WHERE budg.status = inv.status
);


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

SELECT salary FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.id = mgr.id
);


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

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


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

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


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

SELECT value FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.id = txn.id
);


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

SELECT id FROM regions AS acct
WHERE value > (
    SELECT COUNT(amount) FROM warehouses AS cust
    WHERE cust.type = acct.type
);


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

SELECT salary FROM regions AS lne
WHERE value > (
    SELECT COUNT(amount) FROM transactions AS ord
    WHERE ord.status = lne.status
);


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

SELECT amount FROM customers AS emp
WHERE code IN (
    SELECT code FROM projects AS sale
    WHERE sale.id = emp.id
);


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

SELECT name FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = emp.level
);


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

SELECT code FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.id = cust.id
);


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

SELECT id FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.type = sale.type
);


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

SELECT salary FROM shipments AS shp
WHERE value > (
    SELECT SUM(salary) FROM employees AS cust
    WHERE cust.id = shp.id
);


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

SELECT amount FROM employees AS prod
WHERE id IN (
    SELECT id FROM transactions AS sale
    WHERE sale.status = prod.status
);


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

SELECT amount FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.status = shp.status
);


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

SELECT code FROM warehouses AS acct
WHERE value > (
    SELECT MIN(amount) FROM invoices AS dept
    WHERE dept.level = acct.level
);


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

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


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

SELECT salary FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.level = catg.level
);


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

SELECT salary FROM departments AS ord
WHERE salary > (
    SELECT AVG(value) FROM customers AS dept
    WHERE dept.code = ord.code
);


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

SELECT value FROM customers AS lne
WHERE type IN (
    SELECT type FROM accounts AS txn
    WHERE txn.type = lne.type
);


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

SELECT id FROM employees AS lne
WHERE salary > (
    SELECT MIN(value) FROM shipments AS schd
    WHERE schd.status = lne.status
);


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

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


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

SELECT id FROM categories AS mgr
WHERE code IN (
    SELECT code FROM invoices AS dept
    WHERE dept.status = mgr.status
);


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

SELECT id FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.code = prod.code
);


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

SELECT salary FROM tasks AS cust
WHERE id IN (
    SELECT id FROM orders AS inv
    WHERE inv.id = cust.id
);


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

SELECT name FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.code = schd.code
);


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

SELECT id FROM invoices AS ord
WHERE value > (
    SELECT COUNT(value) FROM warehouses AS acct
    WHERE acct.level = ord.level
);


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

SELECT code FROM projects AS budg
WHERE amount > (
    SELECT COUNT(value) FROM products AS inv
    WHERE inv.type = budg.type
);


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

SELECT code FROM warehouses AS emp
WHERE value > (
    SELECT AVG(value) FROM customers AS budg
    WHERE budg.status = emp.status
);


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

SELECT code FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT id FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.status = mgr.status
);


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

SELECT name FROM transactions AS ordr
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.level = ordr.level
);


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

SELECT code FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.level = emp.level
);


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

SELECT code FROM warehouses AS catg
WHERE status IN (
    SELECT status FROM shipments AS shp
    WHERE shp.status = catg.status
);


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

SELECT id FROM products AS sale
WHERE salary > (
    SELECT AVG(salary) FROM branches AS whs
    WHERE whs.code = sale.code
);


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

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


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

SELECT code FROM regions AS prod
WHERE id IN (
    SELECT id FROM accounts AS inv
    WHERE inv.id = prod.id
);


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

SELECT name FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.type = lne.type
);


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

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


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

SELECT name FROM categories AS inv
WHERE level IN (
    SELECT level FROM invoices AS emp
    WHERE emp.code = inv.code
);


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

SELECT id FROM projects AS acct
WHERE code IN (
    SELECT code FROM employees AS empl
    WHERE empl.code = acct.code
);


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

SELECT value FROM tasks AS inv
WHERE amount > (
    SELECT AVG(value) FROM customers AS txn
    WHERE txn.code = inv.code
);


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

SELECT amount FROM shipments AS emp
WHERE amount > (
    SELECT MAX(amount) FROM departments AS sale
    WHERE sale.status = emp.status
);


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

SELECT name FROM accounts AS rgn
WHERE code IN (
    SELECT code FROM regions AS whs
    WHERE whs.code = rgn.code
);


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

SELECT value FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = catg.code
);


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

SELECT amount FROM projects AS cust
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT value FROM branches AS dept
WHERE type IN (
    SELECT type FROM categories AS empl
    WHERE empl.status = dept.status
);


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

SELECT code FROM invoices AS txn
WHERE amount > (
    SELECT MAX(salary) FROM accounts AS empl
    WHERE empl.status = txn.status
);


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

SELECT amount FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.status = rgn.status
);


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

SELECT value FROM departments AS ord
WHERE value > (
    SELECT COUNT(value) FROM regions AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT code FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.type = ord.type
);


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

SELECT name FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.id = prod.id
);


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

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


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

SELECT id FROM regions AS acct
WHERE id IN (
    SELECT id FROM accounts AS srvc
    WHERE srvc.id = acct.id
);


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

SELECT salary FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.type = srvc.type
);


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

SELECT salary FROM departments AS dept
WHERE status IN (
    SELECT status FROM products AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT id FROM regions AS srvc
WHERE salary > (
    SELECT SUM(value) FROM branches AS dept
    WHERE dept.level = srvc.level
);


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

SELECT id FROM projects AS emp
WHERE status IN (
    SELECT status FROM orders AS mgr
    WHERE mgr.status = emp.status
);


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

SELECT value FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.type = rgn.type
);


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

SELECT id FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = acct.type
);


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

SELECT salary FROM tasks AS inv
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.status = inv.status
);


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

SELECT code FROM products AS ordr
WHERE id IN (
    SELECT id FROM orders AS dept
    WHERE dept.status = ordr.status
);


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

SELECT amount FROM tasks AS sale
WHERE value > (
    SELECT MAX(value) FROM invoices AS empl
    WHERE empl.status = sale.status
);


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

SELECT id FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.level = ordr.level
);


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

SELECT id FROM regions AS empl
WHERE type IN (
    SELECT type FROM shipments AS emp
    WHERE emp.status = empl.status
);


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

SELECT name FROM customers AS cust
WHERE amount > (
    SELECT MAX(salary) FROM products AS empl
    WHERE empl.level = cust.level
);


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

SELECT value FROM orders AS budg
WHERE status IN (
    SELECT status FROM employees AS catg
    WHERE catg.type = budg.type
);


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

SELECT value FROM suppliers AS rgn
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.id = rgn.id
);


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

SELECT id FROM warehouses AS txn
WHERE status IN (
    SELECT status FROM employees AS lne
    WHERE lne.status = txn.status
);


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

SELECT id FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.code = shp.code
);


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

SELECT salary FROM branches AS acct
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.id = acct.id
);


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

SELECT code FROM projects AS acct
WHERE type IN (
    SELECT type FROM suppliers AS txn
    WHERE txn.code = acct.code
);


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

SELECT amount FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.status = catg.status
);


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

SELECT name FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.code = empl.code
);


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

SELECT code FROM employees AS sale
WHERE code IN (
    SELECT code FROM transactions AS lne
    WHERE lne.level = sale.level
);


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

SELECT id FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT amount FROM regions AS srvc
WHERE type IN (
    SELECT type FROM tasks AS whs
    WHERE whs.id = srvc.id
);


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

SELECT id FROM invoices AS srvc
WHERE code IN (
    SELECT code FROM suppliers AS ord
    WHERE ord.type = srvc.type
);


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

SELECT value FROM employees AS lne
WHERE salary > (
    SELECT AVG(value) FROM customers AS budg
    WHERE budg.status = lne.status
);


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

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


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

SELECT code FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.status = lne.status
);


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

SELECT amount FROM accounts AS schd
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS shp
    WHERE shp.status = schd.status
);


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

SELECT name FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.id = mgr.id
);


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

SELECT code FROM employees AS emp
WHERE amount > (
    SELECT MIN(salary) FROM departments AS budg
    WHERE budg.id = emp.id
);


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

SELECT name FROM transactions AS sale
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.id = sale.id
);


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

SELECT salary FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.code = catg.code
);


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

SELECT code FROM branches AS sale
WHERE value > (
    SELECT MAX(value) FROM employees AS prod
    WHERE prod.id = sale.id
);


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

SELECT salary FROM customers AS txn
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS sale
    WHERE sale.status = txn.status
);


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

SELECT id FROM products AS cust
WHERE code IN (
    SELECT code FROM branches AS acct
    WHERE acct.level = cust.level
);


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

SELECT amount FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.code = whs.code
);