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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.type = ord.type
);


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

SELECT value FROM employees AS catg
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.type = catg.type
);


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

SELECT name FROM invoices AS emp
WHERE value > (
    SELECT AVG(salary) FROM regions AS lne
    WHERE lne.code = emp.code
);


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

SELECT amount FROM shipments AS srvc
WHERE salary > (
    SELECT MAX(salary) FROM warehouses AS ord
    WHERE ord.id = srvc.id
);


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

SELECT amount FROM regions AS prod
WHERE level IN (
    SELECT level FROM tasks AS dept
    WHERE dept.level = prod.level
);


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

SELECT name FROM shipments AS emp
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS empl
    WHERE empl.type = emp.type
);


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

SELECT amount FROM branches AS whs
WHERE status IN (
    SELECT status FROM invoices AS dept
    WHERE dept.type = whs.type
);


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

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


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

SELECT value FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = shp.id
);


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

SELECT salary FROM invoices AS empl
WHERE salary > (
    SELECT SUM(amount) FROM categories AS inv
    WHERE inv.type = empl.type
);


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

SELECT code FROM employees AS srvc
WHERE salary > (
    SELECT AVG(value) FROM invoices AS cust
    WHERE cust.id = srvc.id
);


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

SELECT amount FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.code = lne.code
);


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

SELECT code FROM transactions AS schd
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT amount FROM transactions AS emp
WHERE id IN (
    SELECT id FROM accounts AS budg
    WHERE budg.id = emp.id
);


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

SELECT value FROM warehouses AS budg
WHERE value > (
    SELECT SUM(salary) FROM invoices AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT name FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT code FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.level = emp.level
);


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

SELECT code FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.level = schd.level
);


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

SELECT amount FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.type = prod.type
);


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

SELECT id FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.level = dept.level
);


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

SELECT value FROM suppliers AS shp
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.id = shp.id
);


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

SELECT salary FROM regions AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.status = whs.status
);


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

SELECT id FROM categories AS srvc
WHERE id IN (
    SELECT id FROM branches AS catg
    WHERE catg.code = srvc.code
);


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

SELECT value FROM regions AS emp
WHERE value > (
    SELECT SUM(salary) FROM departments AS sale
    WHERE sale.level = emp.level
);


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

SELECT code FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.code = dept.code
);


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

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


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT id FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.status = rgn.status
);


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

SELECT amount FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.level = mgr.level
);


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

SELECT id FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.level = catg.level
);


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

SELECT code FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.type = prod.type
);


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

SELECT salary FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT id FROM transactions AS whs
WHERE amount > (
    SELECT MAX(amount) FROM orders AS mgr
    WHERE mgr.level = whs.level
);


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

SELECT code FROM projects AS acct
WHERE id IN (
    SELECT id FROM accounts AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT name FROM departments AS ord
WHERE value > (
    SELECT SUM(amount) FROM transactions AS lne
    WHERE lne.id = ord.id
);


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

SELECT value FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT value FROM categories AS emp
WHERE id IN (
    SELECT id FROM warehouses AS cust
    WHERE cust.id = emp.id
);


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

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


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

SELECT id FROM accounts AS txn
WHERE amount > (
    SELECT SUM(amount) FROM categories AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT name FROM orders AS ord
WHERE type IN (
    SELECT type FROM projects AS dept
    WHERE dept.status = ord.status
);


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

SELECT salary FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.id = rgn.id
);


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

SELECT name FROM projects AS acct
WHERE salary > (
    SELECT MAX(amount) FROM products AS whs
    WHERE whs.status = acct.status
);


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

SELECT salary FROM shipments AS rgn
WHERE code IN (
    SELECT code FROM employees AS ord
    WHERE ord.type = rgn.type
);


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

SELECT value FROM invoices AS srvc
WHERE value > (
    SELECT AVG(salary) FROM transactions AS ord
    WHERE ord.level = srvc.level
);


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

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


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

SELECT code FROM products AS empl
WHERE code IN (
    SELECT code FROM shipments AS dept
    WHERE dept.status = empl.status
);


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

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


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

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


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

SELECT name FROM categories AS txn
WHERE code IN (
    SELECT code FROM transactions AS budg
    WHERE budg.id = txn.id
);


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

SELECT code FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.status = rgn.status
);


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

SELECT code FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.id = mgr.id
);


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

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


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

SELECT code FROM warehouses AS catg
WHERE value > (
    SELECT SUM(value) FROM regions AS acct
    WHERE acct.code = catg.code
);


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

SELECT code FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT amount FROM categories AS dept
WHERE value > (
    SELECT MIN(value) FROM branches AS schd
    WHERE schd.level = dept.level
);


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

SELECT amount FROM accounts AS lne
WHERE salary > (
    SELECT MAX(salary) FROM orders AS empl
    WHERE empl.code = lne.code
);


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

SELECT code FROM employees AS whs
WHERE value > (
    SELECT MIN(salary) FROM orders AS cust
    WHERE cust.id = whs.id
);


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

SELECT value FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = rgn.status
);


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

SELECT salary FROM invoices AS srvc
WHERE amount > (
    SELECT SUM(value) FROM transactions AS budg
    WHERE budg.status = srvc.status
);


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

SELECT name FROM projects AS dept
WHERE type IN (
    SELECT type FROM shipments AS lne
    WHERE lne.status = dept.status
);


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

SELECT value FROM products AS rgn
WHERE level IN (
    SELECT level FROM tasks AS prod
    WHERE prod.status = rgn.status
);


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

SELECT value FROM customers AS cust
WHERE id IN (
    SELECT id FROM regions AS shp
    WHERE shp.level = cust.level
);


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

SELECT salary FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.status = empl.status
);


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

SELECT id FROM products AS prod
WHERE value > (
    SELECT AVG(amount) FROM accounts AS ord
    WHERE ord.id = prod.id
);


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

SELECT name FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.status = shp.status
);


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

SELECT name FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.type = budg.type
);


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

SELECT name FROM projects AS acct
WHERE level IN (
    SELECT level FROM accounts AS sale
    WHERE sale.type = acct.type
);


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

SELECT amount FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.code = shp.code
);


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

SELECT id FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.level = budg.level
);


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

SELECT amount FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.code = prod.code
);


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

SELECT value FROM invoices AS schd
WHERE type IN (
    SELECT type FROM transactions AS emp
    WHERE emp.code = schd.code
);


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

SELECT value FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT amount FROM warehouses AS prod
WHERE value > (
    SELECT MAX(amount) FROM tasks AS ord
    WHERE ord.id = prod.id
);


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

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


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

SELECT code FROM shipments AS schd
WHERE salary > (
    SELECT SUM(salary) FROM regions AS sale
    WHERE sale.id = schd.id
);


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

SELECT id FROM orders AS mgr
WHERE code IN (
    SELECT code FROM categories AS ord
    WHERE ord.level = mgr.level
);


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

SELECT code FROM products AS shp
WHERE level IN (
    SELECT level FROM orders AS txn
    WHERE txn.status = shp.status
);


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

SELECT value FROM employees AS rgn
WHERE value > (
    SELECT AVG(value) FROM branches AS lne
    WHERE lne.type = rgn.type
);


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

SELECT amount FROM suppliers AS catg
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.type = catg.type
);


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

SELECT code FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.id = mgr.id
);


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

SELECT salary FROM customers AS schd
WHERE code IN (
    SELECT code FROM suppliers AS whs
    WHERE whs.id = schd.id
);


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

SELECT name FROM products AS prod
WHERE level IN (
    SELECT level FROM shipments AS budg
    WHERE budg.code = prod.code
);


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

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


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

SELECT salary FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.level = inv.level
);


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

SELECT amount FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = emp.code
);


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

SELECT amount FROM employees AS cust
WHERE status IN (
    SELECT status FROM orders AS inv
    WHERE inv.status = cust.status
);


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

SELECT code FROM projects AS catg
WHERE id IN (
    SELECT id FROM customers AS ord
    WHERE ord.level = catg.level
);


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

SELECT id FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.status = cust.status
);


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

SELECT value FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = budg.code
);


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

SELECT id FROM invoices AS whs
WHERE id IN (
    SELECT id FROM customers AS sale
    WHERE sale.type = whs.type
);


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

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


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

SELECT id FROM warehouses AS emp
WHERE type IN (
    SELECT type FROM categories AS mgr
    WHERE mgr.level = emp.level
);


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

SELECT salary FROM orders AS mgr
WHERE value > (
    SELECT MAX(value) FROM suppliers AS dept
    WHERE dept.id = mgr.id
);


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

SELECT amount FROM employees AS budg
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT value FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.code = inv.code
);


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

SELECT code FROM shipments AS prod
WHERE amount > (
    SELECT MAX(salary) FROM customers AS inv
    WHERE inv.id = prod.id
);


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

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


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

SELECT name FROM regions AS emp
WHERE status IN (
    SELECT status FROM shipments AS empl
    WHERE empl.level = emp.level
);


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

SELECT id FROM regions AS budg
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS prod
    WHERE prod.status = budg.status
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.level = txn.level
);


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

SELECT code FROM categories AS whs
WHERE id IN (
    SELECT id FROM invoices AS inv
    WHERE inv.id = whs.id
);


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

SELECT value FROM branches AS catg
WHERE amount > (
    SELECT MIN(value) FROM suppliers AS sale
    WHERE sale.level = catg.level
);


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

SELECT code FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.type = budg.type
);


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

SELECT salary FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT salary FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.type = sale.type
);


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

SELECT id FROM shipments AS ordr
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS prod
    WHERE prod.type = ordr.type
);


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

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


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

SELECT salary FROM shipments AS acct
WHERE level IN (
    SELECT level FROM branches AS prod
    WHERE prod.code = acct.code
);


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

SELECT code FROM warehouses AS inv
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT name FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.level = dept.level
);


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

SELECT id FROM suppliers AS empl
WHERE level IN (
    SELECT level FROM employees AS whs
    WHERE whs.status = empl.status
);


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

SELECT id FROM warehouses AS inv
WHERE salary > (
    SELECT SUM(salary) FROM shipments AS sale
    WHERE sale.status = inv.status
);


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

SELECT value FROM invoices AS lne
WHERE value > (
    SELECT AVG(amount) FROM orders AS cust
    WHERE cust.status = lne.status
);


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

SELECT salary FROM employees AS mgr
WHERE value > (
    SELECT MIN(value) FROM suppliers AS whs
    WHERE whs.type = mgr.type
);


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

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


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

SELECT code FROM employees AS cust
WHERE value > (
    SELECT MAX(salary) FROM customers AS budg
    WHERE budg.type = cust.type
);


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

SELECT id FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM projects AS whs
    WHERE whs.level = ordr.level
);


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

SELECT code FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.level = ordr.level
);


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

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


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

SELECT name FROM customers AS inv
WHERE salary > (
    SELECT AVG(salary) FROM tasks AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT id FROM departments AS catg
WHERE level IN (
    SELECT level FROM projects AS prod
    WHERE prod.level = catg.level
);


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

SELECT amount FROM regions AS ord
WHERE code IN (
    SELECT code FROM products AS catg
    WHERE catg.level = ord.level
);


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

SELECT code FROM invoices AS dept
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS inv
    WHERE inv.code = dept.code
);


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

SELECT value FROM branches AS rgn
WHERE type IN (
    SELECT type FROM categories AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT value FROM tasks AS schd
WHERE type IN (
    SELECT type FROM regions AS empl
    WHERE empl.id = schd.id
);


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

SELECT salary FROM projects AS sale
WHERE status IN (
    SELECT status FROM transactions AS budg
    WHERE budg.id = sale.id
);


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

SELECT id FROM shipments AS dept
WHERE type IN (
    SELECT type FROM regions AS shp
    WHERE shp.code = dept.code
);


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

SELECT id FROM products AS schd
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS empl
    WHERE empl.id = schd.id
);


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

SELECT id FROM projects AS mgr
WHERE value > (
    SELECT SUM(value) FROM suppliers AS emp
    WHERE emp.code = mgr.code
);


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

SELECT code FROM suppliers AS inv
WHERE status IN (
    SELECT status FROM orders AS acct
    WHERE acct.code = inv.code
);


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

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


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

SELECT id FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT value FROM employees AS ordr
WHERE salary > (
    SELECT MIN(salary) FROM invoices AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT id FROM shipments AS shp
WHERE code IN (
    SELECT code FROM warehouses AS schd
    WHERE schd.code = shp.code
);


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

SELECT salary FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.id = shp.id
);


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

SELECT value FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.level = inv.level
);


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

SELECT amount FROM branches AS ordr
WHERE id IN (
    SELECT id FROM shipments AS dept
    WHERE dept.type = ordr.type
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.id = cust.id
);


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

SELECT name FROM suppliers AS mgr
WHERE amount > (
    SELECT SUM(amount) FROM customers AS acct
    WHERE acct.code = mgr.code
);


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

SELECT name FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = whs.status
);


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

SELECT id FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.level = ordr.level
);


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

SELECT name FROM invoices AS dept
WHERE value > (
    SELECT SUM(amount) FROM projects AS budg
    WHERE budg.id = dept.id
);


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

SELECT name FROM invoices AS dept
WHERE type IN (
    SELECT type FROM suppliers AS cust
    WHERE cust.status = dept.status
);


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

SELECT amount FROM shipments AS dept
WHERE amount > (
    SELECT COUNT(value) FROM orders AS lne
    WHERE lne.id = dept.id
);


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

SELECT name FROM products AS prod
WHERE salary > (
    SELECT SUM(salary) FROM transactions AS lne
    WHERE lne.type = prod.type
);


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

SELECT id FROM departments AS ord
WHERE salary > (
    SELECT AVG(amount) FROM categories AS whs
    WHERE whs.id = ord.id
);


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

SELECT value FROM shipments AS inv
WHERE code IN (
    SELECT code FROM products AS txn
    WHERE txn.type = inv.type
);


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

SELECT name FROM accounts AS catg
WHERE value > (
    SELECT AVG(amount) FROM categories AS srvc
    WHERE srvc.type = catg.type
);


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

SELECT code FROM invoices AS ord
WHERE amount > (
    SELECT MIN(amount) FROM warehouses AS cust
    WHERE cust.level = ord.level
);


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

SELECT id FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.status = dept.status
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT name FROM warehouses AS acct
WHERE id IN (
    SELECT id FROM products AS dept
    WHERE dept.status = acct.status
);


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

SELECT name FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = rgn.type
);


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

SELECT name FROM suppliers AS emp
WHERE status IN (
    SELECT status FROM branches AS shp
    WHERE shp.type = emp.type
);


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

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


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

SELECT amount FROM categories AS catg
WHERE status IN (
    SELECT status FROM branches AS ordr
    WHERE ordr.code = catg.code
);


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

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


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

SELECT salary FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.code = ord.code
);


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

SELECT name FROM warehouses AS emp
WHERE id IN (
    SELECT id FROM customers AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT code FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.id = srvc.id
);


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

SELECT name FROM shipments AS emp
WHERE level IN (
    SELECT level FROM tasks AS prod
    WHERE prod.id = emp.id
);


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

SELECT name FROM transactions AS cust
WHERE code IN (
    SELECT code FROM accounts AS inv
    WHERE inv.code = cust.code
);


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

SELECT amount FROM projects AS srvc
WHERE status IN (
    SELECT status FROM regions AS sale
    WHERE sale.type = srvc.type
);


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

SELECT name FROM suppliers AS mgr
WHERE code IN (
    SELECT code FROM categories AS whs
    WHERE whs.level = mgr.level
);


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

SELECT salary FROM transactions AS budg
WHERE salary > (
    SELECT MIN(value) FROM invoices AS txn
    WHERE txn.code = budg.code
);


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

SELECT name FROM projects AS srvc
WHERE type IN (
    SELECT type FROM transactions AS whs
    WHERE whs.id = srvc.id
);


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

SELECT code FROM branches AS budg
WHERE salary > (
    SELECT AVG(amount) FROM projects AS schd
    WHERE schd.id = budg.id
);


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

SELECT id FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.code = ordr.code
);


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

SELECT name FROM transactions AS rgn
WHERE id IN (
    SELECT id FROM employees AS dept
    WHERE dept.type = rgn.type
);


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

SELECT code FROM projects AS dept
WHERE level IN (
    SELECT level FROM transactions AS srvc
    WHERE srvc.status = dept.status
);


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

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


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

SELECT id FROM invoices AS ord
WHERE status IN (
    SELECT status FROM warehouses AS lne
    WHERE lne.level = ord.level
);


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

SELECT code FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT salary FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.code = acct.code
);


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

SELECT amount FROM accounts AS inv
WHERE type IN (
    SELECT type FROM orders AS prod
    WHERE prod.code = inv.code
);


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

SELECT name FROM accounts AS shp
WHERE amount > (
    SELECT MAX(value) FROM categories AS txn
    WHERE txn.status = shp.status
);


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

SELECT id FROM employees AS inv
WHERE value > (
    SELECT MAX(value) FROM projects AS sale
    WHERE sale.id = inv.id
);


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

SELECT value FROM regions AS cust
WHERE value > (
    SELECT MAX(salary) FROM customers AS prod
    WHERE prod.level = cust.level
);


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

SELECT value FROM orders AS shp
WHERE id IN (
    SELECT id FROM transactions AS acct
    WHERE acct.id = shp.id
);


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

SELECT value FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.type = acct.type
);


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

SELECT amount FROM regions AS emp
WHERE level IN (
    SELECT level FROM products AS acct
    WHERE acct.id = emp.id
);


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

SELECT id FROM transactions AS acct
WHERE id IN (
    SELECT id FROM tasks AS inv
    WHERE inv.status = acct.status
);


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

SELECT salary FROM departments AS whs
WHERE value > (
    SELECT AVG(amount) FROM categories AS catg
    WHERE catg.status = whs.status
);


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

SELECT amount FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.id = inv.id
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.level = ord.level
);


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

SELECT id FROM shipments AS emp
WHERE salary > (
    SELECT COUNT(value) FROM accounts AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT salary FROM branches AS shp
WHERE value > (
    SELECT SUM(value) FROM accounts AS txn
    WHERE txn.code = shp.code
);


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

SELECT salary FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.code = txn.code
);


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

SELECT name FROM invoices AS acct
WHERE id IN (
    SELECT id FROM products AS sale
    WHERE sale.type = acct.type
);


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

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


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

SELECT code FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.id = sale.id
);


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

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


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

SELECT amount FROM transactions AS sale
WHERE value > (
    SELECT MAX(amount) FROM invoices AS mgr
    WHERE mgr.id = sale.id
);


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

SELECT value FROM warehouses AS cust
WHERE code IN (
    SELECT code FROM shipments AS sale
    WHERE sale.level = cust.level
);


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

SELECT value FROM categories AS mgr
WHERE code IN (
    SELECT code FROM suppliers AS empl
    WHERE empl.level = mgr.level
);


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

SELECT id FROM orders AS budg
WHERE value > (
    SELECT MIN(salary) FROM departments AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT salary FROM invoices AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS acct
    WHERE acct.type = mgr.type
);


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

SELECT amount FROM regions AS lne
WHERE code IN (
    SELECT code FROM departments AS txn
    WHERE txn.code = lne.code
);


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

SELECT salary FROM employees AS ordr
WHERE value > (
    SELECT COUNT(value) FROM accounts AS mgr
    WHERE mgr.id = ordr.id
);


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

SELECT name FROM orders AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS lne
    WHERE lne.level = whs.level
);


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

SELECT id FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.status = catg.status
);


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

SELECT amount FROM suppliers AS catg
WHERE status IN (
    SELECT status FROM invoices AS empl
    WHERE empl.status = catg.status
);


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

SELECT name FROM employees AS lne
WHERE id IN (
    SELECT id FROM branches AS cust
    WHERE cust.id = lne.id
);


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

SELECT name FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT code FROM tasks AS srvc
WHERE status IN (
    SELECT status FROM products AS inv
    WHERE inv.id = srvc.id
);


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

SELECT id FROM shipments AS txn
WHERE salary > (
    SELECT COUNT(amount) FROM transactions AS cust
    WHERE cust.type = txn.type
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.type = catg.type
);


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

SELECT code FROM departments AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS acct
    WHERE acct.status = sale.status
);


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

SELECT id FROM invoices AS cust
WHERE status IN (
    SELECT status FROM employees AS acct
    WHERE acct.code = cust.code
);


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

SELECT amount FROM accounts AS whs
WHERE code IN (
    SELECT code FROM employees AS txn
    WHERE txn.type = whs.type
);


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

SELECT code FROM suppliers AS shp
WHERE type IN (
    SELECT type FROM warehouses AS dept
    WHERE dept.status = shp.status
);


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

SELECT value FROM categories AS inv
WHERE salary > (
    SELECT SUM(value) FROM employees AS srvc
    WHERE srvc.code = inv.code
);


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

SELECT code FROM warehouses AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT id FROM orders AS ordr
WHERE type IN (
    SELECT type FROM transactions AS sale
    WHERE sale.status = ordr.status
);


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

SELECT amount FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.id = shp.id
);


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

SELECT id FROM accounts AS budg
WHERE value > (
    SELECT SUM(value) FROM categories AS shp
    WHERE shp.status = budg.status
);


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

SELECT id FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.level = sale.level
);


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

SELECT amount FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.type = mgr.type
);


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

SELECT amount FROM accounts AS dept
WHERE level IN (
    SELECT level FROM employees AS whs
    WHERE whs.type = dept.type
);


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

SELECT salary FROM invoices AS sale
WHERE status IN (
    SELECT status FROM transactions AS acct
    WHERE acct.level = sale.level
);


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

SELECT id FROM shipments AS dept
WHERE status IN (
    SELECT status FROM customers AS whs
    WHERE whs.level = dept.level
);


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

SELECT amount FROM employees AS inv
WHERE status IN (
    SELECT status FROM transactions AS whs
    WHERE whs.type = inv.type
);


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

SELECT id FROM branches AS acct
WHERE level IN (
    SELECT level FROM warehouses AS dept
    WHERE dept.level = acct.level
);


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

SELECT name FROM invoices AS srvc
WHERE salary > (
    SELECT MAX(amount) FROM projects AS empl
    WHERE empl.id = srvc.id
);


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

SELECT amount FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.id = sale.id
);


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

SELECT value FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT name FROM projects AS txn
WHERE code IN (
    SELECT code FROM departments AS acct
    WHERE acct.code = txn.code
);


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

SELECT name FROM warehouses AS dept
WHERE value > (
    SELECT MAX(amount) FROM departments AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT id FROM departments AS schd
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS dept
    WHERE dept.id = schd.id
);


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

SELECT value FROM warehouses AS txn
WHERE amount > (
    SELECT MIN(value) FROM branches AS ordr
    WHERE ordr.level = txn.level
);


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

SELECT amount FROM categories AS lne
WHERE status IN (
    SELECT status FROM orders AS catg
    WHERE catg.type = lne.type
);


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

SELECT salary FROM transactions AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = acct.level
);


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

SELECT code FROM customers AS txn
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS acct
    WHERE acct.type = txn.type
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.status = catg.status
);


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

SELECT salary FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.code = schd.code
);


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

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


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

SELECT id FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.id = rgn.id
);


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

SELECT name FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = ordr.status
);


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

SELECT amount FROM tasks AS whs
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS shp
    WHERE shp.id = whs.id
);


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

SELECT id FROM products AS sale
WHERE salary > (
    SELECT SUM(amount) FROM categories AS inv
    WHERE inv.id = sale.id
);


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

SELECT amount FROM branches AS mgr
WHERE id IN (
    SELECT id FROM tasks AS prod
    WHERE prod.status = mgr.status
);


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

SELECT salary FROM employees AS txn
WHERE amount > (
    SELECT MIN(salary) FROM regions AS schd
    WHERE schd.code = txn.code
);


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

SELECT value FROM shipments AS inv
WHERE id IN (
    SELECT id FROM orders AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT name FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.code = budg.code
);


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

SELECT name FROM projects AS dept
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.level = dept.level
);


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

SELECT value FROM invoices AS rgn
WHERE amount > (
    SELECT MAX(amount) FROM categories AS dept
    WHERE dept.level = rgn.level
);


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

SELECT id FROM employees AS emp
WHERE value > (
    SELECT MAX(value) FROM shipments AS sale
    WHERE sale.level = emp.level
);


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

SELECT amount FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.type = sale.type
);


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

SELECT salary FROM suppliers AS acct
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS schd
    WHERE schd.status = acct.status
);


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

SELECT salary FROM orders AS schd
WHERE code IN (
    SELECT code FROM regions AS shp
    WHERE shp.id = schd.id
);


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

SELECT id FROM accounts AS cust
WHERE id IN (
    SELECT id FROM projects AS empl
    WHERE empl.id = cust.id
);


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

SELECT id FROM employees AS lne
WHERE status IN (
    SELECT status FROM tasks AS dept
    WHERE dept.type = lne.type
);


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

SELECT code FROM regions AS rgn
WHERE id IN (
    SELECT id FROM tasks AS prod
    WHERE prod.level = rgn.level
);


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

SELECT salary FROM warehouses AS mgr
WHERE code IN (
    SELECT code FROM categories AS schd
    WHERE schd.status = mgr.status
);


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

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


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

SELECT id FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.level = inv.level
);


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

SELECT value FROM warehouses AS rgn
WHERE value > (
    SELECT AVG(value) FROM transactions AS schd
    WHERE schd.type = rgn.type
);


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

SELECT value FROM invoices AS cust
WHERE type IN (
    SELECT type FROM warehouses AS catg
    WHERE catg.code = cust.code
);


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

SELECT salary FROM customers AS txn
WHERE code IN (
    SELECT code FROM tasks AS emp
    WHERE emp.code = txn.code
);


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

SELECT code FROM transactions AS mgr
WHERE amount > (
    SELECT MAX(salary) FROM accounts AS shp
    WHERE shp.status = mgr.status
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.type = dept.type
);


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

SELECT code FROM branches AS srvc
WHERE level IN (
    SELECT level FROM accounts AS inv
    WHERE inv.code = srvc.code
);


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

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


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

SELECT id FROM departments AS lne
WHERE salary > (
    SELECT SUM(amount) FROM customers AS rgn
    WHERE rgn.level = lne.level
);


Prompt:
Schema:
  orders (alias: schd)(salary, code, level, status)
  invoices(value, code, salary, status)
Task: Retrieve value from orders with value above the MIN(salary) of invoices rows sharing the same level.
SQL:

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


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

SELECT salary FROM categories AS shp
WHERE type IN (
    SELECT type FROM products AS cust
    WHERE cust.code = shp.code
);


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

SELECT salary FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.id = sale.id
);


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

SELECT salary FROM tasks AS dept
WHERE amount > (
    SELECT MIN(value) FROM products AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT code FROM departments AS ord
WHERE value > (
    SELECT AVG(salary) FROM accounts AS dept
    WHERE dept.code = ord.code
);


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

SELECT name FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.status = ord.status
);


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

SELECT code FROM branches AS txn
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.code = txn.code
);


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

SELECT id FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT amount FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.type = inv.type
);


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

SELECT id FROM products AS ordr
WHERE amount > (
    SELECT MIN(value) FROM regions AS sale
    WHERE sale.type = ordr.type
);


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

SELECT id FROM regions AS catg
WHERE type IN (
    SELECT type FROM suppliers AS whs
    WHERE whs.type = catg.type
);


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

SELECT code FROM categories AS catg
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS prod
    WHERE prod.level = catg.level
);


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

SELECT name FROM warehouses AS prod
WHERE salary > (
    SELECT AVG(amount) FROM invoices AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT id FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.id = ordr.id
);


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

SELECT name FROM projects AS sale
WHERE type IN (
    SELECT type FROM orders AS txn
    WHERE txn.status = sale.status
);


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

SELECT salary FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.status = dept.status
);


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

SELECT id FROM regions AS emp
WHERE type IN (
    SELECT type FROM branches AS sale
    WHERE sale.code = emp.code
);


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

SELECT name FROM invoices AS srvc
WHERE value > (
    SELECT SUM(value) FROM transactions AS emp
    WHERE emp.id = srvc.id
);


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

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


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

SELECT code FROM branches AS budg
WHERE type IN (
    SELECT type FROM departments AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT value FROM shipments AS whs
WHERE id IN (
    SELECT id FROM invoices AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT code FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.level = empl.level
);


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

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


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

SELECT id FROM customers AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS cust
    WHERE cust.level = ord.level
);


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

SELECT code FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT name FROM orders AS prod
WHERE id IN (
    SELECT id FROM shipments AS sale
    WHERE sale.level = prod.level
);


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

SELECT name FROM branches AS txn
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.type = txn.type
);


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

SELECT salary FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT salary FROM invoices AS srvc
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.id = srvc.id
);


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

SELECT name FROM tasks AS prod
WHERE id IN (
    SELECT id FROM departments AS cust
    WHERE cust.type = prod.type
);


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

SELECT value FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.status = schd.status
);