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

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


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

SELECT value FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT value FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.id = catg.id
);


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

SELECT amount FROM shipments AS ord
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS prod
    WHERE prod.code = ord.code
);


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

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


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

SELECT salary FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.status = ordr.status
);


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

SELECT value FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.id = inv.id
);


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

SELECT id FROM shipments AS txn
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT code FROM invoices AS prod
WHERE type IN (
    SELECT type FROM warehouses AS schd
    WHERE schd.status = prod.status
);


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

SELECT salary FROM projects AS prod
WHERE code IN (
    SELECT code FROM transactions AS inv
    WHERE inv.level = prod.level
);


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

SELECT code FROM orders AS lne
WHERE level IN (
    SELECT level FROM branches AS dept
    WHERE dept.id = lne.id
);


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

SELECT name FROM invoices AS whs
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS lne
    WHERE lne.status = whs.status
);


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

SELECT id FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT value FROM products AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM categories AS empl
    WHERE empl.status = mgr.status
);


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

SELECT code FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT salary FROM warehouses AS ord
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.level = ord.level
);


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

SELECT id FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT amount FROM invoices AS catg
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.type = catg.type
);


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

SELECT name FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.status = mgr.status
);


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

SELECT id FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.status = sale.status
);


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

SELECT amount FROM projects AS prod
WHERE code IN (
    SELECT code FROM orders AS budg
    WHERE budg.level = prod.level
);


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

SELECT salary FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.status = ordr.status
);


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

SELECT id FROM suppliers AS budg
WHERE type IN (
    SELECT type FROM transactions AS acct
    WHERE acct.level = budg.level
);


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

SELECT code FROM warehouses AS sale
WHERE value > (
    SELECT SUM(amount) FROM suppliers AS acct
    WHERE acct.code = sale.code
);


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

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


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

SELECT name FROM invoices AS ordr
WHERE id IN (
    SELECT id FROM shipments AS emp
    WHERE emp.type = ordr.type
);


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

SELECT name FROM tasks AS dept
WHERE level IN (
    SELECT level FROM invoices AS cust
    WHERE cust.type = dept.type
);


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

SELECT value FROM products AS prod
WHERE id IN (
    SELECT id FROM warehouses AS emp
    WHERE emp.type = prod.type
);


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

SELECT code FROM customers AS mgr
WHERE value > (
    SELECT COUNT(salary) FROM orders AS ord
    WHERE ord.status = mgr.status
);


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

SELECT salary FROM branches AS cust
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.type = cust.type
);


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

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


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

SELECT id FROM accounts AS budg
WHERE status IN (
    SELECT status FROM warehouses AS empl
    WHERE empl.code = budg.code
);


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

SELECT amount FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.type = ord.type
);


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

SELECT code FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.type = catg.type
);


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

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


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

SELECT code FROM projects AS schd
WHERE value > (
    SELECT MIN(salary) FROM shipments AS sale
    WHERE sale.status = schd.status
);


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

SELECT salary FROM accounts AS lne
WHERE level IN (
    SELECT level FROM products AS dept
    WHERE dept.level = lne.level
);


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

SELECT salary FROM transactions AS lne
WHERE amount > (
    SELECT MIN(salary) FROM employees AS empl
    WHERE empl.status = lne.status
);


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

SELECT code FROM suppliers AS sale
WHERE amount > (
    SELECT MIN(value) FROM customers AS cust
    WHERE cust.id = sale.id
);


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

SELECT id FROM products AS dept
WHERE salary > (
    SELECT MAX(salary) FROM warehouses AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT amount FROM customers AS whs
WHERE level IN (
    SELECT level FROM tasks AS emp
    WHERE emp.code = whs.code
);


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

SELECT amount FROM warehouses AS schd
WHERE type IN (
    SELECT type FROM transactions AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT id FROM projects AS cust
WHERE value > (
    SELECT MAX(amount) FROM orders AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT name FROM orders AS acct
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT name FROM customers AS prod
WHERE amount > (
    SELECT SUM(value) FROM categories AS mgr
    WHERE mgr.id = prod.id
);


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

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


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.type = dept.type
);


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

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


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

SELECT salary FROM regions AS sale
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS dept
    WHERE dept.status = sale.status
);


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

SELECT id FROM regions AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS ord
    WHERE ord.type = lne.type
);


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

SELECT salary FROM invoices AS budg
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.level = budg.level
);


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

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


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

SELECT name FROM products AS whs
WHERE amount > (
    SELECT MAX(value) FROM projects AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT id FROM warehouses AS acct
WHERE salary > (
    SELECT MAX(salary) FROM branches AS shp
    WHERE shp.type = acct.type
);


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

SELECT name FROM accounts AS whs
WHERE amount > (
    SELECT AVG(value) FROM transactions AS ordr
    WHERE ordr.id = whs.id
);


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

SELECT amount FROM products AS cust
WHERE value > (
    SELECT MIN(amount) FROM departments AS lne
    WHERE lne.type = cust.type
);


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

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


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

SELECT amount FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.level = srvc.level
);


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

SELECT salary FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.level = empl.level
);


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

SELECT code FROM departments AS prod
WHERE amount > (
    SELECT SUM(amount) FROM invoices AS dept
    WHERE dept.id = prod.id
);


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

SELECT id FROM projects AS ord
WHERE status IN (
    SELECT status FROM accounts AS mgr
    WHERE mgr.code = ord.code
);


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

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


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

SELECT id FROM products AS prod
WHERE status IN (
    SELECT status FROM tasks AS srvc
    WHERE srvc.level = prod.level
);


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

SELECT code FROM departments AS emp
WHERE code IN (
    SELECT code FROM branches AS schd
    WHERE schd.code = emp.code
);


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

SELECT value FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.type = txn.type
);


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

SELECT code FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.level = lne.level
);


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

SELECT name FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.code = catg.code
);


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

SELECT id FROM departments AS prod
WHERE value > (
    SELECT MIN(salary) FROM branches AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT name FROM customers AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS acct
    WHERE acct.type = ord.type
);


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

SELECT amount FROM projects AS budg
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.id = budg.id
);


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

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


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

SELECT code FROM customers AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM regions AS txn
    WHERE txn.code = mgr.code
);


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

SELECT value FROM tasks AS ord
WHERE code IN (
    SELECT code FROM categories AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT amount FROM invoices AS emp
WHERE type IN (
    SELECT type FROM warehouses AS txn
    WHERE txn.id = emp.id
);


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

SELECT value FROM warehouses AS empl
WHERE salary > (
    SELECT AVG(salary) FROM departments AS rgn
    WHERE rgn.type = empl.type
);


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

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


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

SELECT code FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.status = budg.status
);


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

SELECT value FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.status = prod.status
);


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

SELECT code FROM transactions AS whs
WHERE value > (
    SELECT MAX(amount) FROM shipments AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT id FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.level = empl.level
);


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

SELECT code FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.id = rgn.id
);


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

SELECT salary FROM projects AS schd
WHERE level IN (
    SELECT level FROM branches AS budg
    WHERE budg.status = schd.status
);


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

SELECT amount FROM transactions AS mgr
WHERE level IN (
    SELECT level FROM employees AS dept
    WHERE dept.type = mgr.type
);


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

SELECT id FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT value FROM departments AS ordr
WHERE amount > (
    SELECT MAX(amount) FROM employees AS sale
    WHERE sale.type = ordr.type
);


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

SELECT amount FROM warehouses AS inv
WHERE level IN (
    SELECT level FROM tasks AS whs
    WHERE whs.type = inv.type
);


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

SELECT id FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.level = emp.level
);


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

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


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

SELECT code FROM departments AS catg
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS emp
    WHERE emp.level = catg.level
);


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

SELECT name FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM warehouses AS ord
    WHERE ord.id = ordr.id
);


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

SELECT name FROM invoices AS srvc
WHERE level IN (
    SELECT level FROM suppliers AS mgr
    WHERE mgr.level = srvc.level
);


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

SELECT name FROM warehouses AS budg
WHERE value > (
    SELECT COUNT(value) FROM suppliers AS lne
    WHERE lne.code = budg.code
);


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

SELECT name FROM transactions AS budg
WHERE amount > (
    SELECT AVG(salary) FROM orders AS srvc
    WHERE srvc.level = budg.level
);


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

SELECT code FROM employees AS schd
WHERE level IN (
    SELECT level FROM invoices AS ordr
    WHERE ordr.id = schd.id
);


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

SELECT amount FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = lne.level
);


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

SELECT amount FROM departments AS dept
WHERE level IN (
    SELECT level FROM suppliers AS emp
    WHERE emp.status = dept.status
);


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

SELECT value FROM invoices AS ord
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS emp
    WHERE emp.status = ord.status
);


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

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


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

SELECT value FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.status = sale.status
);


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

SELECT code FROM orders AS whs
WHERE id IN (
    SELECT id FROM invoices AS shp
    WHERE shp.id = whs.id
);


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

SELECT code FROM suppliers AS sale
WHERE level IN (
    SELECT level FROM shipments AS ord
    WHERE ord.level = sale.level
);


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

SELECT amount FROM products AS emp
WHERE status IN (
    SELECT status FROM shipments AS empl
    WHERE empl.id = emp.id
);


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

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


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

SELECT salary FROM categories AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS ord
    WHERE ord.type = inv.type
);


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

SELECT value FROM orders AS prod
WHERE type IN (
    SELECT type FROM departments AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT value FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.status = cust.status
);


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

SELECT amount FROM accounts AS budg
WHERE value > (
    SELECT COUNT(value) FROM customers AS catg
    WHERE catg.status = budg.status
);


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

SELECT id FROM warehouses AS emp
WHERE salary > (
    SELECT MAX(amount) FROM departments AS txn
    WHERE txn.id = emp.id
);


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

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


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

SELECT id FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT id FROM invoices AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM customers AS budg
    WHERE budg.status = mgr.status
);


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

SELECT code FROM regions AS empl
WHERE id IN (
    SELECT id FROM employees AS sale
    WHERE sale.code = empl.code
);


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

SELECT value FROM branches AS acct
WHERE type IN (
    SELECT type FROM products AS cust
    WHERE cust.status = acct.status
);


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

SELECT code FROM warehouses AS catg
WHERE amount > (
    SELECT MIN(value) FROM regions AS ord
    WHERE ord.level = catg.level
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT name FROM accounts AS whs
WHERE level IN (
    SELECT level FROM tasks AS ord
    WHERE ord.type = whs.type
);


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

SELECT name FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.code = shp.code
);


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

SELECT amount FROM regions AS mgr
WHERE salary > (
    SELECT MAX(value) FROM shipments AS empl
    WHERE empl.status = mgr.status
);


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

SELECT salary FROM accounts AS emp
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS inv
    WHERE inv.status = emp.status
);


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

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


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

SELECT code FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.status = rgn.status
);


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

SELECT id FROM transactions AS empl
WHERE status IN (
    SELECT status FROM branches AS acct
    WHERE acct.id = empl.id
);


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

SELECT salary FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.type = emp.type
);


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

SELECT value FROM regions AS txn
WHERE salary > (
    SELECT MAX(salary) FROM projects AS dept
    WHERE dept.code = txn.code
);


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

SELECT id FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.type = ord.type
);


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

SELECT salary FROM transactions AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS acct
    WHERE acct.id = mgr.id
);


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

SELECT salary FROM projects AS acct
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS srvc
    WHERE srvc.level = acct.level
);


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

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


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

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


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

SELECT amount FROM suppliers AS lne
WHERE value > (
    SELECT SUM(salary) FROM invoices AS ord
    WHERE ord.status = lne.status
);


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

SELECT code FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.id = txn.id
);


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

SELECT name FROM suppliers AS cust
WHERE level IN (
    SELECT level FROM orders AS whs
    WHERE whs.type = cust.type
);


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

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


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

SELECT value FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.level = inv.level
);


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

SELECT code FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.status = ordr.status
);


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

SELECT value FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.code = emp.code
);


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

SELECT name FROM projects AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM accounts AS inv
    WHERE inv.id = ordr.id
);


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

SELECT value FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = sale.code
);


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

SELECT salary FROM warehouses AS cust
WHERE salary > (
    SELECT MAX(value) FROM employees AS catg
    WHERE catg.id = cust.id
);


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

SELECT value FROM accounts AS empl
WHERE status IN (
    SELECT status FROM orders AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT code FROM shipments AS acct
WHERE level IN (
    SELECT level FROM suppliers AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT name FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.code = cust.code
);


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

SELECT name FROM shipments AS txn
WHERE salary > (
    SELECT MAX(amount) FROM warehouses AS lne
    WHERE lne.code = txn.code
);


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

SELECT amount FROM projects AS acct
WHERE salary > (
    SELECT SUM(amount) FROM departments AS lne
    WHERE lne.level = acct.level
);


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

SELECT code FROM shipments AS ord
WHERE amount > (
    SELECT AVG(amount) FROM orders AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT id FROM branches AS inv
WHERE status IN (
    SELECT status FROM orders AS emp
    WHERE emp.code = inv.code
);


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

SELECT id FROM regions AS schd
WHERE type IN (
    SELECT type FROM products AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT salary FROM departments AS dept
WHERE code IN (
    SELECT code FROM shipments AS txn
    WHERE txn.code = dept.code
);


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

SELECT name FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM products AS ord
    WHERE ord.code = ordr.code
);


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

SELECT name FROM orders AS whs
WHERE value > (
    SELECT COUNT(value) FROM invoices AS prod
    WHERE prod.level = whs.level
);


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

SELECT code FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT salary FROM orders AS ord
WHERE level IN (
    SELECT level FROM tasks AS prod
    WHERE prod.code = ord.code
);


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

SELECT value FROM suppliers AS lne
WHERE amount > (
    SELECT MAX(value) FROM orders AS catg
    WHERE catg.code = lne.code
);


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

SELECT amount FROM warehouses AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS whs
    WHERE whs.status = txn.status
);


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

SELECT code FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.id = whs.id
);


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

SELECT amount FROM branches AS ordr
WHERE id IN (
    SELECT id FROM employees AS budg
    WHERE budg.code = ordr.code
);


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

SELECT id FROM customers AS srvc
WHERE value > (
    SELECT AVG(salary) FROM regions AS catg
    WHERE catg.level = srvc.level
);


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

SELECT id FROM transactions AS shp
WHERE status IN (
    SELECT status FROM tasks AS schd
    WHERE schd.type = shp.type
);


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

SELECT code FROM shipments AS srvc
WHERE value > (
    SELECT SUM(value) FROM suppliers AS sale
    WHERE sale.level = srvc.level
);


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

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


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

SELECT code FROM transactions AS ord
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS catg
    WHERE catg.code = ord.code
);


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

SELECT name FROM regions AS catg
WHERE status IN (
    SELECT status FROM transactions AS shp
    WHERE shp.type = catg.type
);


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

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


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

SELECT name FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = emp.type
);


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

SELECT value FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.code = lne.code
);


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

SELECT id FROM tasks AS cust
WHERE value > (
    SELECT MIN(value) FROM accounts AS dept
    WHERE dept.id = cust.id
);


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

SELECT amount FROM projects AS prod
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS budg
    WHERE budg.type = prod.type
);


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

SELECT value FROM customers AS ord
WHERE status IN (
    SELECT status FROM categories AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT salary FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.id = txn.id
);


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

SELECT name FROM branches AS budg
WHERE amount > (
    SELECT MAX(value) FROM employees AS schd
    WHERE schd.id = budg.id
);


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

SELECT value FROM transactions AS schd
WHERE type IN (
    SELECT type FROM suppliers AS cust
    WHERE cust.code = schd.code
);


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

SELECT name FROM customers AS cust
WHERE level IN (
    SELECT level FROM suppliers AS sale
    WHERE sale.type = cust.type
);


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

SELECT amount FROM shipments AS whs
WHERE code IN (
    SELECT code FROM warehouses AS acct
    WHERE acct.status = whs.status
);


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

SELECT value FROM invoices AS budg
WHERE amount > (
    SELECT MIN(amount) FROM regions AS rgn
    WHERE rgn.type = budg.type
);


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

SELECT value FROM shipments AS sale
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.level = sale.level
);


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

SELECT value FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = emp.type
);


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

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


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

SELECT name FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.code = ordr.code
);


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

SELECT value FROM projects AS prod
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS whs
    WHERE whs.code = prod.code
);


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

SELECT name FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.id = shp.id
);


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

SELECT name FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.level = schd.level
);


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

SELECT value FROM employees AS schd
WHERE status IN (
    SELECT status FROM tasks AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT amount FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.status = ordr.status
);


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

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


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

SELECT amount FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.status = lne.status
);


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

SELECT name FROM shipments AS cust
WHERE value > (
    SELECT COUNT(salary) FROM products AS catg
    WHERE catg.status = cust.status
);


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

SELECT name FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT salary FROM customers AS schd
WHERE value > (
    SELECT SUM(amount) FROM regions AS sale
    WHERE sale.status = schd.status
);


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

SELECT id FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.id = emp.id
);


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

SELECT salary FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.type = txn.type
);


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

SELECT code FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.id = srvc.id
);


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

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


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

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


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

SELECT code FROM products AS whs
WHERE id IN (
    SELECT id FROM transactions AS emp
    WHERE emp.code = whs.code
);


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

SELECT value FROM employees AS schd
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.type = schd.type
);


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

SELECT salary FROM transactions AS shp
WHERE status IN (
    SELECT status FROM suppliers AS txn
    WHERE txn.id = shp.id
);


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

SELECT amount FROM regions AS srvc
WHERE status IN (
    SELECT status FROM invoices AS cust
    WHERE cust.code = srvc.code
);


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

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


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

SELECT name FROM employees AS ordr
WHERE amount > (
    SELECT AVG(value) FROM departments AS catg
    WHERE catg.code = ordr.code
);


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

SELECT amount FROM regions AS empl
WHERE salary > (
    SELECT MAX(amount) FROM branches AS budg
    WHERE budg.id = empl.id
);


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

SELECT code FROM invoices AS shp
WHERE code IN (
    SELECT code FROM tasks AS lne
    WHERE lne.type = shp.type
);


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

SELECT id FROM branches AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM departments AS lne
    WHERE lne.code = mgr.code
);


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

SELECT name FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.level = shp.level
);


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

SELECT name FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.status = dept.status
);


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

SELECT salary FROM customers AS txn
WHERE level IN (
    SELECT level FROM categories AS schd
    WHERE schd.code = txn.code
);


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

SELECT amount FROM projects AS emp
WHERE amount > (
    SELECT AVG(value) FROM customers AS ord
    WHERE ord.status = emp.status
);


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

SELECT code FROM shipments AS cust
WHERE code IN (
    SELECT code FROM transactions AS budg
    WHERE budg.status = cust.status
);


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

SELECT value FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.status = dept.status
);


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

SELECT amount FROM warehouses AS acct
WHERE level IN (
    SELECT level FROM departments AS lne
    WHERE lne.type = acct.type
);


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

SELECT amount FROM products AS ord
WHERE amount > (
    SELECT AVG(value) FROM customers AS inv
    WHERE inv.level = ord.level
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.level = rgn.level
);


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

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


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

SELECT amount FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM products AS inv
    WHERE inv.level = ordr.level
);


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

SELECT salary FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.status = budg.status
);


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

SELECT name FROM suppliers AS empl
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS emp
    WHERE emp.id = empl.id
);


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

SELECT amount FROM regions AS sale
WHERE level IN (
    SELECT level FROM products AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT amount FROM suppliers AS txn
WHERE level IN (
    SELECT level FROM customers AS whs
    WHERE whs.type = txn.type
);


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

SELECT code FROM invoices AS ord
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS mgr
    WHERE mgr.type = ord.type
);


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

SELECT id FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.type = budg.type
);


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

SELECT value FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.code = acct.code
);


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

SELECT id FROM transactions AS catg
WHERE status IN (
    SELECT status FROM departments AS sale
    WHERE sale.type = catg.type
);


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

SELECT code FROM projects AS shp
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS whs
    WHERE whs.status = shp.status
);


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

SELECT amount FROM projects AS emp
WHERE status IN (
    SELECT status FROM transactions AS shp
    WHERE shp.status = emp.status
);


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

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


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

SELECT id FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.id = acct.id
);


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

SELECT id FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.code = acct.code
);


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

SELECT id FROM employees AS budg
WHERE amount > (
    SELECT AVG(amount) FROM departments AS txn
    WHERE txn.status = budg.status
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.code = prod.code
);


Prompt:
Schema:
  suppliers (alias: srvc)(level, salary, name, id)
  branches(value, id, salary, code)
Task: Retrieve code from suppliers with salary above the SUM(salary) of branches rows sharing the same code.
SQL:

SELECT code FROM suppliers AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM branches AS inv
    WHERE inv.code = srvc.code
);


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

SELECT salary FROM products AS shp
WHERE code IN (
    SELECT code FROM projects AS inv
    WHERE inv.code = shp.code
);


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

SELECT id FROM branches AS shp
WHERE value > (
    SELECT MAX(value) FROM departments AS whs
    WHERE whs.id = shp.id
);


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

SELECT value FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.type = lne.type
);


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

SELECT salary FROM projects AS empl
WHERE value > (
    SELECT MAX(amount) FROM branches AS acct
    WHERE acct.code = empl.code
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.code = rgn.code
);


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

SELECT code FROM branches AS txn
WHERE value > (
    SELECT MAX(salary) FROM employees AS srvc
    WHERE srvc.code = txn.code
);


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

SELECT id FROM customers AS shp
WHERE code IN (
    SELECT code FROM accounts AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT id FROM shipments AS mgr
WHERE level IN (
    SELECT level FROM regions AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT salary FROM suppliers AS prod
WHERE id IN (
    SELECT id FROM branches AS dept
    WHERE dept.id = prod.id
);


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

SELECT id FROM regions AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM transactions AS shp
    WHERE shp.code = mgr.code
);


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

SELECT salary FROM orders AS schd
WHERE salary > (
    SELECT MAX(salary) FROM customers AS sale
    WHERE sale.id = schd.id
);


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

SELECT salary FROM accounts AS dept
WHERE code IN (
    SELECT code FROM regions AS prod
    WHERE prod.level = dept.level
);


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

SELECT name FROM orders AS dept
WHERE salary > (
    SELECT MIN(value) FROM regions AS whs
    WHERE whs.level = dept.level
);


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

SELECT code FROM invoices AS budg
WHERE status IN (
    SELECT status FROM regions AS prod
    WHERE prod.level = budg.level
);


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

SELECT salary FROM categories AS dept
WHERE salary > (
    SELECT MAX(amount) FROM suppliers AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT value FROM products AS emp
WHERE status IN (
    SELECT status FROM accounts AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT salary FROM tasks AS catg
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS budg
    WHERE budg.code = catg.code
);


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

SELECT value FROM departments AS schd
WHERE code IN (
    SELECT code FROM regions AS srvc
    WHERE srvc.level = schd.level
);


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

SELECT value FROM warehouses AS cust
WHERE amount > (
    SELECT MAX(value) FROM employees AS sale
    WHERE sale.level = cust.level
);


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

SELECT salary FROM tasks AS sale
WHERE level IN (
    SELECT level FROM employees AS inv
    WHERE inv.type = sale.type
);


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

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


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

SELECT amount FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.level = emp.level
);


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

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


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

SELECT amount FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.status = lne.status
);


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

SELECT value FROM projects AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM branches AS emp
    WHERE emp.type = ordr.type
);


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

SELECT value FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.level = lne.level
);


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

SELECT code FROM employees AS emp
WHERE level IN (
    SELECT level FROM tasks AS rgn
    WHERE rgn.type = emp.type
);


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

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


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

SELECT salary FROM customers AS txn
WHERE value > (
    SELECT MAX(amount) FROM projects AS catg
    WHERE catg.level = txn.level
);


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

SELECT value FROM transactions AS ord
WHERE code IN (
    SELECT code FROM regions AS acct
    WHERE acct.code = ord.code
);


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

SELECT id FROM transactions AS cust
WHERE code IN (
    SELECT code FROM departments AS shp
    WHERE shp.level = cust.level
);


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

SELECT code FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = schd.id
);


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

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


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

SELECT name FROM invoices AS srvc
WHERE amount > (
    SELECT SUM(value) FROM branches AS emp
    WHERE emp.level = srvc.level
);


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

SELECT amount FROM departments AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS emp
    WHERE emp.type = rgn.type
);


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

SELECT amount FROM tasks AS txn
WHERE value > (
    SELECT AVG(salary) FROM invoices AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT id FROM regions AS emp
WHERE salary > (
    SELECT AVG(value) FROM shipments AS srvc
    WHERE srvc.level = emp.level
);


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

SELECT code FROM suppliers AS whs
WHERE amount > (
    SELECT MIN(amount) FROM orders AS empl
    WHERE empl.level = whs.level
);


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

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


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.code = whs.code
);


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

SELECT amount FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = ord.code
);


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

SELECT name FROM orders AS emp
WHERE value > (
    SELECT COUNT(amount) FROM branches AS budg
    WHERE budg.id = emp.id
);


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

SELECT name FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.code = acct.code
);


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

SELECT id FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.type = ordr.type
);


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

SELECT salary FROM warehouses AS empl
WHERE value > (
    SELECT AVG(value) FROM invoices AS mgr
    WHERE mgr.level = empl.level
);


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

SELECT code FROM tasks AS sale
WHERE level IN (
    SELECT level FROM suppliers AS empl
    WHERE empl.level = sale.level
);


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

SELECT amount FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.level = acct.level
);


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

SELECT amount FROM tasks AS empl
WHERE type IN (
    SELECT type FROM accounts AS txn
    WHERE txn.id = empl.id
);


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

SELECT amount FROM orders AS txn
WHERE level IN (
    SELECT level FROM projects AS ord
    WHERE ord.status = txn.status
);


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

SELECT id FROM employees AS acct
WHERE id IN (
    SELECT id FROM shipments AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT value FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.id = ord.id
);


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

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


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

SELECT name FROM employees AS ordr
WHERE code IN (
    SELECT code FROM transactions AS schd
    WHERE schd.code = ordr.code
);


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

SELECT value FROM categories AS rgn
WHERE status IN (
    SELECT status FROM shipments AS txn
    WHERE txn.type = rgn.type
);


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

SELECT amount FROM invoices AS schd
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.id = schd.id
);


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

SELECT salary FROM accounts AS catg
WHERE salary > (
    SELECT COUNT(value) FROM customers AS whs
    WHERE whs.code = catg.code
);


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

SELECT amount FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.code = dept.code
);


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

SELECT code FROM departments AS sale
WHERE amount > (
    SELECT SUM(amount) FROM orders AS emp
    WHERE emp.level = sale.level
);


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

SELECT salary FROM suppliers AS sale
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.code = sale.code
);


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

SELECT salary FROM branches AS budg
WHERE status IN (
    SELECT status FROM categories AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT salary FROM customers AS shp
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS prod
    WHERE prod.type = shp.type
);


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

SELECT salary FROM categories AS schd
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.status = schd.status
);


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

SELECT amount FROM orders AS rgn
WHERE status IN (
    SELECT status FROM products AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT code FROM tasks AS ord
WHERE value > (
    SELECT MAX(value) FROM regions AS empl
    WHERE empl.type = ord.type
);