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

SELECT value FROM orders AS empl
WHERE level IN (
    SELECT level FROM categories AS inv
    WHERE inv.type = empl.type
);


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

SELECT name FROM employees AS dept
WHERE salary > (
    SELECT MAX(amount) FROM customers AS shp
    WHERE shp.type = dept.type
);


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

SELECT salary FROM products AS shp
WHERE id IN (
    SELECT id FROM employees AS acct
    WHERE acct.type = shp.type
);


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

SELECT id FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.level = sale.level
);


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

SELECT code FROM orders AS ordr
WHERE id IN (
    SELECT id FROM shipments AS catg
    WHERE catg.status = ordr.status
);


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

SELECT amount FROM shipments AS sale
WHERE id IN (
    SELECT id FROM categories AS empl
    WHERE empl.code = sale.code
);


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

SELECT id FROM suppliers AS txn
WHERE salary > (
    SELECT AVG(amount) FROM employees AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT salary FROM categories AS catg
WHERE amount > (
    SELECT MIN(salary) FROM regions AS shp
    WHERE shp.status = catg.status
);


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

SELECT salary FROM transactions AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM employees AS emp
    WHERE emp.type = ordr.type
);


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

SELECT value FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.type = mgr.type
);


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

SELECT value FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = empl.status
);


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

SELECT amount FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.id = schd.id
);


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

SELECT id FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.level = sale.level
);


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

SELECT name FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.status = whs.status
);


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

SELECT id FROM projects AS dept
WHERE salary > (
    SELECT SUM(amount) FROM orders AS txn
    WHERE txn.status = dept.status
);


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

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


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

SELECT salary FROM projects AS mgr
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS shp
    WHERE shp.level = mgr.level
);


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

SELECT value FROM customers AS dept
WHERE level IN (
    SELECT level FROM invoices AS budg
    WHERE budg.type = dept.type
);


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

SELECT id FROM regions AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS txn
    WHERE txn.code = ord.code
);


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

SELECT name FROM customers AS sale
WHERE code IN (
    SELECT code FROM orders AS budg
    WHERE budg.type = sale.type
);


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

SELECT value FROM projects AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS inv
    WHERE inv.level = shp.level
);


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

SELECT code FROM branches AS schd
WHERE code IN (
    SELECT code FROM customers AS inv
    WHERE inv.status = schd.status
);


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

SELECT name FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.id = dept.id
);


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

SELECT id FROM departments AS budg
WHERE level IN (
    SELECT level FROM employees AS prod
    WHERE prod.id = budg.id
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.level = emp.level
);


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

SELECT value FROM suppliers AS sale
WHERE amount > (
    SELECT SUM(salary) FROM employees AS dept
    WHERE dept.id = sale.id
);


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

SELECT value FROM shipments AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT code FROM shipments AS ordr
WHERE status IN (
    SELECT status FROM accounts AS ord
    WHERE ord.status = ordr.status
);


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

SELECT value FROM categories AS mgr
WHERE level IN (
    SELECT level FROM employees AS sale
    WHERE sale.level = mgr.level
);


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

SELECT value FROM tasks AS rgn
WHERE code IN (
    SELECT code FROM employees AS sale
    WHERE sale.id = rgn.id
);


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

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


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

SELECT amount FROM transactions AS ordr
WHERE amount > (
    SELECT MIN(value) FROM employees AS schd
    WHERE schd.status = ordr.status
);


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

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


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

SELECT value FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.code = ordr.code
);


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

SELECT id FROM branches AS budg
WHERE id IN (
    SELECT id FROM categories AS shp
    WHERE shp.level = budg.level
);


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

SELECT code FROM accounts AS dept
WHERE level IN (
    SELECT level FROM tasks AS empl
    WHERE empl.type = dept.type
);


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

SELECT code FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.level = ord.level
);


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

SELECT value FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.status = budg.status
);


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

SELECT code FROM employees AS rgn
WHERE value > (
    SELECT COUNT(value) FROM invoices AS emp
    WHERE emp.type = rgn.type
);


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

SELECT code FROM categories AS acct
WHERE code IN (
    SELECT code FROM shipments AS empl
    WHERE empl.status = acct.status
);


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

SELECT code FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.id = emp.id
);


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.status = acct.status
);


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

SELECT amount FROM products AS whs
WHERE id IN (
    SELECT id FROM invoices AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT name FROM shipments AS emp
WHERE level IN (
    SELECT level FROM branches AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT salary FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.type = mgr.type
);


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

SELECT code FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT salary FROM suppliers AS cust
WHERE level IN (
    SELECT level FROM departments AS ord
    WHERE ord.type = cust.type
);


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

SELECT amount FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.code = inv.code
);


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

SELECT salary FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.status = shp.status
);


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

SELECT name FROM accounts AS inv
WHERE status IN (
    SELECT status FROM categories AS lne
    WHERE lne.level = inv.level
);


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

SELECT value FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.level = prod.level
);


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

SELECT code FROM departments AS txn
WHERE level IN (
    SELECT level FROM accounts AS shp
    WHERE shp.status = txn.status
);


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

SELECT id FROM employees AS shp
WHERE salary > (
    SELECT AVG(value) FROM projects AS whs
    WHERE whs.code = shp.code
);


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

SELECT id FROM products AS acct
WHERE salary > (
    SELECT AVG(salary) FROM branches AS srvc
    WHERE srvc.id = acct.id
);


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

SELECT value FROM orders AS sale
WHERE code IN (
    SELECT code FROM branches AS budg
    WHERE budg.status = sale.status
);


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

SELECT amount FROM branches AS txn
WHERE level IN (
    SELECT level FROM suppliers AS shp
    WHERE shp.status = txn.status
);


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

SELECT salary FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = empl.status
);


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

SELECT amount FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.status = inv.status
);


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

SELECT value FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = emp.level
);


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

SELECT value FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.type = cust.type
);


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

SELECT amount FROM projects AS budg
WHERE value > (
    SELECT COUNT(salary) FROM categories AS empl
    WHERE empl.code = budg.code
);


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

SELECT code FROM departments AS cust
WHERE code IN (
    SELECT code FROM products AS mgr
    WHERE mgr.code = cust.code
);


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

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


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

SELECT value FROM regions AS prod
WHERE id IN (
    SELECT id FROM products AS ordr
    WHERE ordr.code = prod.code
);


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

SELECT code FROM shipments AS mgr
WHERE id IN (
    SELECT id FROM projects AS txn
    WHERE txn.id = mgr.id
);


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

SELECT code FROM tasks AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT id FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = dept.level
);


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

SELECT value FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.code = mgr.code
);


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

SELECT id FROM employees AS acct
WHERE amount > (
    SELECT MIN(salary) FROM orders AS cust
    WHERE cust.type = acct.type
);


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

SELECT salary FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.code = acct.code
);


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

SELECT amount FROM departments AS lne
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS emp
    WHERE emp.code = lne.code
);


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

SELECT name FROM employees AS catg
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS sale
    WHERE sale.level = catg.level
);


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

SELECT salary FROM products AS schd
WHERE level IN (
    SELECT level FROM shipments AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT amount FROM projects AS prod
WHERE id IN (
    SELECT id FROM departments AS emp
    WHERE emp.level = prod.level
);


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

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


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

SELECT salary FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.code = rgn.code
);


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

SELECT salary FROM customers AS ordr
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS inv
    WHERE inv.code = ordr.code
);


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

SELECT code FROM regions AS emp
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS sale
    WHERE sale.type = emp.type
);


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

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


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

SELECT name FROM regions AS empl
WHERE code IN (
    SELECT code FROM tasks AS whs
    WHERE whs.status = empl.status
);


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

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


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

SELECT amount FROM warehouses AS catg
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS dept
    WHERE dept.status = catg.status
);


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

SELECT value FROM suppliers AS lne
WHERE status IN (
    SELECT status FROM employees AS txn
    WHERE txn.type = lne.type
);


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

SELECT code FROM transactions AS lne
WHERE type IN (
    SELECT type FROM customers AS dept
    WHERE dept.type = lne.type
);


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

SELECT name FROM departments AS mgr
WHERE value > (
    SELECT MAX(salary) FROM customers AS empl
    WHERE empl.status = mgr.status
);


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

SELECT amount FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.id = ordr.id
);


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

SELECT id FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.status = ordr.status
);


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

SELECT salary FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.level = prod.level
);


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

SELECT name FROM branches AS srvc
WHERE id IN (
    SELECT id FROM transactions AS prod
    WHERE prod.id = srvc.id
);


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

SELECT salary FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT salary FROM employees AS empl
WHERE id IN (
    SELECT id FROM orders AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT amount FROM customers AS whs
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.level = whs.level
);


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

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


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

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


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

SELECT amount FROM shipments AS acct
WHERE status IN (
    SELECT status FROM categories AS prod
    WHERE prod.id = acct.id
);


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

SELECT value FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.status = srvc.status
);


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

SELECT code FROM products AS catg
WHERE value > (
    SELECT COUNT(value) FROM warehouses AS budg
    WHERE budg.id = catg.id
);


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

SELECT name FROM categories AS rgn
WHERE id IN (
    SELECT id FROM departments AS catg
    WHERE catg.id = rgn.id
);


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

SELECT code FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.code = mgr.code
);


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

SELECT id FROM branches AS lne
WHERE value > (
    SELECT COUNT(value) FROM shipments AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT id FROM tasks AS rgn
WHERE code IN (
    SELECT code FROM shipments AS acct
    WHERE acct.id = rgn.id
);


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

SELECT salary FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = dept.status
);


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

SELECT code FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.status = txn.status
);


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

SELECT id FROM orders AS sale
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS budg
    WHERE budg.code = sale.code
);


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

SELECT code FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.type = lne.type
);


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

SELECT id FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.level = sale.level
);


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

SELECT salary FROM accounts AS inv
WHERE salary > (
    SELECT COUNT(value) FROM regions AS ordr
    WHERE ordr.status = inv.status
);


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

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


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

SELECT id FROM warehouses AS whs
WHERE amount > (
    SELECT AVG(value) FROM employees AS lne
    WHERE lne.type = whs.type
);


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

SELECT name FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT id FROM shipments AS catg
WHERE code IN (
    SELECT code FROM tasks AS ord
    WHERE ord.id = catg.id
);


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

SELECT code FROM suppliers AS srvc
WHERE value > (
    SELECT COUNT(value) FROM customers AS cust
    WHERE cust.id = srvc.id
);


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

SELECT amount FROM suppliers AS ordr
WHERE id IN (
    SELECT id FROM accounts AS whs
    WHERE whs.code = ordr.code
);


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

SELECT value FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = empl.code
);


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

SELECT name FROM regions AS shp
WHERE id IN (
    SELECT id FROM suppliers AS srvc
    WHERE srvc.status = shp.status
);


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

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


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

SELECT id FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.status = ordr.status
);


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

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


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

SELECT value FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.status = sale.status
);


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

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


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

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


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

SELECT salary FROM departments AS rgn
WHERE type IN (
    SELECT type FROM branches AS mgr
    WHERE mgr.id = rgn.id
);


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

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


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

SELECT salary FROM transactions AS sale
WHERE level IN (
    SELECT level FROM projects AS shp
    WHERE shp.status = sale.status
);


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

SELECT name FROM shipments AS catg
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.code = catg.code
);


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

SELECT code FROM branches AS catg
WHERE value > (
    SELECT MIN(value) FROM orders AS lne
    WHERE lne.code = catg.code
);


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

SELECT amount FROM products AS empl
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS dept
    WHERE dept.id = empl.id
);


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

SELECT salary FROM transactions AS ord
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT salary FROM warehouses AS budg
WHERE status IN (
    SELECT status FROM shipments AS lne
    WHERE lne.status = budg.status
);


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

SELECT id FROM transactions AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM suppliers AS catg
    WHERE catg.type = srvc.type
);


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

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


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

SELECT salary FROM departments AS cust
WHERE status IN (
    SELECT status FROM employees AS whs
    WHERE whs.type = cust.type
);


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

SELECT code FROM regions AS lne
WHERE code IN (
    SELECT code FROM departments AS sale
    WHERE sale.level = lne.level
);


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

SELECT name FROM orders AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM warehouses AS ordr
    WHERE ordr.level = schd.level
);


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

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


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

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT COUNT(salary) FROM shipments AS budg
    WHERE budg.type = dept.type
);


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

SELECT code FROM shipments AS srvc
WHERE salary > (
    SELECT SUM(amount) FROM employees AS sale
    WHERE sale.type = srvc.type
);


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

SELECT value FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.level = txn.level
);


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

SELECT salary FROM projects AS emp
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS prod
    WHERE prod.level = emp.level
);


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

SELECT code FROM regions AS mgr
WHERE salary > (
    SELECT MIN(amount) FROM departments AS rgn
    WHERE rgn.level = mgr.level
);


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

SELECT salary FROM invoices AS lne
WHERE value > (
    SELECT MAX(salary) FROM regions AS ord
    WHERE ord.type = lne.type
);


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

SELECT amount FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.level = ord.level
);


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

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


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

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


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

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


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

SELECT salary FROM employees AS budg
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.code = budg.code
);


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

SELECT id FROM customers AS prod
WHERE type IN (
    SELECT type FROM products AS txn
    WHERE txn.status = prod.status
);


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

SELECT value FROM transactions AS ord
WHERE code IN (
    SELECT code FROM invoices AS sale
    WHERE sale.type = ord.type
);


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

SELECT value FROM accounts AS sale
WHERE type IN (
    SELECT type FROM projects AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT name FROM regions AS shp
WHERE id IN (
    SELECT id FROM departments AS emp
    WHERE emp.type = shp.type
);


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

SELECT id FROM projects AS dept
WHERE id IN (
    SELECT id FROM warehouses AS empl
    WHERE empl.code = dept.code
);


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

SELECT id FROM accounts AS ord
WHERE level IN (
    SELECT level FROM products AS schd
    WHERE schd.code = ord.code
);


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

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


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

SELECT value FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.code = shp.code
);


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

SELECT value FROM customers AS ord
WHERE amount > (
    SELECT AVG(value) FROM invoices AS cust
    WHERE cust.id = ord.id
);


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

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


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

SELECT salary FROM categories AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS rgn
    WHERE rgn.id = catg.id
);


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

SELECT id FROM regions AS budg
WHERE id IN (
    SELECT id FROM departments AS empl
    WHERE empl.code = budg.code
);


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

SELECT value FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.type = prod.type
);


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

SELECT value FROM shipments AS prod
WHERE value > (
    SELECT MIN(amount) FROM tasks AS cust
    WHERE cust.type = prod.type
);


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

SELECT name FROM regions AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT name FROM transactions AS catg
WHERE amount > (
    SELECT COUNT(value) FROM orders AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT name FROM products AS catg
WHERE id IN (
    SELECT id FROM categories AS schd
    WHERE schd.id = catg.id
);


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

SELECT name FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.code = inv.code
);


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

SELECT code FROM accounts AS empl
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS schd
    WHERE schd.id = empl.id
);


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

SELECT value FROM invoices AS cust
WHERE amount > (
    SELECT MIN(value) FROM branches AS prod
    WHERE prod.status = cust.status
);


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

SELECT code FROM accounts AS dept
WHERE type IN (
    SELECT type FROM departments AS sale
    WHERE sale.status = dept.status
);


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

SELECT code FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT id FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.code = prod.code
);


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

SELECT code FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.type = whs.type
);


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

SELECT id FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.status = catg.status
);


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

SELECT name FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.code = dept.code
);


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

SELECT id FROM customers AS acct
WHERE id IN (
    SELECT id FROM categories AS cust
    WHERE cust.status = acct.status
);


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

SELECT name FROM accounts AS mgr
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS catg
    WHERE catg.status = mgr.status
);


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

SELECT name FROM invoices AS prod
WHERE level IN (
    SELECT level FROM warehouses AS lne
    WHERE lne.id = prod.id
);


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

SELECT amount FROM warehouses AS acct
WHERE type IN (
    SELECT type FROM invoices AS schd
    WHERE schd.id = acct.id
);


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

SELECT amount FROM employees AS budg
WHERE value > (
    SELECT COUNT(salary) FROM projects AS dept
    WHERE dept.code = budg.code
);


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

SELECT name FROM branches AS prod
WHERE status IN (
    SELECT status FROM departments AS budg
    WHERE budg.id = prod.id
);


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

SELECT value FROM tasks AS cust
WHERE level IN (
    SELECT level FROM accounts AS srvc
    WHERE srvc.level = cust.level
);


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

SELECT id FROM suppliers AS inv
WHERE salary > (
    SELECT MAX(value) FROM projects AS emp
    WHERE emp.level = inv.level
);


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

SELECT name FROM transactions AS lne
WHERE status IN (
    SELECT status FROM regions AS emp
    WHERE emp.type = lne.type
);


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

SELECT id FROM employees AS emp
WHERE type IN (
    SELECT type FROM shipments AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT id FROM branches AS prod
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT salary FROM transactions AS srvc
WHERE salary > (
    SELECT AVG(amount) FROM employees AS rgn
    WHERE rgn.status = srvc.status
);


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

SELECT amount FROM employees AS ordr
WHERE type IN (
    SELECT type FROM accounts AS emp
    WHERE emp.level = ordr.level
);


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

SELECT amount FROM shipments AS cust
WHERE amount > (
    SELECT MIN(amount) FROM customers AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT salary FROM categories AS empl
WHERE value > (
    SELECT MAX(salary) FROM branches AS prod
    WHERE prod.status = empl.status
);


Prompt:
Schema:
  invoices (alias: mgr)(salary, status, date, type)
  projects(id, salary, status, type)
Task: Retrieve salary from invoices with amount above the MAX(amount) of projects rows sharing the same level.
SQL:

SELECT salary FROM invoices AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM projects AS srvc
    WHERE srvc.level = mgr.level
);


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

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


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

SELECT id FROM transactions AS acct
WHERE amount > (
    SELECT SUM(value) FROM branches AS ordr
    WHERE ordr.level = acct.level
);


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

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


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

SELECT value FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.id = acct.id
);


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

SELECT amount FROM branches AS acct
WHERE level IN (
    SELECT level FROM tasks AS dept
    WHERE dept.type = acct.type
);


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

SELECT value FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.code = prod.code
);


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

SELECT id FROM departments AS acct
WHERE type IN (
    SELECT type FROM regions AS ord
    WHERE ord.id = acct.id
);


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

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


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

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


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

SELECT salary FROM customers AS budg
WHERE level IN (
    SELECT level FROM tasks AS dept
    WHERE dept.code = budg.code
);


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

SELECT value FROM warehouses AS prod
WHERE salary > (
    SELECT SUM(amount) FROM categories AS acct
    WHERE acct.type = prod.type
);


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

SELECT amount FROM regions AS cust
WHERE salary > (
    SELECT SUM(value) FROM departments AS emp
    WHERE emp.code = cust.code
);


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

SELECT name FROM warehouses AS dept
WHERE value > (
    SELECT AVG(value) FROM transactions AS empl
    WHERE empl.type = dept.type
);


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

SELECT amount FROM products AS emp
WHERE type IN (
    SELECT type FROM customers AS ord
    WHERE ord.code = emp.code
);


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

SELECT id FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT id FROM employees AS empl
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.level = empl.level
);


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

SELECT name FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.level = catg.level
);


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

SELECT salary FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.status = schd.status
);


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

SELECT value FROM tasks AS ord
WHERE code IN (
    SELECT code FROM customers AS whs
    WHERE whs.type = ord.type
);


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

SELECT value FROM accounts AS emp
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS srvc
    WHERE srvc.level = emp.level
);


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

SELECT name FROM branches AS dept
WHERE code IN (
    SELECT code FROM suppliers AS empl
    WHERE empl.status = dept.status
);


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

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


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

SELECT salary FROM customers AS emp
WHERE code IN (
    SELECT code FROM products AS budg
    WHERE budg.status = emp.status
);


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

SELECT amount FROM orders AS srvc
WHERE level IN (
    SELECT level FROM products AS catg
    WHERE catg.type = srvc.type
);


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

SELECT value FROM orders AS sale
WHERE id IN (
    SELECT id FROM employees AS cust
    WHERE cust.id = sale.id
);


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

SELECT name FROM transactions AS prod
WHERE status IN (
    SELECT status FROM departments AS ord
    WHERE ord.id = prod.id
);


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

SELECT value FROM products AS shp
WHERE value > (
    SELECT MAX(amount) FROM warehouses AS schd
    WHERE schd.type = shp.type
);


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

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


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

SELECT name FROM warehouses AS acct
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT code FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.id = ord.id
);


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

SELECT salary FROM branches AS rgn
WHERE status IN (
    SELECT status FROM projects AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT amount FROM customers AS srvc
WHERE type IN (
    SELECT type FROM branches AS txn
    WHERE txn.status = srvc.status
);


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

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


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

SELECT name FROM accounts AS catg
WHERE type IN (
    SELECT type FROM employees AS prod
    WHERE prod.level = catg.level
);


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

SELECT code FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = ordr.status
);


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

SELECT value FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = sale.level
);


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

SELECT name FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = whs.id
);


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

SELECT name FROM orders AS emp
WHERE amount > (
    SELECT AVG(amount) FROM categories AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT code FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.id = budg.id
);


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

SELECT name FROM tasks AS budg
WHERE status IN (
    SELECT status FROM departments AS srvc
    WHERE srvc.id = budg.id
);


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

SELECT value FROM tasks AS schd
WHERE level IN (
    SELECT level FROM transactions AS acct
    WHERE acct.level = schd.level
);


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

SELECT amount FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.status = budg.status
);


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

SELECT salary FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.level = budg.level
);


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

SELECT salary FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.type = ordr.type
);


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

SELECT salary FROM shipments AS catg
WHERE value > (
    SELECT MAX(value) FROM orders AS inv
    WHERE inv.status = catg.status
);


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

SELECT code FROM invoices AS txn
WHERE status IN (
    SELECT status FROM suppliers AS ordr
    WHERE ordr.type = txn.type
);


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

SELECT salary FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.level = sale.level
);


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

SELECT name FROM orders AS acct
WHERE level IN (
    SELECT level FROM products AS shp
    WHERE shp.id = acct.id
);


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

SELECT amount FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT value FROM departments AS ordr
WHERE salary > (
    SELECT COUNT(amount) FROM warehouses AS acct
    WHERE acct.id = ordr.id
);


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

SELECT name FROM categories AS srvc
WHERE salary > (
    SELECT SUM(value) FROM employees AS whs
    WHERE whs.status = srvc.status
);


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

SELECT name FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = acct.level
);


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

SELECT name FROM employees AS budg
WHERE salary > (
    SELECT MIN(value) FROM departments AS empl
    WHERE empl.type = budg.type
);


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

SELECT name FROM invoices AS txn
WHERE id IN (
    SELECT id FROM shipments AS shp
    WHERE shp.type = txn.type
);


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

SELECT salary FROM categories AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS acct
    WHERE acct.id = shp.id
);


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

SELECT code FROM orders AS sale
WHERE id IN (
    SELECT id FROM departments AS txn
    WHERE txn.level = sale.level
);


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

SELECT value FROM customers AS txn
WHERE status IN (
    SELECT status FROM transactions AS cust
    WHERE cust.type = txn.type
);


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

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


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

SELECT value FROM suppliers AS cust
WHERE amount > (
    SELECT MIN(amount) FROM employees AS catg
    WHERE catg.id = cust.id
);


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

SELECT code FROM departments AS srvc
WHERE value > (
    SELECT COUNT(amount) FROM products AS cust
    WHERE cust.type = srvc.type
);


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

SELECT salary FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.type = rgn.type
);


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

SELECT salary FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = cust.id
);


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

SELECT amount FROM regions AS acct
WHERE status IN (
    SELECT status FROM tasks AS inv
    WHERE inv.id = acct.id
);


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

SELECT value FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.status = budg.status
);


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

SELECT id FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT name FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT salary FROM tasks AS inv
WHERE amount > (
    SELECT SUM(salary) FROM customers AS ord
    WHERE ord.status = inv.status
);


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

SELECT id FROM suppliers AS schd
WHERE value > (
    SELECT AVG(amount) FROM accounts AS ordr
    WHERE ordr.level = schd.level
);


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

SELECT amount FROM invoices AS sale
WHERE salary > (
    SELECT MIN(salary) FROM categories AS inv
    WHERE inv.status = sale.status
);


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

SELECT name FROM employees AS txn
WHERE salary > (
    SELECT AVG(salary) FROM shipments AS dept
    WHERE dept.level = txn.level
);


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

SELECT id FROM tasks AS acct
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT code FROM warehouses AS srvc
WHERE type IN (
    SELECT type FROM accounts AS acct
    WHERE acct.status = srvc.status
);


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

SELECT salary FROM categories AS lne
WHERE amount > (
    SELECT SUM(amount) FROM customers AS whs
    WHERE whs.code = lne.code
);


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

SELECT name FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.type = shp.type
);


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

SELECT value FROM shipments AS mgr
WHERE type IN (
    SELECT type FROM employees AS empl
    WHERE empl.level = mgr.level
);


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

SELECT salary FROM shipments AS prod
WHERE level IN (
    SELECT level FROM employees AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT id FROM branches AS sale
WHERE amount > (
    SELECT AVG(value) FROM accounts AS lne
    WHERE lne.status = sale.status
);


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

SELECT id FROM tasks AS prod
WHERE value > (
    SELECT AVG(value) FROM regions AS ord
    WHERE ord.status = prod.status
);


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

SELECT salary FROM departments AS budg
WHERE id IN (
    SELECT id FROM transactions AS emp
    WHERE emp.level = budg.level
);


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

SELECT id FROM departments AS txn
WHERE id IN (
    SELECT id FROM invoices AS schd
    WHERE schd.type = txn.type
);


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

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


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

SELECT value FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT amount FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.type = inv.type
);


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

SELECT code FROM customers AS sale
WHERE id IN (
    SELECT id FROM categories AS empl
    WHERE empl.status = sale.status
);


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

SELECT value FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.code = prod.code
);


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

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


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

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


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

SELECT value FROM customers AS dept
WHERE id IN (
    SELECT id FROM categories AS rgn
    WHERE rgn.id = dept.id
);


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

SELECT amount FROM tasks AS shp
WHERE value > (
    SELECT COUNT(value) FROM customers AS schd
    WHERE schd.level = shp.level
);


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

SELECT amount FROM transactions AS whs
WHERE code IN (
    SELECT code FROM orders AS sale
    WHERE sale.status = whs.status
);


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

SELECT name FROM invoices AS srvc
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS ord
    WHERE ord.code = srvc.code
);


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

SELECT name FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.id = dept.id
);


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

SELECT name FROM accounts AS rgn
WHERE type IN (
    SELECT type FROM orders AS prod
    WHERE prod.id = rgn.id
);


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

SELECT amount FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.code = sale.code
);


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

SELECT salary FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT amount FROM orders AS dept
WHERE id IN (
    SELECT id FROM projects AS cust
    WHERE cust.code = dept.code
);


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

SELECT salary FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.code = shp.code
);


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

SELECT id FROM transactions AS inv
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS sale
    WHERE sale.type = inv.type
);


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

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


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

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


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

SELECT value FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.type = sale.type
);


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

SELECT name FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = acct.id
);


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

SELECT value FROM shipments AS schd
WHERE code IN (
    SELECT code FROM departments AS catg
    WHERE catg.id = schd.id
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.status = whs.status
);


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

SELECT id FROM warehouses AS prod
WHERE status IN (
    SELECT status FROM accounts AS lne
    WHERE lne.type = prod.type
);