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

SELECT salary FROM orders AS schd
WHERE type IN (
    SELECT type FROM invoices AS shp
    WHERE shp.status = schd.status
);


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

SELECT code FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.id = schd.id
);


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

SELECT amount FROM suppliers AS srvc
WHERE salary > (
    SELECT MIN(value) FROM products AS rgn
    WHERE rgn.level = srvc.level
);


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

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


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

SELECT salary FROM transactions AS inv
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS sale
    WHERE sale.status = inv.status
);


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

SELECT code FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = catg.type
);


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

SELECT value FROM transactions AS cust
WHERE salary > (
    SELECT SUM(value) FROM regions AS whs
    WHERE whs.level = cust.level
);


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

SELECT id FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT value FROM customers AS inv
WHERE type IN (
    SELECT type FROM employees AS acct
    WHERE acct.code = inv.code
);


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

SELECT salary FROM suppliers AS shp
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.level = shp.level
);


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

SELECT id FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.code = prod.code
);


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

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


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

SELECT amount FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.level = lne.level
);


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

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


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

SELECT id FROM products AS whs
WHERE level IN (
    SELECT level FROM departments AS emp
    WHERE emp.status = whs.status
);


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

SELECT salary FROM orders AS inv
WHERE code IN (
    SELECT code FROM tasks AS shp
    WHERE shp.status = inv.status
);


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

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


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

SELECT id FROM suppliers AS inv
WHERE salary > (
    SELECT AVG(salary) FROM customers AS cust
    WHERE cust.type = inv.type
);


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

SELECT id FROM employees AS txn
WHERE level IN (
    SELECT level FROM accounts AS cust
    WHERE cust.type = txn.type
);


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

SELECT value FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = prod.level
);


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

SELECT name FROM departments AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM products AS rgn
    WHERE rgn.type = mgr.type
);


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

SELECT salary FROM transactions AS budg
WHERE salary > (
    SELECT MAX(amount) FROM regions AS acct
    WHERE acct.level = budg.level
);


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

SELECT name FROM branches AS empl
WHERE salary > (
    SELECT AVG(salary) FROM categories AS emp
    WHERE emp.level = empl.level
);


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

SELECT salary FROM regions AS schd
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS catg
    WHERE catg.level = schd.level
);


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

SELECT name FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.level = catg.level
);


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

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


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

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


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

SELECT value FROM categories AS budg
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS cust
    WHERE cust.status = budg.status
);


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

SELECT value FROM orders AS empl
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS emp
    WHERE emp.level = empl.level
);


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

SELECT salary FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.type = shp.type
);


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

SELECT amount FROM warehouses AS emp
WHERE value > (
    SELECT AVG(amount) FROM customers AS catg
    WHERE catg.id = emp.id
);


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

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


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

SELECT id FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.status = sale.status
);


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

SELECT salary FROM branches AS cust
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS schd
    WHERE schd.code = cust.code
);


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

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


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

SELECT amount FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.id = rgn.id
);


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

SELECT value FROM categories AS dept
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS budg
    WHERE budg.code = dept.code
);


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

SELECT value FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = dept.level
);


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

SELECT id FROM orders AS empl
WHERE level IN (
    SELECT level FROM tasks AS inv
    WHERE inv.status = empl.status
);


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

SELECT id FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.type = emp.type
);


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

SELECT id FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT code FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.status = whs.status
);


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

SELECT amount FROM accounts AS ordr
WHERE amount > (
    SELECT SUM(amount) FROM invoices AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT name FROM shipments AS prod
WHERE type IN (
    SELECT type FROM branches AS budg
    WHERE budg.code = prod.code
);


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

SELECT code FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT name FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.id = acct.id
);


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

SELECT salary FROM transactions AS emp
WHERE code IN (
    SELECT code FROM accounts AS schd
    WHERE schd.status = emp.status
);


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

SELECT name FROM suppliers AS catg
WHERE value > (
    SELECT AVG(salary) FROM employees AS dept
    WHERE dept.status = catg.status
);


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

SELECT value FROM shipments AS ordr
WHERE id IN (
    SELECT id FROM branches AS empl
    WHERE empl.code = ordr.code
);


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

SELECT salary FROM invoices AS mgr
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.level = mgr.level
);


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

SELECT id FROM suppliers AS ordr
WHERE amount > (
    SELECT AVG(value) FROM products AS sale
    WHERE sale.code = ordr.code
);


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

SELECT amount FROM categories AS empl
WHERE amount > (
    SELECT MIN(value) FROM warehouses AS ord
    WHERE ord.id = empl.id
);


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

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


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

SELECT id FROM transactions AS ord
WHERE salary > (
    SELECT MIN(value) FROM employees AS whs
    WHERE whs.type = ord.type
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.status = budg.status
);


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

SELECT value FROM transactions AS whs
WHERE code IN (
    SELECT code FROM categories AS ord
    WHERE ord.id = whs.id
);


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

SELECT amount FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = srvc.status
);


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

SELECT id FROM categories AS catg
WHERE level IN (
    SELECT level FROM transactions AS shp
    WHERE shp.id = catg.id
);


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

SELECT code FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.status = sale.status
);


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

SELECT id FROM suppliers AS rgn
WHERE value > (
    SELECT MIN(value) FROM departments AS cust
    WHERE cust.level = rgn.level
);


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

SELECT amount FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.status = sale.status
);


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

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


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

SELECT amount FROM branches AS catg
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT code FROM customers AS inv
WHERE type IN (
    SELECT type FROM accounts AS lne
    WHERE lne.code = inv.code
);


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

SELECT name FROM products AS schd
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS ordr
    WHERE ordr.type = schd.type
);


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

SELECT id FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT id FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT code FROM orders AS shp
WHERE value > (
    SELECT SUM(value) FROM tasks AS whs
    WHERE whs.code = shp.code
);


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

SELECT salary FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT code FROM tasks AS inv
WHERE id IN (
    SELECT id FROM categories AS budg
    WHERE budg.level = inv.level
);


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

SELECT value FROM warehouses AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS cust
    WHERE cust.code = txn.code
);


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

SELECT amount FROM orders AS dept
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS catg
    WHERE catg.code = dept.code
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.code = prod.code
);


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

SELECT code FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.code = srvc.code
);


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

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


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

SELECT value FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT id FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.level = mgr.level
);


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

SELECT value FROM tasks AS mgr
WHERE code IN (
    SELECT code FROM categories AS cust
    WHERE cust.id = mgr.id
);


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

SELECT amount FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT id FROM regions AS dept
WHERE salary > (
    SELECT MAX(salary) FROM employees AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT amount FROM categories AS sale
WHERE salary > (
    SELECT MAX(salary) FROM customers AS whs
    WHERE whs.type = sale.type
);


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

SELECT id FROM accounts AS ordr
WHERE status IN (
    SELECT status FROM warehouses AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT value FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.type = rgn.type
);


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

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


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

SELECT value FROM tasks AS ord
WHERE value > (
    SELECT COUNT(value) FROM shipments AS dept
    WHERE dept.status = ord.status
);


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

SELECT salary FROM tasks AS cust
WHERE level IN (
    SELECT level FROM projects AS sale
    WHERE sale.code = cust.code
);


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

SELECT name FROM departments AS rgn
WHERE level IN (
    SELECT level FROM customers AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT name FROM shipments AS inv
WHERE code IN (
    SELECT code FROM invoices AS sale
    WHERE sale.level = inv.level
);


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

SELECT id FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.code = srvc.code
);


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

SELECT id FROM invoices AS shp
WHERE type IN (
    SELECT type FROM tasks AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT salary FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.status = srvc.status
);


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

SELECT name FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.level = srvc.level
);


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

SELECT amount FROM accounts AS cust
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT value FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.type = dept.type
);


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

SELECT code FROM products AS shp
WHERE value > (
    SELECT MIN(salary) FROM departments AS ord
    WHERE ord.type = shp.type
);


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

SELECT amount FROM customers AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS schd
    WHERE schd.code = rgn.code
);


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

SELECT name FROM branches AS emp
WHERE id IN (
    SELECT id FROM accounts AS catg
    WHERE catg.status = emp.status
);


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

SELECT name FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.status = budg.status
);


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

SELECT id FROM categories AS txn
WHERE value > (
    SELECT AVG(amount) FROM regions AS sale
    WHERE sale.code = txn.code
);


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

SELECT name FROM orders AS lne
WHERE salary > (
    SELECT MAX(value) FROM departments AS emp
    WHERE emp.type = lne.type
);


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

SELECT name FROM categories AS ord
WHERE code IN (
    SELECT code FROM tasks AS sale
    WHERE sale.status = ord.status
);


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

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


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

SELECT id FROM suppliers AS ord
WHERE id IN (
    SELECT id FROM accounts AS whs
    WHERE whs.status = ord.status
);


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

SELECT salary FROM products AS schd
WHERE value > (
    SELECT AVG(salary) FROM branches AS txn
    WHERE txn.type = schd.type
);


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

SELECT id FROM transactions AS empl
WHERE id IN (
    SELECT id FROM tasks AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT code FROM shipments AS catg
WHERE level IN (
    SELECT level FROM categories AS lne
    WHERE lne.status = catg.status
);


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

SELECT salary FROM shipments AS acct
WHERE code IN (
    SELECT code FROM transactions AS cust
    WHERE cust.level = acct.level
);


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

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


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

SELECT name FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.level = emp.level
);


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

SELECT value FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.status = rgn.status
);


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

SELECT amount FROM products AS shp
WHERE id IN (
    SELECT id FROM employees AS prod
    WHERE prod.code = shp.code
);


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

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM employees AS lne
    WHERE lne.type = cust.type
);


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

SELECT code FROM accounts AS lne
WHERE value > (
    SELECT SUM(amount) FROM branches AS cust
    WHERE cust.type = lne.type
);


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

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


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

SELECT salary FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.level = mgr.level
);


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

SELECT name FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT value FROM shipments AS shp
WHERE amount > (
    SELECT MAX(salary) FROM categories AS sale
    WHERE sale.id = shp.id
);


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

SELECT salary FROM orders AS ordr
WHERE code IN (
    SELECT code FROM warehouses AS lne
    WHERE lne.status = ordr.status
);


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

SELECT amount FROM employees AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS cust
    WHERE cust.code = catg.code
);


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

SELECT code FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.type = shp.type
);


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

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


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

SELECT name FROM tasks AS empl
WHERE type IN (
    SELECT type FROM orders AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT id FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.id = ord.id
);


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

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


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

SELECT code FROM accounts AS rgn
WHERE level IN (
    SELECT level FROM invoices AS txn
    WHERE txn.type = rgn.type
);


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

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


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

SELECT amount FROM products AS prod
WHERE status IN (
    SELECT status FROM tasks AS cust
    WHERE cust.status = prod.status
);


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

SELECT amount FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = ord.type
);


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

SELECT id FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM categories AS acct
    WHERE acct.type = ordr.type
);


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

SELECT id FROM branches AS ord
WHERE code IN (
    SELECT code FROM tasks AS srvc
    WHERE srvc.level = ord.level
);


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

SELECT code FROM accounts AS ord
WHERE salary > (
    SELECT MIN(salary) FROM departments AS schd
    WHERE schd.status = ord.status
);


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

SELECT id FROM invoices AS empl
WHERE salary > (
    SELECT AVG(value) FROM tasks AS schd
    WHERE schd.level = empl.level
);


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

SELECT value FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.code = rgn.code
);


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

SELECT id FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.level = schd.level
);


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

SELECT id FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.type = ordr.type
);


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

SELECT name FROM invoices AS rgn
WHERE level IN (
    SELECT level FROM suppliers AS txn
    WHERE txn.id = rgn.id
);


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

SELECT amount FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = ord.level
);


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

SELECT salary FROM departments AS cust
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT code FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.status = srvc.status
);


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

SELECT salary FROM shipments AS empl
WHERE status IN (
    SELECT status FROM tasks AS acct
    WHERE acct.status = empl.status
);


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

SELECT salary FROM categories AS lne
WHERE value > (
    SELECT SUM(value) FROM branches AS ord
    WHERE ord.status = lne.status
);


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

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


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

SELECT id FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = inv.level
);


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

SELECT amount FROM invoices AS prod
WHERE value > (
    SELECT SUM(amount) FROM customers AS empl
    WHERE empl.level = prod.level
);


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

SELECT salary FROM regions AS sale
WHERE level IN (
    SELECT level FROM shipments AS cust
    WHERE cust.type = sale.type
);


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

SELECT value FROM branches AS cust
WHERE id IN (
    SELECT id FROM departments AS schd
    WHERE schd.level = cust.level
);


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

SELECT amount FROM transactions AS sale
WHERE status IN (
    SELECT status FROM projects AS schd
    WHERE schd.type = sale.type
);


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

SELECT name FROM tasks AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM customers AS txn
    WHERE txn.type = rgn.type
);


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

SELECT value FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.id = rgn.id
);


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

SELECT id FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT name FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.type = inv.type
);


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

SELECT name FROM tasks AS empl
WHERE code IN (
    SELECT code FROM accounts AS lne
    WHERE lne.type = empl.type
);


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

SELECT name FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT value FROM suppliers AS lne
WHERE level IN (
    SELECT level FROM invoices AS schd
    WHERE schd.level = lne.level
);


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

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


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

SELECT name FROM shipments AS shp
WHERE type IN (
    SELECT type FROM projects AS ord
    WHERE ord.level = shp.level
);


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

SELECT amount FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.status = srvc.status
);


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

SELECT id FROM accounts AS empl
WHERE value > (
    SELECT MAX(value) FROM employees AS schd
    WHERE schd.code = empl.code
);


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

SELECT code FROM suppliers AS shp
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS catg
    WHERE catg.status = shp.status
);


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

SELECT code FROM accounts AS dept
WHERE code IN (
    SELECT code FROM customers AS prod
    WHERE prod.status = dept.status
);


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

SELECT amount FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.level = budg.level
);


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

SELECT name FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.status = txn.status
);


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

SELECT salary FROM invoices AS prod
WHERE status IN (
    SELECT status FROM regions AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT value FROM departments AS dept
WHERE type IN (
    SELECT type FROM accounts AS schd
    WHERE schd.level = dept.level
);


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

SELECT id FROM suppliers AS lne
WHERE salary > (
    SELECT MAX(value) FROM customers AS ord
    WHERE ord.id = lne.id
);


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

SELECT id FROM orders AS rgn
WHERE salary > (
    SELECT MAX(value) FROM accounts AS lne
    WHERE lne.type = rgn.type
);


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

SELECT id FROM invoices AS inv
WHERE status IN (
    SELECT status FROM transactions AS prod
    WHERE prod.type = inv.type
);


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

SELECT salary FROM accounts AS dept
WHERE type IN (
    SELECT type FROM projects AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT salary FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.level = budg.level
);


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

SELECT id FROM tasks AS inv
WHERE status IN (
    SELECT status FROM customers AS ordr
    WHERE ordr.code = inv.code
);


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

SELECT name FROM projects AS ord
WHERE status IN (
    SELECT status FROM employees AS cust
    WHERE cust.level = ord.level
);


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

SELECT name FROM shipments AS emp
WHERE amount > (
    SELECT AVG(salary) FROM customers AS rgn
    WHERE rgn.code = emp.code
);


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

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


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

SELECT amount FROM shipments AS catg
WHERE id IN (
    SELECT id FROM suppliers AS dept
    WHERE dept.status = catg.status
);


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

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


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

SELECT name FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.type = whs.type
);


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

SELECT value FROM projects AS emp
WHERE value > (
    SELECT MIN(salary) FROM suppliers AS lne
    WHERE lne.status = emp.status
);


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

SELECT name FROM customers AS prod
WHERE status IN (
    SELECT status FROM shipments AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT code FROM shipments AS whs
WHERE value > (
    SELECT AVG(salary) FROM invoices AS ordr
    WHERE ordr.status = whs.status
);


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

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


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

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


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

SELECT salary FROM products AS emp
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS schd
    WHERE schd.type = emp.type
);


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

SELECT id FROM categories AS lne
WHERE amount > (
    SELECT SUM(amount) FROM invoices AS empl
    WHERE empl.level = lne.level
);


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

SELECT id FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.code = cust.code
);


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

SELECT amount FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.level = ordr.level
);


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

SELECT code FROM branches AS cust
WHERE amount > (
    SELECT SUM(salary) FROM departments AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT code FROM products AS acct
WHERE value > (
    SELECT SUM(salary) FROM accounts AS sale
    WHERE sale.level = acct.level
);


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

SELECT amount FROM warehouses AS txn
WHERE value > (
    SELECT SUM(amount) FROM categories AS whs
    WHERE whs.type = txn.type
);


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

SELECT name FROM accounts AS emp
WHERE status IN (
    SELECT status FROM customers AS rgn
    WHERE rgn.code = emp.code
);


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

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


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

SELECT code FROM employees AS acct
WHERE status IN (
    SELECT status FROM warehouses AS catg
    WHERE catg.level = acct.level
);


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

SELECT amount FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT code FROM accounts AS prod
WHERE code IN (
    SELECT code FROM invoices AS catg
    WHERE catg.id = prod.id
);


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

SELECT id FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.type = schd.type
);


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

SELECT value FROM departments AS rgn
WHERE value > (
    SELECT SUM(amount) FROM invoices AS lne
    WHERE lne.type = rgn.type
);


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

SELECT name FROM departments AS empl
WHERE type IN (
    SELECT type FROM products AS acct
    WHERE acct.status = empl.status
);


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

SELECT name FROM accounts AS empl
WHERE value > (
    SELECT COUNT(value) FROM customers AS ordr
    WHERE ordr.code = empl.code
);


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

SELECT value FROM orders AS schd
WHERE value > (
    SELECT COUNT(value) FROM departments AS emp
    WHERE emp.id = schd.id
);


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

SELECT salary FROM accounts AS dept
WHERE id IN (
    SELECT id FROM departments AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT name FROM regions AS cust
WHERE value > (
    SELECT MIN(amount) FROM warehouses AS inv
    WHERE inv.status = cust.status
);


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

SELECT value FROM warehouses AS acct
WHERE amount > (
    SELECT MAX(value) FROM categories AS txn
    WHERE txn.level = acct.level
);


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

SELECT id FROM branches AS prod
WHERE id IN (
    SELECT id FROM departments AS txn
    WHERE txn.level = prod.level
);


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

SELECT name FROM departments AS acct
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS prod
    WHERE prod.id = acct.id
);


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

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


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

SELECT id FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.id = emp.id
);


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

SELECT value FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.status = inv.status
);


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

SELECT amount FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.status = txn.status
);


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

SELECT name FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.status = cust.status
);


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

SELECT value FROM categories AS rgn
WHERE code IN (
    SELECT code FROM products AS ordr
    WHERE ordr.level = rgn.level
);


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

SELECT name FROM branches AS lne
WHERE value > (
    SELECT MIN(amount) FROM invoices AS acct
    WHERE acct.type = lne.type
);


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

SELECT value FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.type = catg.type
);


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

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


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

SELECT name FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = catg.code
);


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

SELECT name FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.code = emp.code
);


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

SELECT value FROM categories AS budg
WHERE amount > (
    SELECT SUM(salary) FROM shipments AS empl
    WHERE empl.type = budg.type
);


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

SELECT code FROM regions AS rgn
WHERE type IN (
    SELECT type FROM shipments AS sale
    WHERE sale.level = rgn.level
);


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

SELECT id FROM projects AS dept
WHERE id IN (
    SELECT id FROM transactions AS txn
    WHERE txn.level = dept.level
);


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

SELECT code FROM shipments AS shp
WHERE status IN (
    SELECT status FROM employees AS sale
    WHERE sale.id = shp.id
);


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

SELECT code FROM invoices AS catg
WHERE id IN (
    SELECT id FROM tasks AS empl
    WHERE empl.type = catg.type
);


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

SELECT id FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.id = ord.id
);


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

SELECT salary FROM employees AS acct
WHERE amount > (
    SELECT COUNT(salary) FROM tasks AS whs
    WHERE whs.id = acct.id
);


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

SELECT name FROM transactions AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.status = prod.status
);


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

SELECT amount FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.level = ordr.level
);


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

SELECT code FROM departments AS mgr
WHERE value > (
    SELECT SUM(amount) FROM accounts AS ord
    WHERE ord.id = mgr.id
);


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

SELECT salary FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.status = shp.status
);


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

SELECT id FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.code = empl.code
);


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

SELECT value FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.id = dept.id
);


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

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


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

SELECT salary FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.code = shp.code
);


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

SELECT name FROM tasks AS catg
WHERE value > (
    SELECT MIN(value) FROM accounts AS empl
    WHERE empl.id = catg.id
);


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

SELECT value FROM transactions AS lne
WHERE id IN (
    SELECT id FROM departments AS srvc
    WHERE srvc.status = lne.status
);


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

SELECT id FROM employees AS whs
WHERE salary > (
    SELECT SUM(value) FROM tasks AS catg
    WHERE catg.type = whs.type
);


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

SELECT id FROM transactions AS srvc
WHERE value > (
    SELECT AVG(amount) FROM regions AS acct
    WHERE acct.type = srvc.type
);


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

SELECT salary FROM products AS acct
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS shp
    WHERE shp.level = acct.level
);


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

SELECT code FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.level = budg.level
);


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

SELECT name FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.type = ord.type
);


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

SELECT name FROM products AS whs
WHERE type IN (
    SELECT type FROM accounts AS budg
    WHERE budg.level = whs.level
);


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

SELECT amount FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.status = budg.status
);


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

SELECT salary FROM projects AS ord
WHERE salary > (
    SELECT SUM(amount) FROM employees AS dept
    WHERE dept.type = ord.type
);


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

SELECT code FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.id = acct.id
);


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

SELECT value FROM invoices AS budg
WHERE value > (
    SELECT MAX(value) FROM branches AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT value FROM employees AS srvc
WHERE salary > (
    SELECT MAX(amount) FROM accounts AS emp
    WHERE emp.id = srvc.id
);


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

SELECT name FROM shipments AS prod
WHERE id IN (
    SELECT id FROM projects AS budg
    WHERE budg.type = prod.type
);


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

SELECT name FROM warehouses AS cust
WHERE value > (
    SELECT SUM(value) FROM accounts AS acct
    WHERE acct.level = cust.level
);


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

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


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

SELECT name FROM projects AS emp
WHERE level IN (
    SELECT level FROM branches AS catg
    WHERE catg.id = emp.id
);


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

SELECT salary FROM branches AS cust
WHERE level IN (
    SELECT level FROM employees AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT id FROM tasks AS prod
WHERE type IN (
    SELECT type FROM products AS txn
    WHERE txn.code = prod.code
);


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

SELECT salary FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.id = dept.id
);


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

SELECT salary FROM orders AS ordr
WHERE amount > (
    SELECT SUM(value) FROM categories AS emp
    WHERE emp.level = ordr.level
);


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

SELECT salary FROM customers AS lne
WHERE value > (
    SELECT AVG(amount) FROM categories AS shp
    WHERE shp.id = lne.id
);


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

SELECT name FROM branches AS schd
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.type = schd.type
);


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

SELECT name FROM invoices AS sale
WHERE salary > (
    SELECT SUM(value) FROM shipments AS acct
    WHERE acct.type = sale.type
);


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

SELECT name FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.status = srvc.status
);


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

SELECT name FROM departments AS emp
WHERE salary > (
    SELECT MAX(value) FROM tasks AS empl
    WHERE empl.level = emp.level
);


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

SELECT value FROM employees AS rgn
WHERE value > (
    SELECT COUNT(amount) FROM customers AS dept
    WHERE dept.id = rgn.id
);


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

SELECT name FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.code = lne.code
);


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

SELECT salary FROM categories AS acct
WHERE level IN (
    SELECT level FROM accounts AS inv
    WHERE inv.id = acct.id
);


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

SELECT code FROM employees AS empl
WHERE amount > (
    SELECT AVG(value) FROM projects AS acct
    WHERE acct.level = empl.level
);


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

SELECT code FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.level = cust.level
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT id FROM departments AS catg
WHERE level IN (
    SELECT level FROM products AS mgr
    WHERE mgr.status = catg.status
);


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

SELECT salary FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.status = dept.status
);


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

SELECT value FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.type = srvc.type
);


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

SELECT value FROM categories AS dept
WHERE value > (
    SELECT MAX(salary) FROM warehouses AS acct
    WHERE acct.type = dept.type
);


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

SELECT amount FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.level = txn.level
);


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

SELECT name FROM transactions AS cust
WHERE salary > (
    SELECT AVG(amount) FROM departments AS schd
    WHERE schd.code = cust.code
);


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

SELECT code FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.status = budg.status
);


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

SELECT code FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.code = dept.code
);


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

SELECT code FROM branches AS catg
WHERE amount > (
    SELECT SUM(amount) FROM projects AS whs
    WHERE whs.status = catg.status
);


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

SELECT id FROM accounts AS budg
WHERE value > (
    SELECT MIN(value) FROM suppliers AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT code FROM regions AS lne
WHERE amount > (
    SELECT MAX(salary) FROM projects AS cust
    WHERE cust.type = lne.type
);


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

SELECT name FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.code = sale.code
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.level = cust.level
);


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

SELECT value FROM shipments AS catg
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS dept
    WHERE dept.code = catg.code
);


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

SELECT salary FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.code = whs.code
);


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

SELECT code FROM tasks AS whs
WHERE status IN (
    SELECT status FROM suppliers AS emp
    WHERE emp.type = whs.type
);


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

SELECT salary FROM accounts AS ord
WHERE salary > (
    SELECT MAX(value) FROM customers AS shp
    WHERE shp.code = ord.code
);


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

SELECT amount FROM warehouses AS prod
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.level = prod.level
);


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

SELECT code FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS schd
    WHERE schd.code = whs.code
);


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

SELECT id FROM categories AS emp
WHERE id IN (
    SELECT id FROM customers AS acct
    WHERE acct.type = emp.type
);


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

SELECT amount FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.status = txn.status
);


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

SELECT name FROM tasks AS srvc
WHERE value > (
    SELECT COUNT(salary) FROM customers AS empl
    WHERE empl.id = srvc.id
);


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

SELECT code FROM accounts AS ord
WHERE amount > (
    SELECT AVG(amount) FROM branches AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT salary FROM accounts AS rgn
WHERE id IN (
    SELECT id FROM projects AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT id FROM regions AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.type = dept.type
);


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

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


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

SELECT value FROM projects AS mgr
WHERE level IN (
    SELECT level FROM shipments AS sale
    WHERE sale.level = mgr.level
);


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

SELECT amount FROM suppliers AS empl
WHERE value > (
    SELECT SUM(amount) FROM shipments AS ordr
    WHERE ordr.id = empl.id
);


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

SELECT id FROM categories AS inv
WHERE amount > (
    SELECT AVG(amount) FROM regions AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT id FROM customers AS ordr
WHERE status IN (
    SELECT status FROM tasks AS cust
    WHERE cust.level = ordr.level
);


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

SELECT salary FROM warehouses AS dept
WHERE type IN (
    SELECT type FROM suppliers AS prod
    WHERE prod.code = dept.code
);


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

SELECT amount FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.level = sale.level
);