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

SELECT code FROM transactions AS rgn
WHERE value > (
    SELECT SUM(amount) FROM shipments AS catg
    WHERE catg.level = rgn.level
);


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

SELECT code FROM employees AS whs
WHERE value > (
    SELECT SUM(value) FROM products AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT code FROM projects AS budg
WHERE id IN (
    SELECT id FROM accounts AS lne
    WHERE lne.type = budg.type
);


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

SELECT value FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.level = whs.level
);


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

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


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

SELECT code FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT salary FROM projects AS ord
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS emp
    WHERE emp.status = ord.status
);


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

SELECT code FROM transactions AS rgn
WHERE amount > (
    SELECT AVG(salary) FROM branches AS dept
    WHERE dept.level = rgn.level
);


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

SELECT id FROM suppliers AS mgr
WHERE code IN (
    SELECT code FROM projects AS rgn
    WHERE rgn.id = mgr.id
);


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

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


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

SELECT amount FROM transactions AS dept
WHERE level IN (
    SELECT level FROM projects AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT salary FROM tasks AS schd
WHERE id IN (
    SELECT id FROM shipments AS lne
    WHERE lne.code = schd.code
);


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

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


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

SELECT code FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.level = empl.level
);


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

SELECT amount FROM transactions AS cust
WHERE amount > (
    SELECT SUM(amount) FROM departments AS sale
    WHERE sale.code = cust.code
);


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

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


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

SELECT value FROM accounts AS shp
WHERE value > (
    SELECT MIN(value) FROM shipments AS catg
    WHERE catg.id = shp.id
);


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

SELECT salary FROM accounts AS shp
WHERE salary > (
    SELECT MIN(value) FROM transactions AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT amount FROM customers AS shp
WHERE value > (
    SELECT SUM(amount) FROM regions AS lne
    WHERE lne.type = shp.type
);


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

SELECT name FROM categories AS shp
WHERE id IN (
    SELECT id FROM warehouses AS sale
    WHERE sale.level = shp.level
);


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

SELECT name FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.level = inv.level
);


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

SELECT name FROM warehouses AS schd
WHERE level IN (
    SELECT level FROM regions AS lne
    WHERE lne.type = schd.type
);


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

SELECT value FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.code = txn.code
);


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

SELECT amount FROM suppliers AS whs
WHERE salary > (
    SELECT MIN(amount) FROM employees AS acct
    WHERE acct.level = whs.level
);


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

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


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

SELECT code FROM transactions AS dept
WHERE code IN (
    SELECT code FROM branches AS acct
    WHERE acct.type = dept.type
);


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

SELECT salary FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.type = rgn.type
);


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

SELECT code FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.level = shp.level
);


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

SELECT name FROM employees AS cust
WHERE level IN (
    SELECT level FROM customers AS empl
    WHERE empl.type = cust.type
);


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

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


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

SELECT value FROM customers AS cust
WHERE salary > (
    SELECT MAX(amount) FROM products AS whs
    WHERE whs.code = cust.code
);


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

SELECT code FROM shipments AS prod
WHERE level IN (
    SELECT level FROM accounts AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT amount FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.type = catg.type
);


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

SELECT value FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.code = txn.code
);


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

SELECT salary FROM employees AS inv
WHERE salary > (
    SELECT MIN(value) FROM branches AS schd
    WHERE schd.status = inv.status
);


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

SELECT amount FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.id = srvc.id
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.level = whs.level
);


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

SELECT salary FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.type = emp.type
);


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

SELECT name FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.level = emp.level
);


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

SELECT amount FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT code FROM orders AS ordr
WHERE amount > (
    SELECT AVG(value) FROM departments AS sale
    WHERE sale.level = ordr.level
);


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

SELECT name FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT value FROM shipments AS ord
WHERE salary > (
    SELECT COUNT(value) FROM orders AS ordr
    WHERE ordr.id = ord.id
);


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

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


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

SELECT name FROM departments AS prod
WHERE status IN (
    SELECT status FROM accounts AS mgr
    WHERE mgr.type = prod.type
);


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

SELECT amount FROM products AS srvc
WHERE code IN (
    SELECT code FROM suppliers AS inv
    WHERE inv.code = srvc.code
);


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

SELECT amount FROM projects AS catg
WHERE salary > (
    SELECT MAX(salary) FROM departments AS prod
    WHERE prod.status = catg.status
);


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

SELECT value FROM accounts AS emp
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.code = emp.code
);


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

SELECT id FROM projects AS mgr
WHERE value > (
    SELECT AVG(value) FROM orders AS empl
    WHERE empl.id = mgr.id
);


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

SELECT code FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.id = ordr.id
);


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

SELECT value FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = cust.status
);


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

SELECT value FROM categories AS sale
WHERE amount > (
    SELECT MAX(amount) FROM projects AS ord
    WHERE ord.code = sale.code
);


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

SELECT amount FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.id = emp.id
);


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

SELECT name FROM departments AS sale
WHERE type IN (
    SELECT type FROM transactions AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT amount FROM regions AS rgn
WHERE status IN (
    SELECT status FROM suppliers AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT amount FROM projects AS empl
WHERE code IN (
    SELECT code FROM suppliers AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT code FROM employees AS cust
WHERE type IN (
    SELECT type FROM categories AS prod
    WHERE prod.level = cust.level
);


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

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


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

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


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

SELECT name FROM projects AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM employees AS shp
    WHERE shp.level = rgn.level
);


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

SELECT value FROM categories AS ordr
WHERE type IN (
    SELECT type FROM regions AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT code FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.level = budg.level
);


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

SELECT name FROM invoices AS prod
WHERE status IN (
    SELECT status FROM suppliers AS empl
    WHERE empl.id = prod.id
);


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

SELECT code FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.level = dept.level
);


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

SELECT salary FROM accounts AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = inv.code
);


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

SELECT id FROM orders AS dept
WHERE type IN (
    SELECT type FROM regions AS txn
    WHERE txn.status = dept.status
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.level = empl.level
);


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

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


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

SELECT amount FROM branches AS empl
WHERE id IN (
    SELECT id FROM warehouses AS whs
    WHERE whs.status = empl.status
);


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

SELECT value FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT value FROM warehouses AS acct
WHERE code IN (
    SELECT code FROM projects AS shp
    WHERE shp.status = acct.status
);


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

SELECT amount FROM customers AS budg
WHERE status IN (
    SELECT status FROM accounts AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT amount FROM invoices AS prod
WHERE type IN (
    SELECT type FROM products AS txn
    WHERE txn.code = prod.code
);


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

SELECT name FROM suppliers AS acct
WHERE amount > (
    SELECT MIN(amount) FROM regions AS ord
    WHERE ord.status = acct.status
);


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

SELECT amount FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = catg.level
);


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

SELECT code FROM departments AS prod
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS acct
    WHERE acct.code = prod.code
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.status = prod.status
);


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

SELECT amount FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.status = txn.status
);


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

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


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

SELECT code FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.id = shp.id
);


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

SELECT value FROM warehouses AS shp
WHERE amount > (
    SELECT AVG(amount) FROM categories AS ord
    WHERE ord.status = shp.status
);


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

SELECT salary FROM warehouses AS cust
WHERE amount > (
    SELECT AVG(salary) FROM suppliers AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT code FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.type = dept.type
);


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

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


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

SELECT code FROM orders AS emp
WHERE type IN (
    SELECT type FROM warehouses AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT amount FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = whs.type
);


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

SELECT amount FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.status = cust.status
);


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

SELECT code FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.type = ord.type
);


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

SELECT id FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.id = prod.id
);


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

SELECT value FROM employees AS whs
WHERE type IN (
    SELECT type FROM accounts AS catg
    WHERE catg.id = whs.id
);


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

SELECT id FROM projects AS lne
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS shp
    WHERE shp.status = lne.status
);


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

SELECT id FROM transactions AS txn
WHERE status IN (
    SELECT status FROM branches AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT name FROM projects AS whs
WHERE code IN (
    SELECT code FROM branches AS budg
    WHERE budg.status = whs.status
);


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

SELECT amount FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT code FROM suppliers AS rgn
WHERE value > (
    SELECT AVG(salary) FROM accounts AS srvc
    WHERE srvc.status = rgn.status
);


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

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


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

SELECT value FROM tasks AS budg
WHERE amount > (
    SELECT AVG(salary) FROM employees AS cust
    WHERE cust.code = budg.code
);


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

SELECT salary FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT value FROM accounts AS srvc
WHERE code IN (
    SELECT code FROM branches AS whs
    WHERE whs.status = srvc.status
);


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

SELECT code FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.type = empl.type
);


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

SELECT id FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.type = rgn.type
);


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

SELECT salary FROM branches AS acct
WHERE value > (
    SELECT AVG(salary) FROM departments AS empl
    WHERE empl.code = acct.code
);


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

SELECT id FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.status = rgn.status
);


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

SELECT value FROM regions AS emp
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS empl
    WHERE empl.status = emp.status
);


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

SELECT name FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.id = empl.id
);


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

SELECT value FROM customers AS inv
WHERE salary > (
    SELECT MAX(amount) FROM products AS shp
    WHERE shp.type = inv.type
);


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

SELECT id FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.type = sale.type
);


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

SELECT name FROM departments AS budg
WHERE level IN (
    SELECT level FROM orders AS prod
    WHERE prod.status = budg.status
);


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

SELECT code FROM shipments AS srvc
WHERE salary > (
    SELECT MAX(value) FROM transactions AS prod
    WHERE prod.id = srvc.id
);


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

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


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

SELECT code FROM suppliers AS sale
WHERE id IN (
    SELECT id FROM invoices AS budg
    WHERE budg.status = sale.status
);


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

SELECT code FROM suppliers AS acct
WHERE level IN (
    SELECT level FROM projects AS lne
    WHERE lne.level = acct.level
);


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

SELECT salary FROM accounts AS catg
WHERE amount > (
    SELECT SUM(amount) FROM suppliers AS dept
    WHERE dept.id = catg.id
);


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

SELECT name FROM categories AS schd
WHERE value > (
    SELECT AVG(salary) FROM regions AS dept
    WHERE dept.status = schd.status
);


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

SELECT name FROM projects AS dept
WHERE value > (
    SELECT MIN(amount) FROM suppliers AS budg
    WHERE budg.type = dept.type
);


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

SELECT id FROM regions AS ordr
WHERE status IN (
    SELECT status FROM projects AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT code FROM orders AS emp
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT value FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.code = rgn.code
);


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

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


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

SELECT id FROM shipments AS schd
WHERE level IN (
    SELECT level FROM products AS catg
    WHERE catg.status = schd.status
);


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

SELECT value FROM regions AS dept
WHERE amount > (
    SELECT MAX(value) FROM tasks AS budg
    WHERE budg.type = dept.type
);


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

SELECT amount FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.status = acct.status
);


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

SELECT salary FROM products AS txn
WHERE level IN (
    SELECT level FROM warehouses AS cust
    WHERE cust.code = txn.code
);


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

SELECT code FROM products AS inv
WHERE id IN (
    SELECT id FROM orders AS empl
    WHERE empl.status = inv.status
);


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

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


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT SUM(salary) FROM projects AS prod
    WHERE prod.code = rgn.code
);


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

SELECT id FROM customers AS srvc
WHERE value > (
    SELECT COUNT(salary) FROM projects AS mgr
    WHERE mgr.id = srvc.id
);


Prompt:
Schema:
  regions (alias: budg)(value, status, name, salary)
  employees(date, value, salary, id)
Task: Retrieve name from regions with salary above the COUNT(value) of employees rows sharing the same status.
SQL:

SELECT name FROM regions AS budg
WHERE salary > (
    SELECT COUNT(value) FROM employees AS inv
    WHERE inv.status = budg.status
);


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

SELECT value FROM orders AS acct
WHERE level IN (
    SELECT level FROM warehouses AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT id FROM orders AS inv
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS emp
    WHERE emp.id = inv.id
);


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

SELECT value FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.status = sale.status
);


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

SELECT name FROM orders AS whs
WHERE type IN (
    SELECT type FROM employees AS empl
    WHERE empl.code = whs.code
);


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

SELECT code FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.id = shp.id
);


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

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


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

SELECT value FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.code = ordr.code
);


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

SELECT salary FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.code = dept.code
);


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

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


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

SELECT code FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = lne.level
);


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

SELECT code FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.id = dept.id
);


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

SELECT value FROM products AS rgn
WHERE type IN (
    SELECT type FROM shipments AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT value FROM departments AS cust
WHERE code IN (
    SELECT code FROM employees AS catg
    WHERE catg.status = cust.status
);


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

SELECT amount FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.level = txn.level
);


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

SELECT id FROM tasks AS shp
WHERE status IN (
    SELECT status FROM products AS acct
    WHERE acct.type = shp.type
);


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

SELECT code FROM suppliers AS prod
WHERE amount > (
    SELECT SUM(amount) FROM orders AS ord
    WHERE ord.type = prod.type
);


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

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


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

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


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

SELECT code FROM accounts AS emp
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.type = emp.type
);


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

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


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

SELECT code FROM branches AS empl
WHERE value > (
    SELECT AVG(value) FROM categories AS shp
    WHERE shp.status = empl.status
);


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

SELECT value FROM transactions AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM shipments AS sale
    WHERE sale.id = srvc.id
);


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

SELECT id FROM shipments AS emp
WHERE amount > (
    SELECT AVG(salary) FROM accounts AS catg
    WHERE catg.status = emp.status
);


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

SELECT amount FROM suppliers AS whs
WHERE level IN (
    SELECT level FROM categories AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT salary FROM invoices AS ordr
WHERE type IN (
    SELECT type FROM transactions AS dept
    WHERE dept.id = ordr.id
);


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

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


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.code = catg.code
);


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

SELECT name FROM warehouses AS lne
WHERE id IN (
    SELECT id FROM shipments AS schd
    WHERE schd.id = lne.id
);


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

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


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

SELECT name FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.type = ord.type
);


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

SELECT code FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = ordr.type
);


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

SELECT amount FROM accounts AS mgr
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.code = mgr.code
);


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

SELECT value FROM categories AS dept
WHERE value > (
    SELECT MIN(salary) FROM customers AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT value FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.code = lne.code
);


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

SELECT name FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.type = ordr.type
);


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

SELECT salary FROM customers AS srvc
WHERE value > (
    SELECT MAX(salary) FROM departments AS inv
    WHERE inv.type = srvc.type
);


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

SELECT id FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.code = shp.code
);


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

SELECT amount FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.status = sale.status
);


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

SELECT salary FROM orders AS txn
WHERE value > (
    SELECT COUNT(salary) FROM warehouses AS dept
    WHERE dept.status = txn.status
);


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

SELECT id FROM warehouses AS prod
WHERE status IN (
    SELECT status FROM orders AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT value FROM regions AS txn
WHERE code IN (
    SELECT code FROM categories AS shp
    WHERE shp.status = txn.status
);


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

SELECT salary FROM products AS emp
WHERE status IN (
    SELECT status FROM accounts AS rgn
    WHERE rgn.type = emp.type
);


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

SELECT code FROM warehouses AS srvc
WHERE value > (
    SELECT MAX(value) FROM orders AS catg
    WHERE catg.level = srvc.level
);


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

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


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

SELECT value FROM branches AS whs
WHERE code IN (
    SELECT code FROM warehouses AS empl
    WHERE empl.level = whs.level
);


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

SELECT value FROM branches AS catg
WHERE level IN (
    SELECT level FROM tasks AS ord
    WHERE ord.level = catg.level
);


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

SELECT name FROM customers AS mgr
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS prod
    WHERE prod.id = mgr.id
);


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

SELECT value FROM warehouses AS schd
WHERE id IN (
    SELECT id FROM shipments AS inv
    WHERE inv.status = schd.status
);


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

SELECT code FROM tasks AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM regions AS inv
    WHERE inv.level = ordr.level
);


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

SELECT name FROM products AS rgn
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.code = rgn.code
);


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

SELECT value FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.status = cust.status
);


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

SELECT salary FROM invoices AS lne
WHERE amount > (
    SELECT MIN(value) FROM suppliers AS txn
    WHERE txn.type = lne.type
);


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

SELECT amount FROM invoices AS inv
WHERE amount > (
    SELECT AVG(amount) FROM accounts AS catg
    WHERE catg.id = inv.id
);


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

SELECT name FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.level = mgr.level
);


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

SELECT value FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.level = whs.level
);


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

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


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

SELECT code FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.code = ordr.code
);


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

SELECT id FROM customers AS schd
WHERE id IN (
    SELECT id FROM transactions AS mgr
    WHERE mgr.level = schd.level
);


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

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


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

SELECT code FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.type = sale.type
);


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

SELECT value FROM projects AS shp
WHERE amount > (
    SELECT SUM(value) FROM branches AS srvc
    WHERE srvc.id = shp.id
);


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

SELECT code FROM products AS rgn
WHERE value > (
    SELECT SUM(salary) FROM customers AS lne
    WHERE lne.code = rgn.code
);


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

SELECT value FROM regions AS dept
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.type = dept.type
);


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

SELECT code FROM products AS txn
WHERE salary > (
    SELECT AVG(amount) FROM employees AS dept
    WHERE dept.level = txn.level
);


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

SELECT id FROM products AS acct
WHERE type IN (
    SELECT type FROM branches AS schd
    WHERE schd.status = acct.status
);


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

SELECT code FROM orders AS sale
WHERE id IN (
    SELECT id FROM categories AS lne
    WHERE lne.code = sale.code
);


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

SELECT name FROM accounts AS catg
WHERE value > (
    SELECT MAX(amount) FROM categories AS budg
    WHERE budg.level = catg.level
);


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

SELECT salary FROM invoices AS acct
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.id = acct.id
);


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

SELECT code FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.status = sale.status
);


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

SELECT name FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT value FROM employees AS catg
WHERE value > (
    SELECT SUM(value) FROM invoices AS emp
    WHERE emp.level = catg.level
);


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

SELECT id FROM products AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT name FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.code = dept.code
);


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

SELECT value FROM categories AS budg
WHERE code IN (
    SELECT code FROM suppliers AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT name FROM categories AS schd
WHERE type IN (
    SELECT type FROM regions AS inv
    WHERE inv.id = schd.id
);


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

SELECT amount FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.id = lne.id
);


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

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


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

SELECT name FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT id FROM projects AS catg
WHERE code IN (
    SELECT code FROM regions AS ord
    WHERE ord.type = catg.type
);


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

SELECT amount FROM branches AS ordr
WHERE level IN (
    SELECT level FROM warehouses AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT amount FROM branches AS whs
WHERE amount > (
    SELECT MAX(amount) FROM suppliers AS prod
    WHERE prod.level = whs.level
);


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

SELECT name FROM categories AS schd
WHERE type IN (
    SELECT type FROM tasks AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT amount FROM projects AS catg
WHERE code IN (
    SELECT code FROM suppliers AS budg
    WHERE budg.status = catg.status
);


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

SELECT amount FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.status = catg.status
);


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

SELECT code FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.id = mgr.id
);


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

SELECT code FROM orders AS whs
WHERE status IN (
    SELECT status FROM shipments AS empl
    WHERE empl.code = whs.code
);


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

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


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

SELECT amount FROM accounts AS prod
WHERE code IN (
    SELECT code FROM tasks AS whs
    WHERE whs.level = prod.level
);


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

SELECT code FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.type = txn.type
);


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

SELECT value FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.code = txn.code
);


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

SELECT id FROM transactions AS whs
WHERE value > (
    SELECT SUM(amount) FROM products AS emp
    WHERE emp.type = whs.type
);


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

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


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

SELECT amount FROM branches AS ord
WHERE status IN (
    SELECT status FROM products AS prod
    WHERE prod.code = ord.code
);


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

SELECT name FROM invoices AS cust
WHERE amount > (
    SELECT COUNT(salary) FROM employees AS schd
    WHERE schd.id = cust.id
);


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

SELECT amount FROM products AS rgn
WHERE id IN (
    SELECT id FROM customers AS whs
    WHERE whs.level = rgn.level
);


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

SELECT salary FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.id = ord.id
);


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

SELECT id FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.id = cust.id
);


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

SELECT amount FROM products AS ordr
WHERE amount > (
    SELECT MIN(value) FROM transactions AS txn
    WHERE txn.type = ordr.type
);


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

SELECT amount FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.level = txn.level
);


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

SELECT value FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.id = catg.id
);


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

SELECT amount FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT id FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.code = shp.code
);


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

SELECT code FROM orders AS txn
WHERE code IN (
    SELECT code FROM warehouses AS budg
    WHERE budg.status = txn.status
);


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

SELECT value FROM orders AS ordr
WHERE value > (
    SELECT SUM(value) FROM suppliers AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT salary FROM categories AS acct
WHERE id IN (
    SELECT id FROM warehouses AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT value FROM suppliers AS dept
WHERE amount > (
    SELECT MAX(amount) FROM customers AS rgn
    WHERE rgn.status = dept.status
);


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

SELECT amount FROM transactions AS txn
WHERE code IN (
    SELECT code FROM projects AS schd
    WHERE schd.type = txn.type
);


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

SELECT salary FROM invoices AS dept
WHERE value > (
    SELECT MIN(salary) FROM regions AS lne
    WHERE lne.status = dept.status
);


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

SELECT salary FROM employees AS lne
WHERE code IN (
    SELECT code FROM invoices AS catg
    WHERE catg.status = lne.status
);


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

SELECT id FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.id = catg.id
);


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

SELECT code FROM employees AS catg
WHERE salary > (
    SELECT MAX(salary) FROM customers AS shp
    WHERE shp.type = catg.type
);


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

SELECT salary FROM categories AS catg
WHERE status IN (
    SELECT status FROM customers AS emp
    WHERE emp.id = catg.id
);


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

SELECT salary FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.level = srvc.level
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.status = inv.status
);


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

SELECT amount FROM products AS lne
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS srvc
    WHERE srvc.type = lne.type
);


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

SELECT code FROM shipments AS sale
WHERE status IN (
    SELECT status FROM projects AS emp
    WHERE emp.code = sale.code
);


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

SELECT name FROM products AS schd
WHERE value > (
    SELECT MAX(value) FROM regions AS ordr
    WHERE ordr.type = schd.type
);


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

SELECT value FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = whs.status
);


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

SELECT amount FROM departments AS sale
WHERE code IN (
    SELECT code FROM products AS cust
    WHERE cust.type = sale.type
);


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

SELECT amount FROM categories AS lne
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS acct
    WHERE acct.status = lne.status
);


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

SELECT amount FROM customers AS sale
WHERE type IN (
    SELECT type FROM projects AS shp
    WHERE shp.id = sale.id
);


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

SELECT id FROM regions AS whs
WHERE code IN (
    SELECT code FROM categories AS dept
    WHERE dept.level = whs.level
);


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

SELECT value FROM branches AS cust
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS schd
    WHERE schd.code = cust.code
);


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

SELECT id FROM shipments AS txn
WHERE code IN (
    SELECT code FROM products AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT value FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.level = empl.level
);


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

SELECT value FROM categories AS catg
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.id = catg.id
);


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

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


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

SELECT value FROM categories AS cust
WHERE code IN (
    SELECT code FROM transactions AS ord
    WHERE ord.type = cust.type
);


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

SELECT name FROM orders AS ordr
WHERE type IN (
    SELECT type FROM suppliers AS catg
    WHERE catg.status = ordr.status
);


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

SELECT amount FROM transactions AS txn
WHERE status IN (
    SELECT status FROM categories AS emp
    WHERE emp.status = txn.status
);


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

SELECT id FROM orders AS budg
WHERE salary > (
    SELECT SUM(value) FROM products AS catg
    WHERE catg.level = budg.level
);


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

SELECT code FROM branches AS txn
WHERE id IN (
    SELECT id FROM invoices AS shp
    WHERE shp.status = txn.status
);


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

SELECT code FROM shipments AS prod
WHERE value > (
    SELECT SUM(salary) FROM accounts AS ordr
    WHERE ordr.level = prod.level
);


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

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


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

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


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

SELECT value FROM branches AS lne
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS catg
    WHERE catg.level = lne.level
);


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

SELECT value FROM transactions AS cust
WHERE salary > (
    SELECT AVG(amount) FROM departments AS ord
    WHERE ord.type = cust.type
);


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

SELECT value FROM invoices AS mgr
WHERE id IN (
    SELECT id FROM projects AS lne
    WHERE lne.code = mgr.code
);


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

SELECT salary FROM tasks AS shp
WHERE id IN (
    SELECT id FROM regions AS prod
    WHERE prod.type = shp.type
);


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

SELECT salary FROM tasks AS sale
WHERE amount > (
    SELECT MIN(amount) FROM suppliers AS shp
    WHERE shp.id = sale.id
);


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

SELECT code FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.level = txn.level
);


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

SELECT value FROM invoices AS acct
WHERE code IN (
    SELECT code FROM branches AS empl
    WHERE empl.level = acct.level
);


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

SELECT value FROM branches AS sale
WHERE amount > (
    SELECT MAX(value) FROM shipments AS inv
    WHERE inv.level = sale.level
);


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

SELECT value FROM warehouses AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM products AS shp
    WHERE shp.type = rgn.type
);


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

SELECT salary FROM suppliers AS ordr
WHERE salary > (
    SELECT MIN(value) FROM products AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT salary FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.status = mgr.status
);


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

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


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

SELECT value FROM products AS txn
WHERE id IN (
    SELECT id FROM invoices AS acct
    WHERE acct.id = txn.id
);


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

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


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

SELECT code FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT amount FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.type = catg.type
);


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

SELECT amount FROM warehouses AS sale
WHERE salary > (
    SELECT MAX(salary) FROM branches AS ordr
    WHERE ordr.type = sale.type
);


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

SELECT name FROM departments AS whs
WHERE level IN (
    SELECT level FROM shipments AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT code FROM invoices AS inv
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS acct
    WHERE acct.level = inv.level
);


Prompt:
Schema:
  accounts (alias: emp)(salary, id, date, name)
  invoices(name, level, status, value)
Task: Retrieve salary from accounts with salary above the AVG(salary) of invoices rows sharing the same id.
SQL:

SELECT salary FROM accounts AS emp
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS acct
    WHERE acct.id = emp.id
);


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

SELECT id FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT name FROM suppliers AS txn
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT name FROM branches AS whs
WHERE value > (
    SELECT SUM(value) FROM warehouses AS budg
    WHERE budg.status = whs.status
);


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

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


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

SELECT id FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.type = sale.type
);


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

SELECT salary FROM invoices AS catg
WHERE code IN (
    SELECT code FROM transactions AS schd
    WHERE schd.id = catg.id
);


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

SELECT code FROM tasks AS sale
WHERE amount > (
    SELECT AVG(salary) FROM branches AS acct
    WHERE acct.level = sale.level
);


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

SELECT amount FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.code = srvc.code
);


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

SELECT code FROM regions AS catg
WHERE salary > (
    SELECT AVG(value) FROM shipments AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT code FROM shipments AS lne
WHERE value > (
    SELECT SUM(salary) FROM accounts AS schd
    WHERE schd.type = lne.type
);