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

SELECT name FROM regions AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM accounts AS shp
    WHERE shp.id = ordr.id
);


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

SELECT id FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.code = ord.code
);


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

SELECT salary FROM tasks AS dept
WHERE id IN (
    SELECT id FROM suppliers AS lne
    WHERE lne.code = dept.code
);


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

SELECT salary FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT code FROM warehouses AS shp
WHERE id IN (
    SELECT id FROM branches AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT id FROM employees AS whs
WHERE salary > (
    SELECT SUM(amount) FROM products AS empl
    WHERE empl.id = whs.id
);


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

SELECT code FROM regions AS txn
WHERE value > (
    SELECT MAX(salary) FROM products AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT name FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.type = lne.type
);


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

SELECT name FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.status = acct.status
);


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

SELECT value FROM orders AS ord
WHERE type IN (
    SELECT type FROM shipments AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT amount FROM projects AS dept
WHERE salary > (
    SELECT COUNT(amount) FROM transactions AS budg
    WHERE budg.id = dept.id
);


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

SELECT value FROM suppliers AS emp
WHERE status IN (
    SELECT status FROM orders AS cust
    WHERE cust.id = emp.id
);


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

SELECT amount FROM accounts AS whs
WHERE value > (
    SELECT AVG(amount) FROM products AS acct
    WHERE acct.type = whs.type
);


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

SELECT name FROM departments AS whs
WHERE salary > (
    SELECT COUNT(value) FROM branches AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT amount FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.type = ordr.type
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.type = emp.type
);


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

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


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

SELECT name FROM employees AS sale
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT id FROM invoices AS catg
WHERE value > (
    SELECT COUNT(value) FROM orders AS emp
    WHERE emp.type = catg.type
);


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

SELECT code FROM shipments AS acct
WHERE code IN (
    SELECT code FROM branches AS sale
    WHERE sale.id = acct.id
);


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

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


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

SELECT value FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.id = lne.id
);


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

SELECT value FROM projects AS rgn
WHERE value > (
    SELECT COUNT(value) FROM invoices AS sale
    WHERE sale.type = rgn.type
);


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

SELECT salary FROM warehouses AS lne
WHERE status IN (
    SELECT status FROM transactions AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT id FROM accounts AS srvc
WHERE status IN (
    SELECT status FROM orders AS schd
    WHERE schd.status = srvc.status
);


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

SELECT code FROM regions AS prod
WHERE type IN (
    SELECT type FROM employees AS budg
    WHERE budg.code = prod.code
);


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

SELECT value FROM transactions AS cust
WHERE level IN (
    SELECT level FROM categories AS rgn
    WHERE rgn.code = cust.code
);


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

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


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

SELECT code FROM employees AS catg
WHERE value > (
    SELECT MAX(salary) FROM departments AS sale
    WHERE sale.type = catg.type
);


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

SELECT salary FROM employees AS inv
WHERE amount > (
    SELECT MAX(value) FROM tasks AS txn
    WHERE txn.id = inv.id
);


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

SELECT id FROM customers AS srvc
WHERE amount > (
    SELECT MAX(salary) FROM regions AS mgr
    WHERE mgr.id = srvc.id
);


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

SELECT amount FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.level = whs.level
);


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

SELECT code FROM orders AS lne
WHERE id IN (
    SELECT id FROM projects AS txn
    WHERE txn.level = lne.level
);


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

SELECT name FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.status = ord.status
);


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

SELECT id FROM tasks AS ord
WHERE type IN (
    SELECT type FROM orders AS prod
    WHERE prod.status = ord.status
);


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

SELECT name FROM accounts AS dept
WHERE code IN (
    SELECT code FROM shipments AS budg
    WHERE budg.code = dept.code
);


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

SELECT salary FROM invoices AS empl
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.id = empl.id
);


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

SELECT salary FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.code = ord.code
);


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

SELECT value FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.level = txn.level
);


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

SELECT code FROM shipments AS budg
WHERE level IN (
    SELECT level FROM branches AS dept
    WHERE dept.id = budg.id
);


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

SELECT id FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.id = srvc.id
);


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

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


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

SELECT salary FROM products AS srvc
WHERE id IN (
    SELECT id FROM branches AS sale
    WHERE sale.level = srvc.level
);


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

SELECT amount FROM shipments AS cust
WHERE value > (
    SELECT SUM(amount) FROM regions AS sale
    WHERE sale.id = cust.id
);


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

SELECT value FROM projects AS cust
WHERE type IN (
    SELECT type FROM categories AS empl
    WHERE empl.type = cust.type
);


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

SELECT id FROM projects AS inv
WHERE id IN (
    SELECT id FROM suppliers AS emp
    WHERE emp.level = inv.level
);


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

SELECT value FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.status = sale.status
);


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

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


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

SELECT code FROM projects AS ordr
WHERE code IN (
    SELECT code FROM branches AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT name FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.code = ordr.code
);


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

SELECT amount FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.id = srvc.id
);


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

SELECT code FROM warehouses AS sale
WHERE level IN (
    SELECT level FROM tasks AS rgn
    WHERE rgn.level = sale.level
);


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

SELECT salary FROM regions AS dept
WHERE level IN (
    SELECT level FROM shipments AS budg
    WHERE budg.status = dept.status
);


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

SELECT value FROM customers AS lne
WHERE amount > (
    SELECT AVG(value) FROM regions AS sale
    WHERE sale.code = lne.code
);


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

SELECT value FROM orders AS ord
WHERE status IN (
    SELECT status FROM shipments AS acct
    WHERE acct.id = ord.id
);


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

SELECT name FROM tasks AS cust
WHERE id IN (
    SELECT id FROM employees AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT salary FROM warehouses AS lne
WHERE type IN (
    SELECT type FROM suppliers AS catg
    WHERE catg.type = lne.type
);


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

SELECT code FROM regions AS budg
WHERE code IN (
    SELECT code FROM transactions AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT salary FROM transactions AS cust
WHERE amount > (
    SELECT AVG(amount) FROM employees AS prod
    WHERE prod.id = cust.id
);


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

SELECT amount FROM branches AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM suppliers AS acct
    WHERE acct.id = rgn.id
);


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

SELECT value FROM employees AS lne
WHERE salary > (
    SELECT MAX(value) FROM projects AS inv
    WHERE inv.type = lne.type
);


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

SELECT salary FROM branches AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS dept
    WHERE dept.status = mgr.status
);


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

SELECT value FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = rgn.type
);


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

SELECT name FROM orders AS ord
WHERE level IN (
    SELECT level FROM invoices AS empl
    WHERE empl.type = ord.type
);


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

SELECT amount FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.status = ordr.status
);


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

SELECT code FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT amount FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.id = sale.id
);


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

SELECT name FROM orders AS srvc
WHERE amount > (
    SELECT AVG(value) FROM warehouses AS mgr
    WHERE mgr.id = srvc.id
);


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

SELECT value FROM suppliers AS prod
WHERE code IN (
    SELECT code FROM regions AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT code FROM orders AS acct
WHERE value > (
    SELECT MIN(salary) FROM warehouses AS empl
    WHERE empl.code = acct.code
);


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

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


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

SELECT code FROM employees AS txn
WHERE code IN (
    SELECT code FROM categories AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT name FROM transactions AS dept
WHERE level IN (
    SELECT level FROM shipments AS txn
    WHERE txn.type = dept.type
);


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

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


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

SELECT code FROM customers AS ordr
WHERE level IN (
    SELECT level FROM departments AS prod
    WHERE prod.code = ordr.code
);


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

SELECT amount FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = schd.type
);


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

SELECT code FROM orders AS mgr
WHERE value > (
    SELECT MAX(salary) FROM categories AS dept
    WHERE dept.level = mgr.level
);


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

SELECT amount FROM departments AS empl
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.id = empl.id
);


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

SELECT value FROM categories AS emp
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS prod
    WHERE prod.id = emp.id
);


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

SELECT code FROM transactions AS lne
WHERE status IN (
    SELECT status FROM employees AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT code FROM customers AS whs
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS lne
    WHERE lne.status = whs.status
);


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

SELECT salary FROM invoices AS dept
WHERE amount > (
    SELECT AVG(salary) FROM warehouses AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT name FROM departments AS txn
WHERE amount > (
    SELECT COUNT(value) FROM orders AS srvc
    WHERE srvc.id = txn.id
);


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

SELECT name FROM products AS rgn
WHERE code IN (
    SELECT code FROM suppliers AS ordr
    WHERE ordr.type = rgn.type
);


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

SELECT id FROM tasks AS empl
WHERE salary > (
    SELECT MIN(salary) FROM customers AS cust
    WHERE cust.type = empl.type
);


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

SELECT code FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT amount FROM products AS sale
WHERE code IN (
    SELECT code FROM accounts AS mgr
    WHERE mgr.type = sale.type
);


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

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


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

SELECT code FROM employees AS ord
WHERE id IN (
    SELECT id FROM customers AS whs
    WHERE whs.status = ord.status
);


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

SELECT amount FROM warehouses AS shp
WHERE value > (
    SELECT SUM(value) FROM transactions AS mgr
    WHERE mgr.type = shp.type
);


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

SELECT name FROM branches AS lne
WHERE salary > (
    SELECT COUNT(value) FROM products AS acct
    WHERE acct.status = lne.status
);


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

SELECT value FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.type = budg.type
);


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

SELECT code FROM invoices AS schd
WHERE salary > (
    SELECT SUM(value) FROM categories AS prod
    WHERE prod.level = schd.level
);


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

SELECT salary FROM accounts AS acct
WHERE amount > (
    SELECT SUM(value) FROM transactions AS emp
    WHERE emp.code = acct.code
);


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

SELECT salary FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.code = ordr.code
);


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

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


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

SELECT id FROM warehouses AS shp
WHERE level IN (
    SELECT level FROM projects AS inv
    WHERE inv.level = shp.level
);


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

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


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

SELECT salary FROM products AS inv
WHERE amount > (
    SELECT AVG(salary) FROM transactions AS empl
    WHERE empl.level = inv.level
);


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

SELECT value FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.type = emp.type
);


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

SELECT name FROM customers AS empl
WHERE level IN (
    SELECT level FROM transactions AS emp
    WHERE emp.type = empl.type
);


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

SELECT id FROM tasks AS whs
WHERE id IN (
    SELECT id FROM accounts AS sale
    WHERE sale.status = whs.status
);


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

SELECT salary FROM employees AS rgn
WHERE amount > (
    SELECT SUM(amount) FROM categories AS cust
    WHERE cust.id = rgn.id
);


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

SELECT value FROM customers AS whs
WHERE amount > (
    SELECT MIN(value) FROM tasks AS shp
    WHERE shp.type = whs.type
);


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

SELECT salary FROM categories AS lne
WHERE salary > (
    SELECT AVG(value) FROM projects AS prod
    WHERE prod.level = lne.level
);


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

SELECT code FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = budg.level
);


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

SELECT name FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.id = emp.id
);


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

SELECT code FROM invoices AS sale
WHERE code IN (
    SELECT code FROM warehouses AS empl
    WHERE empl.level = sale.level
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = rgn.type
);


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

SELECT amount FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.level = prod.level
);


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

SELECT id FROM projects AS rgn
WHERE code IN (
    SELECT code FROM products AS whs
    WHERE whs.level = rgn.level
);


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

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


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.status = rgn.status
);


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

SELECT salary FROM accounts AS emp
WHERE id IN (
    SELECT id FROM employees AS rgn
    WHERE rgn.id = emp.id
);


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

SELECT value FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.code = catg.code
);


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

SELECT value FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.id = sale.id
);


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

SELECT amount FROM tasks AS catg
WHERE value > (
    SELECT MIN(value) FROM orders AS ord
    WHERE ord.level = catg.level
);


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

SELECT value FROM transactions AS lne
WHERE code IN (
    SELECT code FROM orders AS schd
    WHERE schd.status = lne.status
);


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

SELECT code FROM departments AS ord
WHERE code IN (
    SELECT code FROM invoices AS dept
    WHERE dept.level = ord.level
);


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

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


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

SELECT salary FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.type = mgr.type
);


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

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


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

SELECT value FROM products AS txn
WHERE salary > (
    SELECT MIN(value) FROM projects AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT code FROM regions AS emp
WHERE status IN (
    SELECT status FROM invoices AS cust
    WHERE cust.level = emp.level
);


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

SELECT amount FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = catg.level
);


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

SELECT name FROM customers AS shp
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.code = shp.code
);


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

SELECT code FROM products AS catg
WHERE amount > (
    SELECT MIN(amount) FROM employees AS mgr
    WHERE mgr.type = catg.type
);


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

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


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

SELECT name FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT amount FROM projects AS sale
WHERE salary > (
    SELECT MIN(value) FROM branches AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT name FROM products AS srvc
WHERE type IN (
    SELECT type FROM shipments AS shp
    WHERE shp.type = srvc.type
);


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

SELECT name FROM branches AS catg
WHERE id IN (
    SELECT id FROM customers AS txn
    WHERE txn.level = catg.level
);


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

SELECT name FROM orders AS catg
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS empl
    WHERE empl.type = catg.type
);


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

SELECT amount FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = inv.id
);


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

SELECT code FROM branches AS whs
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS txn
    WHERE txn.status = whs.status
);


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

SELECT id FROM employees AS sale
WHERE type IN (
    SELECT type FROM regions AS whs
    WHERE whs.level = sale.level
);


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

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


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

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


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

SELECT value FROM departments AS emp
WHERE code IN (
    SELECT code FROM projects AS budg
    WHERE budg.code = emp.code
);


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

SELECT code FROM employees AS empl
WHERE type IN (
    SELECT type FROM branches AS emp
    WHERE emp.code = empl.code
);


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

SELECT id FROM shipments AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS empl
    WHERE empl.type = mgr.type
);


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

SELECT code FROM suppliers AS srvc
WHERE status IN (
    SELECT status FROM projects AS rgn
    WHERE rgn.code = srvc.code
);


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

SELECT salary FROM customers AS acct
WHERE type IN (
    SELECT type FROM warehouses AS shp
    WHERE shp.type = acct.type
);


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

SELECT code FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.level = ordr.level
);


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

SELECT salary FROM departments AS cust
WHERE amount > (
    SELECT SUM(salary) FROM regions AS ord
    WHERE ord.level = cust.level
);


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

SELECT salary FROM departments AS rgn
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS acct
    WHERE acct.code = rgn.code
);


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

SELECT name FROM products AS ordr
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.status = ordr.status
);


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

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


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

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


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

SELECT name FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.id = acct.id
);


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

SELECT value FROM suppliers AS inv
WHERE value > (
    SELECT SUM(value) FROM invoices AS emp
    WHERE emp.type = inv.type
);


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

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


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

SELECT code FROM shipments AS rgn
WHERE amount > (
    SELECT SUM(salary) FROM branches AS sale
    WHERE sale.status = rgn.status
);


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

SELECT id FROM branches AS dept
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT id FROM tasks AS whs
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS cust
    WHERE cust.code = whs.code
);


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

SELECT id FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT value FROM regions AS ord
WHERE level IN (
    SELECT level FROM transactions AS inv
    WHERE inv.level = ord.level
);


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

SELECT value FROM suppliers AS acct
WHERE id IN (
    SELECT id FROM products AS sale
    WHERE sale.id = acct.id
);


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

SELECT id FROM projects AS shp
WHERE salary > (
    SELECT MAX(salary) FROM categories AS sale
    WHERE sale.level = shp.level
);


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

SELECT amount FROM invoices AS catg
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS whs
    WHERE whs.code = catg.code
);


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

SELECT value FROM tasks AS acct
WHERE type IN (
    SELECT type FROM employees AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT salary FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.level = whs.level
);


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

SELECT code FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.id = lne.id
);


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

SELECT salary FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.id = sale.id
);


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

SELECT amount FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.code = empl.code
);


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.id = catg.id
);


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

SELECT code FROM branches AS shp
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT code FROM customers AS emp
WHERE value > (
    SELECT COUNT(amount) FROM invoices AS catg
    WHERE catg.level = emp.level
);


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

SELECT salary FROM suppliers AS acct
WHERE value > (
    SELECT MAX(amount) FROM regions AS whs
    WHERE whs.code = acct.code
);


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

SELECT value FROM customers AS sale
WHERE code IN (
    SELECT code FROM suppliers AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT code FROM accounts AS txn
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS emp
    WHERE emp.type = txn.type
);


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

SELECT value FROM orders AS dept
WHERE status IN (
    SELECT status FROM employees AS ordr
    WHERE ordr.level = dept.level
);


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

SELECT value FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM orders AS schd
    WHERE schd.code = ordr.code
);


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

SELECT name FROM regions AS dept
WHERE id IN (
    SELECT id FROM invoices AS ord
    WHERE ord.code = dept.code
);


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

SELECT code FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.code = ord.code
);


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

SELECT value FROM transactions AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM invoices AS rgn
    WHERE rgn.code = ordr.code
);


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

SELECT code FROM customers AS sale
WHERE value > (
    SELECT MAX(value) FROM employees AS emp
    WHERE emp.code = sale.code
);


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

SELECT salary FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.status = budg.status
);


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

SELECT name FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.code = budg.code
);


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

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


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

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


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

SELECT name FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.status = rgn.status
);


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

SELECT salary FROM departments AS prod
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS empl
    WHERE empl.level = prod.level
);


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

SELECT amount FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.level = ordr.level
);


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

SELECT salary FROM invoices AS prod
WHERE code IN (
    SELECT code FROM projects AS schd
    WHERE schd.code = prod.code
);


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

SELECT value FROM categories AS prod
WHERE level IN (
    SELECT level FROM regions AS shp
    WHERE shp.id = prod.id
);


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

SELECT salary FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.type = ord.type
);


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

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


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

SELECT amount FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.id = ordr.id
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.level = rgn.level
);


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

SELECT value FROM transactions AS shp
WHERE amount > (
    SELECT MAX(salary) FROM projects AS whs
    WHERE whs.status = shp.status
);


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

SELECT value FROM departments AS ordr
WHERE id IN (
    SELECT id FROM branches AS txn
    WHERE txn.id = ordr.id
);


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

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


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

SELECT name FROM employees AS whs
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.status = whs.status
);


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

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


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

SELECT code FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.id = schd.id
);


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

SELECT id FROM transactions AS empl
WHERE value > (
    SELECT MAX(amount) FROM categories AS prod
    WHERE prod.status = empl.status
);


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

SELECT id FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.id = acct.id
);


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

SELECT id FROM transactions AS empl
WHERE salary > (
    SELECT SUM(salary) FROM departments AS lne
    WHERE lne.id = empl.id
);


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

SELECT code FROM projects AS txn
WHERE level IN (
    SELECT level FROM departments AS empl
    WHERE empl.id = txn.id
);


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

SELECT name FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.level = txn.level
);


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

SELECT value FROM shipments AS prod
WHERE amount > (
    SELECT MAX(amount) FROM departments AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT salary FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.code = inv.code
);


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

SELECT value FROM branches AS emp
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS shp
    WHERE shp.status = emp.status
);


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

SELECT salary FROM warehouses AS inv
WHERE id IN (
    SELECT id FROM branches AS lne
    WHERE lne.code = inv.code
);


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

SELECT id FROM products AS lne
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.status = lne.status
);


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

SELECT id FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.level = schd.level
);


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

SELECT id FROM projects AS whs
WHERE salary > (
    SELECT SUM(value) FROM branches AS ord
    WHERE ord.level = whs.level
);


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

SELECT id FROM accounts AS catg
WHERE status IN (
    SELECT status FROM suppliers AS acct
    WHERE acct.type = catg.type
);


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

SELECT value FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = ordr.level
);


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

SELECT amount FROM shipments AS shp
WHERE value > (
    SELECT MIN(salary) FROM invoices AS srvc
    WHERE srvc.level = shp.level
);


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

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


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

SELECT value FROM tasks AS ord
WHERE amount > (
    SELECT MAX(value) FROM branches AS txn
    WHERE txn.status = ord.status
);


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

SELECT code FROM projects AS emp
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS catg
    WHERE catg.status = emp.status
);


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

SELECT value FROM suppliers AS txn
WHERE status IN (
    SELECT status FROM warehouses AS inv
    WHERE inv.status = txn.status
);


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

SELECT id FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.level = ordr.level
);


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

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


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

SELECT amount FROM employees AS txn
WHERE value > (
    SELECT MAX(value) FROM invoices AS budg
    WHERE budg.status = txn.status
);


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

SELECT name FROM transactions AS shp
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT salary FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.type = acct.type
);


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

SELECT code FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.code = rgn.code
);


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

SELECT salary FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT amount FROM regions AS schd
WHERE status IN (
    SELECT status FROM products AS sale
    WHERE sale.id = schd.id
);


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

SELECT salary FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.code = mgr.code
);


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

SELECT salary FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.type = sale.type
);


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

SELECT code FROM employees AS acct
WHERE status IN (
    SELECT status FROM regions AS lne
    WHERE lne.type = acct.type
);


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

SELECT name FROM projects AS acct
WHERE type IN (
    SELECT type FROM customers AS sale
    WHERE sale.id = acct.id
);


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

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


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

SELECT amount FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT name FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.id = prod.id
);


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

SELECT salary FROM invoices AS cust
WHERE code IN (
    SELECT code FROM employees AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT salary FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.type = ordr.type
);


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

SELECT salary FROM accounts AS schd
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.status = schd.status
);


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

SELECT salary FROM employees AS srvc
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT code FROM tasks AS mgr
WHERE status IN (
    SELECT status FROM regions AS shp
    WHERE shp.id = mgr.id
);


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

SELECT id FROM branches AS cust
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS whs
    WHERE whs.type = cust.type
);


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

SELECT salary FROM suppliers AS acct
WHERE value > (
    SELECT SUM(salary) FROM orders AS sale
    WHERE sale.id = acct.id
);


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

SELECT amount FROM transactions AS emp
WHERE level IN (
    SELECT level FROM branches AS whs
    WHERE whs.type = emp.type
);


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

SELECT code FROM orders AS budg
WHERE salary > (
    SELECT COUNT(salary) FROM products AS schd
    WHERE schd.code = budg.code
);


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

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


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

SELECT amount FROM shipments AS cust
WHERE amount > (
    SELECT SUM(value) FROM projects AS txn
    WHERE txn.code = cust.code
);


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

SELECT value FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.id = sale.id
);


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

SELECT code FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.id = budg.id
);


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

SELECT code FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.type = schd.type
);


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

SELECT id FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT name FROM transactions AS emp
WHERE type IN (
    SELECT type FROM warehouses AS budg
    WHERE budg.level = emp.level
);


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

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


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

SELECT code FROM products AS schd
WHERE value > (
    SELECT MAX(value) FROM tasks AS srvc
    WHERE srvc.id = schd.id
);


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

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


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

SELECT id FROM warehouses AS srvc
WHERE type IN (
    SELECT type FROM orders AS cust
    WHERE cust.id = srvc.id
);


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

SELECT name FROM products AS empl
WHERE value > (
    SELECT MAX(amount) FROM shipments AS sale
    WHERE sale.level = empl.level
);


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

SELECT salary FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.code = ordr.code
);


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

SELECT code FROM transactions AS whs
WHERE type IN (
    SELECT type FROM accounts AS prod
    WHERE prod.status = whs.status
);


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

SELECT code FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.status = budg.status
);


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

SELECT name FROM projects AS ord
WHERE code IN (
    SELECT code FROM warehouses AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT salary FROM invoices AS prod
WHERE salary > (
    SELECT MAX(salary) FROM orders AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT salary FROM categories AS schd
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS ordr
    WHERE ordr.type = schd.type
);


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

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


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

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


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

SELECT salary FROM projects AS txn
WHERE type IN (
    SELECT type FROM customers AS shp
    WHERE shp.code = txn.code
);


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

SELECT id FROM customers AS catg
WHERE value > (
    SELECT MIN(value) FROM categories AS empl
    WHERE empl.level = catg.level
);


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

SELECT name FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT amount FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.code = ord.code
);


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

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


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

SELECT id FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.id = ordr.id
);


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

SELECT id FROM accounts AS prod
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.code = prod.code
);


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

SELECT id FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = ordr.type
);


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

SELECT name FROM projects AS prod
WHERE code IN (
    SELECT code FROM accounts AS txn
    WHERE txn.level = prod.level
);


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

SELECT value FROM suppliers AS txn
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.id = txn.id
);


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

SELECT amount FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.id = acct.id
);


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

SELECT value FROM departments AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS srvc
    WHERE srvc.code = rgn.code
);


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

SELECT name FROM projects AS prod
WHERE code IN (
    SELECT code FROM accounts AS srvc
    WHERE srvc.status = prod.status
);


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

SELECT code FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.level = budg.level
);


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

SELECT salary FROM warehouses AS inv
WHERE id IN (
    SELECT id FROM tasks AS acct
    WHERE acct.level = inv.level
);


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

SELECT amount FROM regions AS schd
WHERE status IN (
    SELECT status FROM categories AS whs
    WHERE whs.code = schd.code
);


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

SELECT name FROM products AS schd
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS budg
    WHERE budg.level = schd.level
);


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

SELECT salary FROM tasks AS empl
WHERE code IN (
    SELECT code FROM projects AS catg
    WHERE catg.type = empl.type
);


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

SELECT code FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.level = inv.level
);


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

SELECT salary FROM projects AS inv
WHERE status IN (
    SELECT status FROM orders AS dept
    WHERE dept.type = inv.type
);


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

SELECT id FROM orders AS rgn
WHERE value > (
    SELECT SUM(amount) FROM branches AS acct
    WHERE acct.code = rgn.code
);


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

SELECT name FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.status = srvc.status
);


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

SELECT name FROM categories AS schd
WHERE id IN (
    SELECT id FROM tasks AS empl
    WHERE empl.status = schd.status
);


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

SELECT value FROM customers AS lne
WHERE status IN (
    SELECT status FROM shipments AS sale
    WHERE sale.level = lne.level
);


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

SELECT id FROM transactions AS sale
WHERE salary > (
    SELECT AVG(amount) FROM employees AS catg
    WHERE catg.type = sale.type
);


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

SELECT code FROM suppliers AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM branches AS ord
    WHERE ord.level = rgn.level
);


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

SELECT amount FROM employees AS catg
WHERE status IN (
    SELECT status FROM branches AS sale
    WHERE sale.level = catg.level
);


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

SELECT id FROM employees AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS cust
    WHERE cust.id = whs.id
);


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

SELECT name FROM products AS cust
WHERE id IN (
    SELECT id FROM categories AS sale
    WHERE sale.type = cust.type
);


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

SELECT id FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.status = schd.status
);


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

SELECT value FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.type = emp.type
);


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

SELECT amount FROM suppliers AS cust
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.code = cust.code
);


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

SELECT amount FROM customers AS sale
WHERE code IN (
    SELECT code FROM shipments AS emp
    WHERE emp.type = sale.type
);


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

SELECT name FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.code = prod.code
);