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

SELECT value FROM employees AS cust
WHERE status IN (
    SELECT status FROM projects AS txn
    WHERE txn.code = cust.code
);


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

SELECT value FROM customers AS empl
WHERE level IN (
    SELECT level FROM invoices AS catg
    WHERE catg.status = empl.status
);


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

SELECT salary FROM transactions AS schd
WHERE type IN (
    SELECT type FROM shipments AS shp
    WHERE shp.id = schd.id
);


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

SELECT id FROM orders AS whs
WHERE status IN (
    SELECT status FROM accounts AS dept
    WHERE dept.type = whs.type
);


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

SELECT amount FROM regions AS lne
WHERE salary > (
    SELECT MIN(value) FROM orders AS prod
    WHERE prod.type = lne.type
);


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

SELECT amount FROM products AS lne
WHERE code IN (
    SELECT code FROM invoices AS emp
    WHERE emp.type = lne.type
);


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

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


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

SELECT id FROM transactions AS mgr
WHERE amount > (
    SELECT AVG(salary) FROM regions AS lne
    WHERE lne.type = mgr.type
);


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

SELECT id FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.level = txn.level
);


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

SELECT code FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.level = dept.level
);


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

SELECT name FROM suppliers AS acct
WHERE value > (
    SELECT SUM(amount) FROM customers AS txn
    WHERE txn.status = acct.status
);


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

SELECT name FROM customers AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM branches AS budg
    WHERE budg.level = acct.level
);


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

SELECT code FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.type = shp.type
);


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

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


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

SELECT value FROM employees AS txn
WHERE amount > (
    SELECT COUNT(amount) FROM departments AS ordr
    WHERE ordr.id = txn.id
);


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

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


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

SELECT name FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = whs.type
);


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

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


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

SELECT salary FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.type = srvc.type
);


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

SELECT name FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT id FROM branches AS emp
WHERE code IN (
    SELECT code FROM accounts AS lne
    WHERE lne.level = emp.level
);


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

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


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

SELECT salary FROM products AS rgn
WHERE salary > (
    SELECT COUNT(salary) FROM employees AS catg
    WHERE catg.type = rgn.type
);


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

SELECT amount FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT amount FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.level = dept.level
);


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

SELECT name FROM tasks AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM departments AS lne
    WHERE lne.code = ord.code
);


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

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


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

SELECT name FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.status = mgr.status
);


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.type = ord.type
);


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

SELECT salary FROM departments AS shp
WHERE type IN (
    SELECT type FROM orders AS ord
    WHERE ord.level = shp.level
);


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

SELECT id FROM tasks AS cust
WHERE level IN (
    SELECT level FROM invoices AS catg
    WHERE catg.type = cust.type
);


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

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


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

SELECT code FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.level = acct.level
);


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

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


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

SELECT salary FROM departments AS rgn
WHERE id IN (
    SELECT id FROM regions AS sale
    WHERE sale.status = rgn.status
);


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

SELECT salary FROM employees AS txn
WHERE salary > (
    SELECT AVG(amount) FROM projects AS rgn
    WHERE rgn.id = txn.id
);


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

SELECT code FROM employees AS emp
WHERE value > (
    SELECT AVG(salary) FROM products AS budg
    WHERE budg.status = emp.status
);


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

SELECT name FROM customers AS txn
WHERE id IN (
    SELECT id FROM transactions AS ord
    WHERE ord.id = txn.id
);


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

SELECT amount FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.level = lne.level
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = inv.status
);


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

SELECT id FROM suppliers AS budg
WHERE value > (
    SELECT MAX(value) FROM tasks AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT name FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.level = emp.level
);


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

SELECT name FROM customers AS dept
WHERE value > (
    SELECT MIN(amount) FROM employees AS ord
    WHERE ord.id = dept.id
);


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

SELECT name FROM suppliers AS empl
WHERE value > (
    SELECT MAX(amount) FROM orders AS sale
    WHERE sale.type = empl.type
);


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

SELECT amount FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.id = mgr.id
);


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

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


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

SELECT code FROM warehouses AS budg
WHERE id IN (
    SELECT id FROM regions AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT salary FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.status = shp.status
);


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

SELECT amount FROM invoices AS sale
WHERE amount > (
    SELECT MAX(amount) FROM regions AS txn
    WHERE txn.type = sale.type
);


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

SELECT id FROM invoices AS ordr
WHERE amount > (
    SELECT COUNT(value) FROM employees AS budg
    WHERE budg.type = ordr.type
);


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

SELECT amount FROM branches AS dept
WHERE id IN (
    SELECT id FROM accounts AS lne
    WHERE lne.level = dept.level
);


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

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


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

SELECT id FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.id = catg.id
);


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

SELECT name FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.level = srvc.level
);


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

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


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

SELECT amount FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.code = txn.code
);


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

SELECT name FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT value FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = cust.code
);


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

SELECT name FROM branches AS whs
WHERE status IN (
    SELECT status FROM tasks AS lne
    WHERE lne.id = whs.id
);


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

SELECT code FROM projects AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS whs
    WHERE whs.type = rgn.type
);


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

SELECT value FROM suppliers AS inv
WHERE amount > (
    SELECT MAX(value) FROM regions AS ord
    WHERE ord.id = inv.id
);


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

SELECT name FROM customers AS txn
WHERE salary > (
    SELECT AVG(value) FROM tasks AS ordr
    WHERE ordr.level = txn.level
);


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

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


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

SELECT salary FROM suppliers AS prod
WHERE amount > (
    SELECT MIN(amount) FROM employees AS sale
    WHERE sale.status = prod.status
);


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

SELECT id FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.code = dept.code
);


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

SELECT code FROM projects AS empl
WHERE value > (
    SELECT MIN(value) FROM accounts AS lne
    WHERE lne.type = empl.type
);


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

SELECT salary FROM orders AS catg
WHERE salary > (
    SELECT MAX(amount) FROM projects AS ord
    WHERE ord.type = catg.type
);


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

SELECT salary FROM regions AS sale
WHERE amount > (
    SELECT MIN(value) FROM accounts AS srvc
    WHERE srvc.level = sale.level
);


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

SELECT amount FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.code = inv.code
);


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

SELECT value FROM suppliers AS mgr
WHERE level IN (
    SELECT level FROM branches AS schd
    WHERE schd.code = mgr.code
);


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

SELECT amount FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.code = sale.code
);


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

SELECT code FROM categories AS dept
WHERE value > (
    SELECT MIN(amount) FROM customers AS inv
    WHERE inv.type = dept.type
);


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

SELECT id FROM invoices AS catg
WHERE level IN (
    SELECT level FROM shipments AS sale
    WHERE sale.code = catg.code
);


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

SELECT id FROM orders AS dept
WHERE salary > (
    SELECT AVG(amount) FROM departments AS budg
    WHERE budg.status = dept.status
);


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

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


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

SELECT salary FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.code = catg.code
);


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

SELECT name FROM warehouses AS empl
WHERE status IN (
    SELECT status FROM categories AS shp
    WHERE shp.id = empl.id
);


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

SELECT amount FROM suppliers AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM tasks AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT name FROM orders AS ord
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS whs
    WHERE whs.status = ord.status
);


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

SELECT value FROM tasks AS prod
WHERE id IN (
    SELECT id FROM orders AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT value FROM branches AS whs
WHERE value > (
    SELECT AVG(amount) FROM employees AS catg
    WHERE catg.status = whs.status
);


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

SELECT code FROM branches AS rgn
WHERE amount > (
    SELECT SUM(value) FROM customers AS dept
    WHERE dept.code = rgn.code
);


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

SELECT amount FROM customers AS prod
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS cust
    WHERE cust.level = prod.level
);


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

SELECT id FROM departments AS txn
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS mgr
    WHERE mgr.status = txn.status
);


Prompt:
Schema:
  employees (alias: prod)(level, amount, status, type)
  tasks(amount, type, level, date)
Task: Retrieve salary from employees with salary above the AVG(amount) of tasks rows sharing the same type.
SQL:

SELECT salary FROM employees AS prod
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS catg
    WHERE catg.type = prod.type
);


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

SELECT code FROM tasks AS cust
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS inv
    WHERE inv.code = cust.code
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.code = rgn.code
);


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

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


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

SELECT amount FROM accounts AS ord
WHERE value > (
    SELECT COUNT(value) FROM warehouses AS acct
    WHERE acct.status = ord.status
);


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

SELECT id FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT id FROM categories AS whs
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.status = whs.status
);


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

SELECT code FROM products AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT name FROM departments AS mgr
WHERE type IN (
    SELECT type FROM tasks AS emp
    WHERE emp.id = mgr.id
);


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

SELECT salary FROM warehouses AS budg
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.level = dept.level
);


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

SELECT amount FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.status = txn.status
);


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

SELECT name FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT amount FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.type = acct.type
);


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

SELECT code FROM accounts AS budg
WHERE code IN (
    SELECT code FROM products AS lne
    WHERE lne.code = budg.code
);


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

SELECT id FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.level = ord.level
);


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

SELECT amount FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.code = inv.code
);


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

SELECT salary FROM regions AS dept
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS inv
    WHERE inv.status = dept.status
);


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

SELECT salary FROM projects AS prod
WHERE level IN (
    SELECT level FROM invoices AS ord
    WHERE ord.level = prod.level
);


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

SELECT code FROM tasks AS whs
WHERE level IN (
    SELECT level FROM shipments AS mgr
    WHERE mgr.id = whs.id
);


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

SELECT amount FROM invoices AS sale
WHERE level IN (
    SELECT level FROM branches AS schd
    WHERE schd.status = sale.status
);


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

SELECT value FROM customers AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM shipments AS txn
    WHERE txn.level = schd.level
);


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

SELECT code FROM warehouses AS emp
WHERE type IN (
    SELECT type FROM categories AS dept
    WHERE dept.status = emp.status
);


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

SELECT id FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.id = sale.id
);


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

SELECT value FROM departments AS ord
WHERE level IN (
    SELECT level FROM orders AS prod
    WHERE prod.level = ord.level
);


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

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


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

SELECT amount FROM suppliers AS dept
WHERE id IN (
    SELECT id FROM regions AS schd
    WHERE schd.type = dept.type
);


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

SELECT id FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.status = sale.status
);


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

SELECT salary FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.type = schd.type
);


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

SELECT code FROM products AS cust
WHERE level IN (
    SELECT level FROM warehouses AS acct
    WHERE acct.id = cust.id
);


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

SELECT code FROM suppliers AS rgn
WHERE salary > (
    SELECT MIN(value) FROM products AS txn
    WHERE txn.id = rgn.id
);


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

SELECT code FROM accounts AS lne
WHERE type IN (
    SELECT type FROM transactions AS emp
    WHERE emp.level = lne.level
);


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

SELECT id FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.level = prod.level
);


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

SELECT id FROM regions AS ord
WHERE value > (
    SELECT MAX(value) FROM customers AS budg
    WHERE budg.type = ord.type
);


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

SELECT amount FROM suppliers AS cust
WHERE value > (
    SELECT AVG(salary) FROM orders AS shp
    WHERE shp.level = cust.level
);


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

SELECT value FROM categories AS empl
WHERE value > (
    SELECT MAX(value) FROM invoices AS inv
    WHERE inv.type = empl.type
);


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

SELECT value FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.code = dept.code
);


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

SELECT value FROM branches AS catg
WHERE value > (
    SELECT AVG(value) FROM customers AS acct
    WHERE acct.type = catg.type
);


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

SELECT value FROM regions AS prod
WHERE amount > (
    SELECT MIN(amount) FROM products AS whs
    WHERE whs.id = prod.id
);


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

SELECT name FROM warehouses AS dept
WHERE id IN (
    SELECT id FROM shipments AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT value FROM suppliers AS emp
WHERE value > (
    SELECT SUM(salary) FROM branches AS budg
    WHERE budg.id = emp.id
);


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

SELECT id FROM projects AS lne
WHERE id IN (
    SELECT id FROM suppliers AS empl
    WHERE empl.level = lne.level
);


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

SELECT id FROM tasks AS dept
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS mgr
    WHERE mgr.type = dept.type
);


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

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


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

SELECT code FROM accounts AS mgr
WHERE level IN (
    SELECT level FROM customers AS empl
    WHERE empl.level = mgr.level
);


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

SELECT name FROM branches AS rgn
WHERE code IN (
    SELECT code FROM employees AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT name FROM suppliers AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS shp
    WHERE shp.type = ordr.type
);


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

SELECT amount FROM tasks AS cust
WHERE salary > (
    SELECT SUM(amount) FROM projects AS prod
    WHERE prod.level = cust.level
);


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

SELECT amount FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = shp.level
);


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

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


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

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


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

SELECT salary FROM regions AS mgr
WHERE value > (
    SELECT COUNT(amount) FROM products AS rgn
    WHERE rgn.code = mgr.code
);


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

SELECT value FROM accounts AS catg
WHERE status IN (
    SELECT status FROM customers AS prod
    WHERE prod.type = catg.type
);


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

SELECT name FROM employees AS rgn
WHERE type IN (
    SELECT type FROM categories AS dept
    WHERE dept.status = rgn.status
);


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

SELECT value FROM regions AS ord
WHERE id IN (
    SELECT id FROM shipments AS dept
    WHERE dept.status = ord.status
);


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

SELECT name FROM shipments AS lne
WHERE code IN (
    SELECT code FROM projects AS txn
    WHERE txn.status = lne.status
);


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

SELECT name FROM accounts AS prod
WHERE type IN (
    SELECT type FROM branches AS sale
    WHERE sale.type = prod.type
);


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

SELECT id FROM suppliers AS empl
WHERE salary > (
    SELECT MAX(value) FROM projects AS srvc
    WHERE srvc.status = empl.status
);


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

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


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

SELECT id FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.code = dept.code
);


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

SELECT value FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.type = shp.type
);


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

SELECT name FROM accounts AS whs
WHERE id IN (
    SELECT id FROM departments AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT value FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.status = acct.status
);


Prompt:
Schema:
  accounts (alias: cust)(id, amount, salary, value)
  shipments(code, level, id, salary)
Task: Retrieve salary from accounts with value above the MAX(salary) of shipments rows sharing the same code.
SQL:

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


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

SELECT salary FROM tasks AS whs
WHERE value > (
    SELECT COUNT(amount) FROM orders AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT salary FROM shipments AS lne
WHERE amount > (
    SELECT SUM(value) FROM invoices AS dept
    WHERE dept.type = lne.type
);


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

SELECT name FROM invoices AS inv
WHERE status IN (
    SELECT status FROM warehouses AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT amount FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = budg.code
);


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

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


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

SELECT amount FROM warehouses AS txn
WHERE status IN (
    SELECT status FROM suppliers AS empl
    WHERE empl.code = txn.code
);


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

SELECT name FROM employees AS ord
WHERE amount > (
    SELECT AVG(value) FROM categories AS schd
    WHERE schd.code = ord.code
);


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

SELECT id FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.level = empl.level
);


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

SELECT salary FROM categories AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS schd
    WHERE schd.status = srvc.status
);


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

SELECT code FROM regions AS schd
WHERE level IN (
    SELECT level FROM transactions AS ord
    WHERE ord.type = schd.type
);


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

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


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

SELECT name FROM products AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM orders AS dept
    WHERE dept.code = ordr.code
);


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

SELECT value FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.code = empl.code
);


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

SELECT salary FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.code = srvc.code
);


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

SELECT id FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.status = empl.status
);


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

SELECT code FROM transactions AS empl
WHERE salary > (
    SELECT MAX(salary) FROM categories AS budg
    WHERE budg.status = empl.status
);


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

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


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

SELECT id FROM employees AS budg
WHERE salary > (
    SELECT MIN(value) FROM transactions AS dept
    WHERE dept.status = budg.status
);


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

SELECT amount FROM shipments AS cust
WHERE salary > (
    SELECT MIN(amount) FROM orders AS whs
    WHERE whs.status = cust.status
);


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

SELECT amount FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = budg.type
);


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

SELECT code FROM warehouses AS sale
WHERE type IN (
    SELECT type FROM projects AS ord
    WHERE ord.type = sale.type
);


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

SELECT salary FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.type = ordr.type
);


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

SELECT id FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = txn.type
);


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

SELECT code FROM departments AS lne
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS acct
    WHERE acct.level = lne.level
);


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

SELECT code FROM accounts AS dept
WHERE salary > (
    SELECT MAX(value) FROM employees AS rgn
    WHERE rgn.type = dept.type
);


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

SELECT amount FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.status = srvc.status
);


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

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


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

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


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

SELECT value FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT value FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT name FROM shipments AS budg
WHERE salary > (
    SELECT AVG(value) FROM transactions AS inv
    WHERE inv.level = budg.level
);


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

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


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

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


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

SELECT value FROM tasks AS shp
WHERE id IN (
    SELECT id FROM shipments AS txn
    WHERE txn.code = shp.code
);


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

SELECT salary FROM accounts AS sale
WHERE level IN (
    SELECT level FROM customers AS dept
    WHERE dept.code = sale.code
);


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

SELECT amount FROM suppliers AS catg
WHERE value > (
    SELECT SUM(salary) FROM branches AS prod
    WHERE prod.id = catg.id
);


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

SELECT name FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.code = rgn.code
);


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

SELECT salary FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.level = catg.level
);


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

SELECT id FROM orders AS lne
WHERE level IN (
    SELECT level FROM departments AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT id FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM customers AS empl
    WHERE empl.type = whs.type
);


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

SELECT salary FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = rgn.type
);


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

SELECT code FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.type = rgn.type
);


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

SELECT value FROM accounts AS dept
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.level = dept.level
);


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

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


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

SELECT salary FROM projects AS shp
WHERE value > (
    SELECT MIN(amount) FROM tasks AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT value FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.level = prod.level
);


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

SELECT salary FROM branches AS ord
WHERE type IN (
    SELECT type FROM suppliers AS schd
    WHERE schd.level = ord.level
);


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

SELECT salary FROM categories AS mgr
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.status = mgr.status
);


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

SELECT salary FROM branches AS empl
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS shp
    WHERE shp.level = empl.level
);


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

SELECT name FROM categories AS sale
WHERE code IN (
    SELECT code FROM projects AS mgr
    WHERE mgr.type = sale.type
);


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

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


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

SELECT salary FROM shipments AS whs
WHERE code IN (
    SELECT code FROM transactions AS ord
    WHERE ord.level = whs.level
);


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

SELECT salary FROM employees AS prod
WHERE level IN (
    SELECT level FROM projects AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT amount FROM regions AS emp
WHERE amount > (
    SELECT AVG(salary) FROM customers AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT code FROM departments AS budg
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.status = budg.status
);


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

SELECT salary FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.status = inv.status
);


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

SELECT code FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = ordr.type
);


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

SELECT value FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.level = lne.level
);


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

SELECT id FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = lne.level
);


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

SELECT amount FROM warehouses AS cust
WHERE status IN (
    SELECT status FROM shipments AS emp
    WHERE emp.status = cust.status
);


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

SELECT name FROM tasks AS sale
WHERE status IN (
    SELECT status FROM shipments AS txn
    WHERE txn.status = sale.status
);


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

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


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

SELECT value FROM warehouses AS ordr
WHERE level IN (
    SELECT level FROM customers AS prod
    WHERE prod.id = ordr.id
);


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

SELECT amount FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.level = ord.level
);


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

SELECT name FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.id = shp.id
);


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

SELECT amount FROM categories AS mgr
WHERE code IN (
    SELECT code FROM branches AS prod
    WHERE prod.id = mgr.id
);


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

SELECT name FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.status = shp.status
);


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

SELECT code FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT value FROM warehouses AS dept
WHERE value > (
    SELECT COUNT(salary) FROM departments AS inv
    WHERE inv.level = dept.level
);


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

SELECT amount FROM shipments AS prod
WHERE code IN (
    SELECT code FROM projects AS sale
    WHERE sale.type = prod.type
);


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

SELECT name FROM regions AS cust
WHERE level IN (
    SELECT level FROM suppliers AS inv
    WHERE inv.status = cust.status
);


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

SELECT amount FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.type = sale.type
);


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

SELECT code FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.code = shp.code
);


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

SELECT salary FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.type = dept.type
);


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

SELECT code FROM departments AS shp
WHERE amount > (
    SELECT MAX(salary) FROM products AS budg
    WHERE budg.status = shp.status
);


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

SELECT name FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT code FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.id = srvc.id
);


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

SELECT name FROM categories AS budg
WHERE amount > (
    SELECT MAX(value) FROM regions AS cust
    WHERE cust.type = budg.type
);


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

SELECT code FROM accounts AS ord
WHERE id IN (
    SELECT id FROM branches AS lne
    WHERE lne.level = ord.level
);


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

SELECT amount FROM orders AS cust
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS emp
    WHERE emp.code = cust.code
);


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

SELECT code FROM transactions AS emp
WHERE value > (
    SELECT MAX(salary) FROM branches AS prod
    WHERE prod.level = emp.level
);


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

SELECT value FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.type = dept.type
);


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

SELECT salary FROM products AS schd
WHERE salary > (
    SELECT MAX(salary) FROM employees AS whs
    WHERE whs.status = schd.status
);


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

SELECT value FROM warehouses AS cust
WHERE value > (
    SELECT COUNT(value) FROM projects AS txn
    WHERE txn.level = cust.level
);


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

SELECT value FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT id FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.type = txn.type
);


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

SELECT id FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.type = mgr.type
);


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

SELECT amount FROM suppliers AS rgn
WHERE salary > (
    SELECT MAX(value) FROM invoices AS budg
    WHERE budg.code = rgn.code
);


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

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


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

SELECT name FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.code = prod.code
);


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

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


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

SELECT amount FROM branches AS lne
WHERE level IN (
    SELECT level FROM regions AS emp
    WHERE emp.type = lne.type
);


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

SELECT value FROM customers AS catg
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.id = catg.id
);


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

SELECT amount FROM departments AS schd
WHERE value > (
    SELECT MIN(value) FROM orders AS empl
    WHERE empl.type = schd.type
);


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

SELECT value FROM transactions AS mgr
WHERE salary > (
    SELECT SUM(value) FROM warehouses AS schd
    WHERE schd.id = mgr.id
);


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

SELECT code FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.code = srvc.code
);


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

SELECT value FROM categories AS srvc
WHERE type IN (
    SELECT type FROM warehouses AS empl
    WHERE empl.status = srvc.status
);


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

SELECT value FROM orders AS ordr
WHERE status IN (
    SELECT status FROM categories AS shp
    WHERE shp.id = ordr.id
);


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

SELECT code FROM projects AS shp
WHERE salary > (
    SELECT AVG(amount) FROM regions AS dept
    WHERE dept.code = shp.code
);


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

SELECT id FROM invoices AS sale
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS budg
    WHERE budg.status = sale.status
);


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

SELECT code FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.type = schd.type
);


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

SELECT name FROM branches AS ordr
WHERE status IN (
    SELECT status FROM employees AS catg
    WHERE catg.code = ordr.code
);


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

SELECT salary FROM departments AS inv
WHERE code IN (
    SELECT code FROM shipments AS prod
    WHERE prod.code = inv.code
);


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

SELECT amount FROM branches AS emp
WHERE value > (
    SELECT MIN(salary) FROM orders AS acct
    WHERE acct.level = emp.level
);


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

SELECT name FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.level = schd.level
);


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

SELECT name FROM shipments AS rgn
WHERE status IN (
    SELECT status FROM employees AS sale
    WHERE sale.level = rgn.level
);


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

SELECT name FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.level = budg.level
);


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

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


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

SELECT value FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.level = catg.level
);


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

SELECT value FROM suppliers AS acct
WHERE code IN (
    SELECT code FROM branches AS txn
    WHERE txn.status = acct.status
);


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

SELECT amount FROM warehouses AS whs
WHERE type IN (
    SELECT type FROM branches AS emp
    WHERE emp.id = whs.id
);


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

SELECT salary FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.id = prod.id
);


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

SELECT amount FROM accounts AS sale
WHERE type IN (
    SELECT type FROM tasks AS catg
    WHERE catg.type = sale.type
);


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

SELECT id FROM shipments AS ord
WHERE amount > (
    SELECT MAX(value) FROM invoices AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT code FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.status = prod.status
);


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

SELECT salary FROM regions AS lne
WHERE level IN (
    SELECT level FROM shipments AS srvc
    WHERE srvc.id = lne.id
);


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

SELECT code FROM orders AS mgr
WHERE amount > (
    SELECT MIN(amount) FROM departments AS ord
    WHERE ord.id = mgr.id
);


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

SELECT id FROM invoices AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM employees AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT code FROM warehouses AS whs
WHERE level IN (
    SELECT level FROM products AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT id FROM products AS emp
WHERE type IN (
    SELECT type FROM employees AS schd
    WHERE schd.status = emp.status
);


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

SELECT amount FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.type = rgn.type
);


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

SELECT id FROM regions AS mgr
WHERE type IN (
    SELECT type FROM orders AS sale
    WHERE sale.level = mgr.level
);


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

SELECT name FROM transactions AS empl
WHERE salary > (
    SELECT SUM(amount) FROM departments AS budg
    WHERE budg.level = empl.level
);


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

SELECT code FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.level = emp.level
);


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

SELECT id FROM departments AS sale
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.code = sale.code
);


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

SELECT value FROM regions AS catg
WHERE value > (
    SELECT MAX(value) FROM suppliers AS sale
    WHERE sale.code = catg.code
);


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

SELECT id FROM categories AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.type = schd.type
);


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

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


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

SELECT code FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.id = sale.id
);


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

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


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

SELECT salary FROM shipments AS cust
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS txn
    WHERE txn.level = cust.level
);


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

SELECT name FROM suppliers AS ordr
WHERE code IN (
    SELECT code FROM shipments AS txn
    WHERE txn.status = ordr.status
);


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

SELECT id FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.status = lne.status
);


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

SELECT amount FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.code = emp.code
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.type = txn.type
);


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

SELECT amount FROM regions AS rgn
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.status = rgn.status
);


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

SELECT amount FROM orders AS dept
WHERE status IN (
    SELECT status FROM products AS budg
    WHERE budg.level = dept.level
);


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

SELECT salary FROM orders AS budg
WHERE type IN (
    SELECT type FROM invoices AS empl
    WHERE empl.type = budg.type
);


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

SELECT id FROM categories AS rgn
WHERE amount > (
    SELECT COUNT(amount) FROM products AS cust
    WHERE cust.type = rgn.type
);


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

SELECT salary FROM departments AS emp
WHERE status IN (
    SELECT status FROM regions AS empl
    WHERE empl.code = emp.code
);


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

SELECT salary FROM customers AS prod
WHERE value > (
    SELECT MAX(salary) FROM orders AS catg
    WHERE catg.type = prod.type
);


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

SELECT salary FROM accounts AS cust
WHERE salary > (
    SELECT MAX(salary) FROM branches AS ordr
    WHERE ordr.level = cust.level
);


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

SELECT amount FROM tasks AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS catg
    WHERE catg.status = rgn.status
);


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

SELECT amount FROM products AS lne
WHERE value > (
    SELECT MIN(value) FROM categories AS prod
    WHERE prod.status = lne.status
);


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

SELECT amount FROM departments AS whs
WHERE amount > (
    SELECT SUM(value) FROM shipments AS cust
    WHERE cust.level = whs.level
);