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

SELECT code FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.id = budg.id
);


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

SELECT amount FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT name FROM tasks AS schd
WHERE salary > (
    SELECT COUNT(value) FROM accounts AS dept
    WHERE dept.type = schd.type
);


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

SELECT code FROM warehouses AS empl
WHERE code IN (
    SELECT code FROM suppliers AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT salary FROM employees AS inv
WHERE id IN (
    SELECT id FROM departments AS dept
    WHERE dept.level = inv.level
);


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

SELECT amount FROM warehouses AS catg
WHERE amount > (
    SELECT AVG(amount) FROM departments AS cust
    WHERE cust.type = catg.type
);


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

SELECT amount FROM orders AS cust
WHERE status IN (
    SELECT status FROM customers AS catg
    WHERE catg.id = cust.id
);


Prompt:
Schema:
  categories (alias: lne)(amount, level, value, name)
  projects(code, value, status, level)
Task: Retrieve value from categories with amount above the MAX(value) of projects rows sharing the same status.
SQL:

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


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

SELECT name FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.status = rgn.status
);


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

SELECT name FROM branches AS txn
WHERE value > (
    SELECT SUM(amount) FROM invoices AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT value FROM departments AS catg
WHERE type IN (
    SELECT type FROM products AS shp
    WHERE shp.status = catg.status
);


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

SELECT code FROM projects AS empl
WHERE code IN (
    SELECT code FROM branches AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT salary FROM regions AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM accounts AS acct
    WHERE acct.type = sale.type
);


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

SELECT name FROM branches AS rgn
WHERE code IN (
    SELECT code FROM suppliers AS whs
    WHERE whs.id = rgn.id
);


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

SELECT salary FROM accounts AS lne
WHERE id IN (
    SELECT id FROM departments AS inv
    WHERE inv.code = lne.code
);


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

SELECT id FROM tasks AS inv
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS whs
    WHERE whs.code = inv.code
);


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

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


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.status = empl.status
);


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

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


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

SELECT amount FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.level = mgr.level
);


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

SELECT id FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.level = inv.level
);


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

SELECT salary FROM categories AS dept
WHERE level IN (
    SELECT level FROM products AS ordr
    WHERE ordr.level = dept.level
);


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

SELECT id FROM transactions AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS emp
    WHERE emp.id = ord.id
);


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

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


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

SELECT name FROM invoices AS acct
WHERE amount > (
    SELECT MIN(salary) FROM customers AS schd
    WHERE schd.status = acct.status
);


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

SELECT amount FROM regions AS catg
WHERE id IN (
    SELECT id FROM shipments AS acct
    WHERE acct.id = catg.id
);


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

SELECT name FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.id = cust.id
);


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

SELECT name FROM warehouses AS sale
WHERE amount > (
    SELECT MAX(amount) FROM projects AS catg
    WHERE catg.level = sale.level
);


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

SELECT salary FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.type = emp.type
);


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

SELECT code FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.level = mgr.level
);


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

SELECT name FROM accounts AS emp
WHERE salary > (
    SELECT MIN(value) FROM products AS inv
    WHERE inv.level = emp.level
);


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

SELECT name FROM warehouses AS mgr
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.status = mgr.status
);


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

SELECT id FROM warehouses AS ord
WHERE amount > (
    SELECT SUM(value) FROM tasks AS emp
    WHERE emp.code = ord.code
);


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

SELECT name FROM shipments AS budg
WHERE amount > (
    SELECT AVG(salary) FROM warehouses AS whs
    WHERE whs.type = budg.type
);


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

SELECT name FROM tasks AS srvc
WHERE type IN (
    SELECT type FROM categories AS sale
    WHERE sale.level = srvc.level
);


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

SELECT value FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.level = mgr.level
);


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

SELECT code FROM orders AS mgr
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS whs
    WHERE whs.level = mgr.level
);


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

SELECT amount FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.status = dept.status
);


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

SELECT name FROM orders AS emp
WHERE status IN (
    SELECT status FROM accounts AS schd
    WHERE schd.type = emp.type
);


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

SELECT code FROM branches AS catg
WHERE type IN (
    SELECT type FROM orders AS ord
    WHERE ord.id = catg.id
);


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

SELECT name FROM tasks AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS dept
    WHERE dept.level = schd.level
);


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

SELECT value FROM invoices AS schd
WHERE id IN (
    SELECT id FROM customers AS sale
    WHERE sale.code = schd.code
);


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

SELECT value FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.id = cust.id
);


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

SELECT name FROM departments AS prod
WHERE amount > (
    SELECT AVG(salary) FROM products AS lne
    WHERE lne.id = prod.id
);


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

SELECT name FROM shipments AS catg
WHERE id IN (
    SELECT id FROM regions AS txn
    WHERE txn.code = catg.code
);


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

SELECT value FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.level = prod.level
);


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

SELECT value FROM projects AS ordr
WHERE status IN (
    SELECT status FROM tasks AS cust
    WHERE cust.type = ordr.type
);


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

SELECT value FROM products AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS budg
    WHERE budg.status = schd.status
);


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

SELECT value FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.status = prod.status
);


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

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


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

SELECT id FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.type = mgr.type
);


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

SELECT value FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.code = cust.code
);


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

SELECT name FROM employees AS srvc
WHERE level IN (
    SELECT level FROM categories AS catg
    WHERE catg.level = srvc.level
);


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

SELECT salary FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.level = srvc.level
);


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

SELECT salary FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.level = emp.level
);


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

SELECT salary FROM invoices AS catg
WHERE code IN (
    SELECT code FROM employees AS inv
    WHERE inv.id = catg.id
);


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

SELECT salary FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.code = budg.code
);


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

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


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

SELECT id FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.id = schd.id
);


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

SELECT name FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.level = txn.level
);


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

SELECT name FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.code = rgn.code
);


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

SELECT name FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.status = mgr.status
);


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

SELECT amount FROM products AS prod
WHERE level IN (
    SELECT level FROM customers AS shp
    WHERE shp.id = prod.id
);


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

SELECT salary FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.level = dept.level
);


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

SELECT amount FROM projects AS shp
WHERE amount > (
    SELECT COUNT(value) FROM departments AS whs
    WHERE whs.type = shp.type
);


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

SELECT value FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT code FROM branches AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM products AS inv
    WHERE inv.level = sale.level
);


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

SELECT code FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.id = budg.id
);


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

SELECT code FROM shipments AS empl
WHERE amount > (
    SELECT AVG(value) FROM categories AS txn
    WHERE txn.code = empl.code
);


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

SELECT name FROM customers AS shp
WHERE code IN (
    SELECT code FROM orders AS acct
    WHERE acct.id = shp.id
);


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

SELECT id FROM transactions AS txn
WHERE salary > (
    SELECT AVG(amount) FROM orders AS whs
    WHERE whs.id = txn.id
);


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

SELECT salary FROM customers AS sale
WHERE value > (
    SELECT MIN(value) FROM departments AS inv
    WHERE inv.status = sale.status
);


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

SELECT amount FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.status = cust.status
);


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

SELECT name FROM invoices AS rgn
WHERE type IN (
    SELECT type FROM departments AS budg
    WHERE budg.type = rgn.type
);


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

SELECT name FROM projects AS rgn
WHERE type IN (
    SELECT type FROM products AS shp
    WHERE shp.status = rgn.status
);


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

SELECT code FROM regions AS prod
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS sale
    WHERE sale.code = prod.code
);


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

SELECT id FROM orders AS shp
WHERE id IN (
    SELECT id FROM regions AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT id FROM customers AS emp
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS budg
    WHERE budg.type = emp.type
);


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

SELECT amount FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT code FROM suppliers AS whs
WHERE status IN (
    SELECT status FROM departments AS mgr
    WHERE mgr.type = whs.type
);


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

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


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

SELECT id FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.level = lne.level
);


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

SELECT id FROM transactions AS txn
WHERE value > (
    SELECT COUNT(value) FROM invoices AS schd
    WHERE schd.id = txn.id
);


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

SELECT value FROM invoices AS schd
WHERE amount > (
    SELECT AVG(amount) FROM employees AS cust
    WHERE cust.type = schd.type
);


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

SELECT id FROM orders AS ord
WHERE id IN (
    SELECT id FROM customers AS schd
    WHERE schd.code = ord.code
);


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

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


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

SELECT name FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.id = whs.id
);


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

SELECT code FROM suppliers AS empl
WHERE value > (
    SELECT COUNT(value) FROM shipments AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT name FROM invoices AS shp
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.status = shp.status
);


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

SELECT code FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.level = rgn.level
);


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

SELECT code FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.type = shp.type
);


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

SELECT amount FROM products AS mgr
WHERE value > (
    SELECT MIN(value) FROM regions AS cust
    WHERE cust.code = mgr.code
);


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

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


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

SELECT amount FROM orders AS schd
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.status = schd.status
);


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

SELECT salary FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.code = txn.code
);


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

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


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

SELECT salary FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.type = lne.type
);


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

SELECT amount FROM categories AS acct
WHERE level IN (
    SELECT level FROM shipments AS dept
    WHERE dept.status = acct.status
);


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

SELECT value FROM invoices AS inv
WHERE type IN (
    SELECT type FROM customers AS catg
    WHERE catg.type = inv.type
);


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

SELECT id FROM invoices AS inv
WHERE type IN (
    SELECT type FROM projects AS schd
    WHERE schd.level = inv.level
);


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

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


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

SELECT id FROM warehouses AS mgr
WHERE type IN (
    SELECT type FROM projects AS sale
    WHERE sale.id = mgr.id
);


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

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


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

SELECT salary FROM orders AS budg
WHERE value > (
    SELECT MAX(amount) FROM projects AS shp
    WHERE shp.id = budg.id
);


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

SELECT name FROM employees AS acct
WHERE code IN (
    SELECT code FROM invoices AS ord
    WHERE ord.code = acct.code
);


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

SELECT amount FROM orders AS rgn
WHERE amount > (
    SELECT MIN(value) FROM regions AS acct
    WHERE acct.code = rgn.code
);


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

SELECT code FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = budg.status
);


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

SELECT value FROM branches AS inv
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT amount FROM suppliers AS budg
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS empl
    WHERE empl.code = budg.code
);


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

SELECT name FROM orders AS cust
WHERE level IN (
    SELECT level FROM regions AS txn
    WHERE txn.type = cust.type
);


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

SELECT amount FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.type = catg.type
);


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

SELECT value FROM orders AS acct
WHERE amount > (
    SELECT AVG(value) FROM categories AS dept
    WHERE dept.id = acct.id
);


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

SELECT salary FROM regions AS ordr
WHERE type IN (
    SELECT type FROM departments AS txn
    WHERE txn.level = ordr.level
);


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

SELECT value FROM suppliers AS catg
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS schd
    WHERE schd.id = catg.id
);


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

SELECT code FROM orders AS emp
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS shp
    WHERE shp.code = emp.code
);


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

SELECT salary FROM tasks AS rgn
WHERE salary > (
    SELECT MIN(value) FROM invoices AS sale
    WHERE sale.id = rgn.id
);


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

SELECT amount FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.id = cust.id
);


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

SELECT value FROM suppliers AS txn
WHERE amount > (
    SELECT SUM(salary) FROM products AS cust
    WHERE cust.type = txn.type
);


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

SELECT value FROM customers AS shp
WHERE level IN (
    SELECT level FROM regions AS empl
    WHERE empl.status = shp.status
);


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

SELECT value FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.code = budg.code
);


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

SELECT name FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.code = shp.code
);


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

SELECT name FROM suppliers AS srvc
WHERE salary > (
    SELECT MAX(amount) FROM employees AS shp
    WHERE shp.id = srvc.id
);


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

SELECT amount FROM employees AS dept
WHERE id IN (
    SELECT id FROM regions AS rgn
    WHERE rgn.type = dept.type
);


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

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


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

SELECT salary FROM orders AS schd
WHERE level IN (
    SELECT level FROM products AS emp
    WHERE emp.level = schd.level
);


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

SELECT name FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.level = mgr.level
);


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

SELECT name FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.code = empl.code
);


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

SELECT name FROM warehouses AS dept
WHERE level IN (
    SELECT level FROM accounts AS emp
    WHERE emp.type = dept.type
);


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

SELECT amount FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.type = emp.type
);


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

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


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

SELECT amount FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.id = txn.id
);


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

SELECT name FROM products AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT salary FROM departments AS ordr
WHERE status IN (
    SELECT status FROM products AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT value FROM regions AS shp
WHERE value > (
    SELECT COUNT(value) FROM tasks AS empl
    WHERE empl.type = shp.type
);


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

SELECT name FROM customers AS cust
WHERE level IN (
    SELECT level FROM orders AS inv
    WHERE inv.level = cust.level
);


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

SELECT id FROM departments AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS budg
    WHERE budg.code = mgr.code
);


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

SELECT name FROM suppliers AS txn
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.status = txn.status
);


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

SELECT value FROM shipments AS rgn
WHERE value > (
    SELECT MAX(salary) FROM categories AS schd
    WHERE schd.id = rgn.id
);


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

SELECT code FROM customers AS mgr
WHERE code IN (
    SELECT code FROM employees AS inv
    WHERE inv.code = mgr.code
);


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

SELECT value FROM regions AS sale
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.type = sale.type
);


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

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


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

SELECT amount FROM projects AS lne
WHERE level IN (
    SELECT level FROM warehouses AS sale
    WHERE sale.status = lne.status
);


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

SELECT name FROM customers AS dept
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.id = dept.id
);


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.type = ord.type
);


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

SELECT value FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = dept.status
);


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

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


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

SELECT name FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.status = empl.status
);


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

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


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

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


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

SELECT id FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = mgr.status
);


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

SELECT amount FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.type = prod.type
);


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

SELECT name FROM accounts AS ord
WHERE salary > (
    SELECT MAX(salary) FROM warehouses AS txn
    WHERE txn.level = ord.level
);


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

SELECT salary FROM warehouses AS schd
WHERE code IN (
    SELECT code FROM departments AS srvc
    WHERE srvc.type = schd.type
);


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

SELECT code FROM accounts AS acct
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT salary FROM invoices AS acct
WHERE level IN (
    SELECT level FROM employees AS lne
    WHERE lne.type = acct.type
);


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

SELECT amount FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.id = txn.id
);


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

SELECT value FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.status = mgr.status
);


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

SELECT amount FROM products AS srvc
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS lne
    WHERE lne.type = srvc.type
);


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

SELECT id FROM projects AS ordr
WHERE value > (
    SELECT AVG(amount) FROM departments AS emp
    WHERE emp.code = ordr.code
);


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

SELECT name FROM orders AS emp
WHERE salary > (
    SELECT COUNT(value) FROM projects AS cust
    WHERE cust.id = emp.id
);


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

SELECT code FROM categories AS rgn
WHERE status IN (
    SELECT status FROM branches AS whs
    WHERE whs.level = rgn.level
);


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

SELECT id FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT salary FROM departments AS inv
WHERE code IN (
    SELECT code FROM warehouses AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT value FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT name FROM suppliers AS srvc
WHERE value > (
    SELECT COUNT(amount) FROM customers AS empl
    WHERE empl.code = srvc.code
);


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

SELECT salary FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.status = txn.status
);


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

SELECT salary FROM branches AS budg
WHERE status IN (
    SELECT status FROM accounts AS prod
    WHERE prod.level = budg.level
);


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

SELECT value FROM projects AS mgr
WHERE value > (
    SELECT SUM(salary) FROM customers AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT amount FROM orders AS cust
WHERE salary > (
    SELECT MIN(value) FROM projects AS txn
    WHERE txn.type = cust.type
);


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

SELECT salary FROM regions AS catg
WHERE amount > (
    SELECT MAX(salary) FROM branches AS whs
    WHERE whs.status = catg.status
);


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

SELECT name FROM products AS prod
WHERE status IN (
    SELECT status FROM projects AS catg
    WHERE catg.type = prod.type
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.type = budg.type
);


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

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


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

SELECT id FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.level = sale.level
);


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

SELECT value FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.id = catg.id
);


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

SELECT amount FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.id = srvc.id
);


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

SELECT salary FROM branches AS dept
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS ord
    WHERE ord.type = dept.type
);


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

SELECT amount FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = lne.type
);


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

SELECT name FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.id = catg.id
);


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

SELECT code FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.code = inv.code
);


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

SELECT salary FROM suppliers AS budg
WHERE salary > (
    SELECT MIN(value) FROM shipments AS emp
    WHERE emp.code = budg.code
);


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

SELECT salary FROM accounts AS emp
WHERE type IN (
    SELECT type FROM suppliers AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT id FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.type = srvc.type
);


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

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


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

SELECT code FROM departments AS acct
WHERE code IN (
    SELECT code FROM tasks AS lne
    WHERE lne.level = acct.level
);


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

SELECT id FROM regions AS acct
WHERE type IN (
    SELECT type FROM shipments AS lne
    WHERE lne.type = acct.type
);


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

SELECT value FROM regions AS ordr
WHERE value > (
    SELECT MIN(salary) FROM accounts AS whs
    WHERE whs.type = ordr.type
);


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

SELECT code FROM shipments AS srvc
WHERE value > (
    SELECT AVG(value) FROM warehouses AS budg
    WHERE budg.code = srvc.code
);


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

SELECT value FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.type = ordr.type
);


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

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


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

SELECT amount FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.id = cust.id
);


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

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


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

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


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

SELECT id FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.id = shp.id
);


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

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


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

SELECT id FROM orders AS acct
WHERE type IN (
    SELECT type FROM suppliers AS schd
    WHERE schd.code = acct.code
);


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

SELECT salary FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.level = rgn.level
);


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

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


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

SELECT amount FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.level = whs.level
);


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

SELECT salary FROM transactions AS srvc
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS catg
    WHERE catg.type = srvc.type
);


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

SELECT salary FROM departments AS acct
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.level = acct.level
);


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

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


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

SELECT amount FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.id = sale.id
);


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

SELECT value FROM projects AS rgn
WHERE code IN (
    SELECT code FROM shipments AS acct
    WHERE acct.code = rgn.code
);


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

SELECT code FROM projects AS txn
WHERE id IN (
    SELECT id FROM suppliers AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT code FROM suppliers AS ord
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.status = ord.status
);


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

SELECT value FROM departments AS empl
WHERE value > (
    SELECT MIN(salary) FROM employees AS prod
    WHERE prod.status = empl.status
);


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

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


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

SELECT amount FROM warehouses AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM products AS budg
    WHERE budg.status = rgn.status
);


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

SELECT id FROM suppliers AS emp
WHERE code IN (
    SELECT code FROM departments AS ordr
    WHERE ordr.status = emp.status
);


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

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


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

SELECT value FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.status = rgn.status
);


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

SELECT name FROM categories AS cust
WHERE value > (
    SELECT COUNT(amount) FROM employees AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT value FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT value FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.code = rgn.code
);


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

SELECT value FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.type = cust.type
);


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

SELECT name FROM shipments AS mgr
WHERE amount > (
    SELECT MIN(value) FROM projects AS srvc
    WHERE srvc.id = mgr.id
);


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

SELECT salary FROM tasks AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM departments AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT value FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.status = lne.status
);


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

SELECT salary FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT salary FROM accounts AS catg
WHERE value > (
    SELECT SUM(salary) FROM regions AS cust
    WHERE cust.status = catg.status
);


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

SELECT amount FROM tasks AS srvc
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.type = srvc.type
);


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

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


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

SELECT amount FROM transactions AS txn
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.status = txn.status
);


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

SELECT name FROM accounts AS ord
WHERE amount > (
    SELECT SUM(salary) FROM orders AS budg
    WHERE budg.type = ord.type
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.level = ord.level
);


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

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS budg
    WHERE budg.id = ord.id
);


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

SELECT id FROM accounts AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS ord
    WHERE ord.id = schd.id
);


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

SELECT name FROM shipments AS whs
WHERE status IN (
    SELECT status FROM suppliers AS cust
    WHERE cust.level = whs.level
);


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

SELECT salary FROM orders AS schd
WHERE amount > (
    SELECT MAX(value) FROM employees AS inv
    WHERE inv.level = schd.level
);


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

SELECT code FROM tasks AS cust
WHERE amount > (
    SELECT AVG(value) FROM products AS lne
    WHERE lne.status = cust.status
);


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

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


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

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


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

SELECT id FROM projects AS shp
WHERE level IN (
    SELECT level FROM products AS ord
    WHERE ord.status = shp.status
);


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

SELECT amount FROM suppliers AS sale
WHERE amount > (
    SELECT AVG(value) FROM transactions AS catg
    WHERE catg.status = sale.status
);


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

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


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

SELECT salary FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.code = inv.code
);


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

SELECT value FROM warehouses AS acct
WHERE amount > (
    SELECT MIN(salary) FROM orders AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT id FROM departments AS inv
WHERE status IN (
    SELECT status FROM transactions AS txn
    WHERE txn.level = inv.level
);


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

SELECT code FROM warehouses AS emp
WHERE value > (
    SELECT SUM(value) FROM categories AS acct
    WHERE acct.type = emp.type
);


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

SELECT name FROM invoices AS acct
WHERE code IN (
    SELECT code FROM suppliers AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT amount FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.status = ord.status
);


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

SELECT salary FROM categories AS rgn
WHERE level IN (
    SELECT level FROM orders AS empl
    WHERE empl.status = rgn.status
);


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

SELECT id FROM suppliers AS txn
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS shp
    WHERE shp.id = txn.id
);


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

SELECT id FROM suppliers AS budg
WHERE code IN (
    SELECT code FROM accounts AS empl
    WHERE empl.level = budg.level
);


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

SELECT code FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.status = srvc.status
);


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

SELECT value FROM shipments AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS txn
    WHERE txn.id = whs.id
);


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

SELECT code FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.id = txn.id
);


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

SELECT salary FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.type = schd.type
);


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

SELECT name FROM branches AS dept
WHERE value > (
    SELECT MAX(value) FROM categories AS cust
    WHERE cust.id = dept.id
);


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

SELECT salary FROM regions AS budg
WHERE id IN (
    SELECT id FROM categories AS inv
    WHERE inv.code = budg.code
);


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.code = cust.code
);


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

SELECT salary FROM transactions AS inv
WHERE amount > (
    SELECT SUM(salary) FROM customers AS schd
    WHERE schd.code = inv.code
);


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

SELECT amount FROM branches AS catg
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT code FROM customers AS emp
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS rgn
    WHERE rgn.status = emp.status
);


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

SELECT name FROM orders AS empl
WHERE amount > (
    SELECT MIN(salary) FROM projects AS prod
    WHERE prod.id = empl.id
);


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

SELECT id FROM tasks AS lne
WHERE id IN (
    SELECT id FROM suppliers AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT value FROM projects AS budg
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.status = budg.status
);


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

SELECT name FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.level = acct.level
);


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

SELECT amount FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.level = shp.level
);


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

SELECT id FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.type = empl.type
);


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

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


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

SELECT salary FROM regions AS txn
WHERE id IN (
    SELECT id FROM invoices AS acct
    WHERE acct.code = txn.code
);


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

SELECT amount FROM accounts AS budg
WHERE value > (
    SELECT MAX(amount) FROM tasks AS whs
    WHERE whs.code = budg.code
);


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

SELECT value FROM tasks AS shp
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS schd
    WHERE schd.type = shp.type
);


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

SELECT value FROM invoices AS budg
WHERE type IN (
    SELECT type FROM projects AS shp
    WHERE shp.id = budg.id
);


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

SELECT name FROM regions AS sale
WHERE type IN (
    SELECT type FROM accounts AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT value FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.id = srvc.id
);


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

SELECT id FROM customers AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM regions AS inv
    WHERE inv.level = rgn.level
);


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

SELECT name FROM regions AS txn
WHERE id IN (
    SELECT id FROM employees AS ord
    WHERE ord.type = txn.type
);


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

SELECT code FROM products AS ord
WHERE level IN (
    SELECT level FROM departments AS acct
    WHERE acct.status = ord.status
);


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

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


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

SELECT amount FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM suppliers AS txn
    WHERE txn.type = whs.type
);


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

SELECT amount FROM departments AS mgr
WHERE value > (
    SELECT AVG(amount) FROM regions AS budg
    WHERE budg.type = mgr.type
);


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

SELECT id FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = emp.type
);


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

SELECT amount FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.level = rgn.level
);


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

SELECT amount FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.code = empl.code
);


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

SELECT value FROM orders AS txn
WHERE value > (
    SELECT MIN(value) FROM tasks AS acct
    WHERE acct.type = txn.type
);


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

SELECT amount FROM categories AS rgn
WHERE status IN (
    SELECT status FROM transactions AS lne
    WHERE lne.status = rgn.status
);


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

SELECT value FROM orders AS txn
WHERE value > (
    SELECT MIN(amount) FROM products AS emp
    WHERE emp.type = txn.type
);


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

SELECT amount FROM regions AS sale
WHERE status IN (
    SELECT status FROM customers AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT id FROM departments AS catg
WHERE level IN (
    SELECT level FROM transactions AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT value FROM invoices AS lne
WHERE value > (
    SELECT MIN(amount) FROM tasks AS rgn
    WHERE rgn.code = lne.code
);


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

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


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

SELECT salary FROM warehouses AS inv
WHERE code IN (
    SELECT code FROM orders AS srvc
    WHERE srvc.id = inv.id
);


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

SELECT name FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT salary FROM regions AS ord
WHERE id IN (
    SELECT id FROM orders AS catg
    WHERE catg.id = ord.id
);


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

SELECT amount FROM invoices AS budg
WHERE salary > (
    SELECT AVG(value) FROM orders AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT amount FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT code FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.code = shp.code
);


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

SELECT value FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.status = srvc.status
);


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

SELECT id FROM warehouses AS acct
WHERE value > (
    SELECT COUNT(value) FROM projects AS catg
    WHERE catg.id = acct.id
);


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

SELECT value FROM accounts AS inv
WHERE code IN (
    SELECT code FROM employees AS txn
    WHERE txn.type = inv.type
);