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

SELECT amount FROM customers AS emp
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS shp
    WHERE shp.level = emp.level
);


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

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


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

SELECT value FROM orders AS acct
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS emp
    WHERE emp.status = acct.status
);


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

SELECT amount FROM transactions AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM departments AS cust
    WHERE cust.status = srvc.status
);


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

SELECT name FROM accounts AS dept
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.type = dept.type
);


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

SELECT name FROM products AS budg
WHERE amount > (
    SELECT SUM(value) FROM departments AS dept
    WHERE dept.code = budg.code
);


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

SELECT amount FROM warehouses AS inv
WHERE amount > (
    SELECT MAX(salary) FROM orders AS budg
    WHERE budg.code = inv.code
);


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

SELECT salary FROM projects AS srvc
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS budg
    WHERE budg.code = srvc.code
);


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

SELECT id FROM suppliers AS txn
WHERE value > (
    SELECT MAX(amount) FROM accounts AS budg
    WHERE budg.level = txn.level
);


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

SELECT id FROM categories AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS lne
    WHERE lne.level = acct.level
);


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

SELECT salary FROM projects AS ordr
WHERE status IN (
    SELECT status FROM products AS rgn
    WHERE rgn.code = ordr.code
);


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

SELECT value FROM customers AS catg
WHERE value > (
    SELECT MIN(salary) FROM products AS acct
    WHERE acct.type = catg.type
);


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

SELECT value FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.id = inv.id
);


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

SELECT amount FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.level = sale.level
);


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

SELECT amount FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT amount FROM accounts AS emp
WHERE value > (
    SELECT AVG(salary) FROM transactions AS empl
    WHERE empl.status = emp.status
);


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

SELECT id FROM orders AS srvc
WHERE amount > (
    SELECT MIN(value) FROM categories AS catg
    WHERE catg.status = srvc.status
);


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

SELECT amount FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.id = acct.id
);


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

SELECT salary FROM accounts AS shp
WHERE status IN (
    SELECT status FROM products AS catg
    WHERE catg.code = shp.code
);


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

SELECT salary FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.id = ord.id
);


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

SELECT name FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT code FROM branches AS mgr
WHERE code IN (
    SELECT code FROM orders AS shp
    WHERE shp.code = mgr.code
);


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

SELECT id FROM branches AS sale
WHERE level IN (
    SELECT level FROM shipments AS budg
    WHERE budg.status = sale.status
);


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

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


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

SELECT id FROM products AS mgr
WHERE value > (
    SELECT SUM(salary) FROM branches AS lne
    WHERE lne.type = mgr.type
);


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

SELECT id FROM warehouses AS cust
WHERE value > (
    SELECT MAX(salary) FROM projects AS empl
    WHERE empl.level = cust.level
);


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

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


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

SELECT name FROM accounts AS lne
WHERE amount > (
    SELECT MIN(value) FROM projects AS txn
    WHERE txn.type = lne.type
);


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

SELECT code FROM categories AS rgn
WHERE value > (
    SELECT MAX(value) FROM branches AS inv
    WHERE inv.level = rgn.level
);


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

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


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

SELECT value FROM orders AS catg
WHERE salary > (
    SELECT AVG(value) FROM products AS ordr
    WHERE ordr.id = catg.id
);


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

SELECT value FROM departments AS budg
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS txn
    WHERE txn.status = budg.status
);


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

SELECT name FROM tasks AS rgn
WHERE amount > (
    SELECT AVG(salary) FROM products AS ord
    WHERE ord.id = rgn.id
);


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

SELECT id FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT salary FROM products AS sale
WHERE value > (
    SELECT SUM(salary) FROM departments AS whs
    WHERE whs.code = sale.code
);


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

SELECT code FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT value FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.level = mgr.level
);


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

SELECT amount FROM projects AS ord
WHERE status IN (
    SELECT status FROM suppliers AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT amount FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.status = sale.status
);


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

SELECT value FROM orders AS dept
WHERE type IN (
    SELECT type FROM employees AS empl
    WHERE empl.status = dept.status
);


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

SELECT id FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.id = ordr.id
);


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

SELECT amount FROM suppliers AS budg
WHERE id IN (
    SELECT id FROM transactions AS whs
    WHERE whs.type = budg.type
);


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

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


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

SELECT name FROM regions AS empl
WHERE id IN (
    SELECT id FROM accounts AS catg
    WHERE catg.type = empl.type
);


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

SELECT id FROM projects AS empl
WHERE value > (
    SELECT COUNT(salary) FROM accounts AS cust
    WHERE cust.code = empl.code
);


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

SELECT code FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.level = ordr.level
);


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

SELECT value FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.code = prod.code
);


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

SELECT amount FROM products AS rgn
WHERE salary > (
    SELECT SUM(salary) FROM branches AS sale
    WHERE sale.status = rgn.status
);


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

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


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

SELECT salary FROM categories AS ordr
WHERE value > (
    SELECT AVG(value) FROM customers AS budg
    WHERE budg.id = ordr.id
);


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

SELECT amount FROM invoices AS budg
WHERE value > (
    SELECT MIN(amount) FROM categories AS ord
    WHERE ord.status = budg.status
);


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

SELECT id FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS ordr
    WHERE ordr.id = schd.id
);


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

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


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

SELECT value FROM suppliers AS catg
WHERE amount > (
    SELECT MAX(amount) FROM products AS whs
    WHERE whs.id = catg.id
);


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

SELECT code FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.status = emp.status
);


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

SELECT amount FROM customers AS empl
WHERE code IN (
    SELECT code FROM projects AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT value FROM categories AS rgn
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS empl
    WHERE empl.type = rgn.type
);


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

SELECT amount FROM branches AS ord
WHERE code IN (
    SELECT code FROM tasks AS ordr
    WHERE ordr.code = ord.code
);


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

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


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

SELECT value FROM warehouses AS prod
WHERE amount > (
    SELECT MIN(value) FROM employees AS ord
    WHERE ord.type = prod.type
);


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

SELECT code FROM shipments AS rgn
WHERE amount > (
    SELECT SUM(amount) FROM categories AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT salary FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.type = rgn.type
);


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

SELECT name FROM warehouses AS dept
WHERE value > (
    SELECT MIN(salary) FROM invoices AS sale
    WHERE sale.code = dept.code
);


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

SELECT code FROM suppliers AS txn
WHERE level IN (
    SELECT level FROM customers AS prod
    WHERE prod.code = txn.code
);


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

SELECT salary FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.type = budg.type
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.id = ord.id
);


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

SELECT amount FROM tasks AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM warehouses AS shp
    WHERE shp.level = ordr.level
);


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

SELECT amount FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.id = inv.id
);


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

SELECT value FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.code = mgr.code
);


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

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


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

SELECT salary FROM shipments AS empl
WHERE salary > (
    SELECT COUNT(salary) FROM transactions AS schd
    WHERE schd.code = empl.code
);


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

SELECT name FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.type = srvc.type
);


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

SELECT salary FROM categories AS ord
WHERE salary > (
    SELECT COUNT(value) FROM projects AS srvc
    WHERE srvc.status = ord.status
);


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

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


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

SELECT code FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.level = schd.level
);


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

SELECT value FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.level = ordr.level
);


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

SELECT name FROM categories AS whs
WHERE amount > (
    SELECT MAX(amount) FROM customers AS ord
    WHERE ord.id = whs.id
);


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

SELECT name FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.code = rgn.code
);


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

SELECT name FROM transactions AS lne
WHERE value > (
    SELECT COUNT(value) FROM products AS whs
    WHERE whs.code = lne.code
);


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

SELECT amount FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.type = sale.type
);


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

SELECT id FROM accounts AS emp
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.status = emp.status
);


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

SELECT amount FROM employees AS txn
WHERE salary > (
    SELECT AVG(salary) FROM departments AS cust
    WHERE cust.code = txn.code
);


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

SELECT salary FROM transactions AS budg
WHERE type IN (
    SELECT type FROM tasks AS whs
    WHERE whs.level = budg.level
);


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

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


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

SELECT salary FROM categories AS rgn
WHERE value > (
    SELECT SUM(value) FROM accounts AS whs
    WHERE whs.status = rgn.status
);


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

SELECT name FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.code = dept.code
);


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

SELECT value FROM suppliers AS acct
WHERE salary > (
    SELECT MIN(value) FROM projects AS cust
    WHERE cust.id = acct.id
);


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

SELECT name FROM employees AS budg
WHERE id IN (
    SELECT id FROM projects AS prod
    WHERE prod.level = budg.level
);


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

SELECT amount FROM suppliers AS txn
WHERE value > (
    SELECT MIN(salary) FROM categories AS schd
    WHERE schd.code = txn.code
);


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

SELECT name FROM projects AS rgn
WHERE value > (
    SELECT AVG(amount) FROM shipments AS empl
    WHERE empl.code = rgn.code
);


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

SELECT amount FROM products AS emp
WHERE level IN (
    SELECT level FROM regions AS mgr
    WHERE mgr.code = emp.code
);


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

SELECT name FROM tasks AS acct
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS budg
    WHERE budg.code = acct.code
);


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

SELECT amount FROM customers AS shp
WHERE type IN (
    SELECT type FROM projects AS lne
    WHERE lne.status = shp.status
);


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

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


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

SELECT id FROM departments AS budg
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT name FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.code = cust.code
);


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

SELECT name FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.level = rgn.level
);


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

SELECT name FROM suppliers AS schd
WHERE id IN (
    SELECT id FROM orders AS sale
    WHERE sale.status = schd.status
);


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

SELECT code FROM tasks AS cust
WHERE level IN (
    SELECT level FROM warehouses AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT code FROM invoices AS dept
WHERE code IN (
    SELECT code FROM shipments AS ord
    WHERE ord.level = dept.level
);


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS dept
    WHERE dept.code = prod.code
);


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

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


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

SELECT id FROM projects AS prod
WHERE salary > (
    SELECT MAX(salary) FROM products AS schd
    WHERE schd.level = prod.level
);


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

SELECT salary FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = acct.level
);


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

SELECT salary FROM accounts AS schd
WHERE value > (
    SELECT SUM(salary) FROM transactions AS cust
    WHERE cust.status = schd.status
);


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

SELECT id FROM accounts AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM departments AS rgn
    WHERE rgn.status = srvc.status
);


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

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


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

SELECT code FROM invoices AS schd
WHERE code IN (
    SELECT code FROM tasks AS cust
    WHERE cust.type = schd.type
);


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

SELECT amount FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.type = mgr.type
);


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

SELECT code FROM categories AS prod
WHERE level IN (
    SELECT level FROM tasks AS txn
    WHERE txn.status = prod.status
);


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

SELECT amount FROM categories AS acct
WHERE value > (
    SELECT MAX(salary) FROM regions AS dept
    WHERE dept.status = acct.status
);


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

SELECT name FROM tasks AS schd
WHERE id IN (
    SELECT id FROM orders AS inv
    WHERE inv.id = schd.id
);


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

SELECT id FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.type = txn.type
);


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

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


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

SELECT name FROM invoices AS rgn
WHERE id IN (
    SELECT id FROM regions AS catg
    WHERE catg.status = rgn.status
);


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

SELECT amount FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.type = shp.type
);


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

SELECT code FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = acct.type
);


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

SELECT name FROM transactions AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM departments AS sale
    WHERE sale.type = schd.type
);


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

SELECT id FROM tasks AS dept
WHERE status IN (
    SELECT status FROM projects AS shp
    WHERE shp.code = dept.code
);


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

SELECT value FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.status = rgn.status
);


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

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


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

SELECT amount FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.level = dept.level
);


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

SELECT amount FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.code = sale.code
);


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

SELECT value FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT value FROM customers AS catg
WHERE level IN (
    SELECT level FROM transactions AS prod
    WHERE prod.id = catg.id
);


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

SELECT amount FROM accounts AS cust
WHERE type IN (
    SELECT type FROM employees AS srvc
    WHERE srvc.id = cust.id
);


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

SELECT amount FROM customers AS shp
WHERE status IN (
    SELECT status FROM products AS prod
    WHERE prod.type = shp.type
);


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

SELECT salary FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.type = ordr.type
);


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

SELECT name FROM branches AS dept
WHERE status IN (
    SELECT status FROM accounts AS schd
    WHERE schd.status = dept.status
);


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

SELECT amount FROM suppliers AS dept
WHERE level IN (
    SELECT level FROM orders AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT salary FROM employees AS inv
WHERE id IN (
    SELECT id FROM customers AS schd
    WHERE schd.level = inv.level
);


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

SELECT code FROM categories AS shp
WHERE level IN (
    SELECT level FROM orders AS dept
    WHERE dept.level = shp.level
);


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

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


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

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


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

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


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

SELECT code FROM suppliers AS cust
WHERE type IN (
    SELECT type FROM regions AS whs
    WHERE whs.status = cust.status
);


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

SELECT salary FROM orders AS cust
WHERE code IN (
    SELECT code FROM branches AS empl
    WHERE empl.status = cust.status
);


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

SELECT value FROM employees AS acct
WHERE value > (
    SELECT SUM(amount) FROM regions AS ordr
    WHERE ordr.level = acct.level
);


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

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


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

SELECT code FROM projects AS acct
WHERE status IN (
    SELECT status FROM products AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT id FROM transactions AS dept
WHERE status IN (
    SELECT status FROM orders AS shp
    WHERE shp.id = dept.id
);


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

SELECT name FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.status = rgn.status
);


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

SELECT code FROM transactions AS emp
WHERE value > (
    SELECT COUNT(value) FROM projects AS mgr
    WHERE mgr.status = emp.status
);


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

SELECT salary FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.id = catg.id
);


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

SELECT amount FROM employees AS catg
WHERE code IN (
    SELECT code FROM categories AS empl
    WHERE empl.status = catg.status
);


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

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


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

SELECT value FROM shipments AS cust
WHERE code IN (
    SELECT code FROM suppliers AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT code FROM regions AS ordr
WHERE amount > (
    SELECT MIN(value) FROM transactions AS emp
    WHERE emp.level = ordr.level
);


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

SELECT amount FROM orders AS prod
WHERE type IN (
    SELECT type FROM projects AS budg
    WHERE budg.id = prod.id
);


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

SELECT amount FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.level = cust.level
);


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

SELECT salary FROM invoices AS whs
WHERE status IN (
    SELECT status FROM employees AS sale
    WHERE sale.code = whs.code
);


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

SELECT amount FROM departments AS mgr
WHERE amount > (
    SELECT MAX(value) FROM invoices AS emp
    WHERE emp.status = mgr.status
);


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

SELECT value FROM employees AS empl
WHERE value > (
    SELECT COUNT(value) FROM orders AS emp
    WHERE emp.code = empl.code
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.id = prod.id
);


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

SELECT amount FROM branches AS schd
WHERE id IN (
    SELECT id FROM warehouses AS emp
    WHERE emp.code = schd.code
);


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

SELECT salary FROM branches AS sale
WHERE salary > (
    SELECT SUM(salary) FROM warehouses AS txn
    WHERE txn.type = sale.type
);


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

SELECT salary FROM shipments AS srvc
WHERE status IN (
    SELECT status FROM regions AS empl
    WHERE empl.status = srvc.status
);


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

SELECT code FROM shipments AS mgr
WHERE value > (
    SELECT MAX(salary) FROM transactions AS sale
    WHERE sale.type = mgr.type
);


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

SELECT code FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT amount FROM invoices AS empl
WHERE level IN (
    SELECT level FROM projects AS ordr
    WHERE ordr.id = empl.id
);


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

SELECT code FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.level = inv.level
);


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

SELECT code FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.id = acct.id
);


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

SELECT name FROM customers AS shp
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS emp
    WHERE emp.level = shp.level
);


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

SELECT code FROM categories AS budg
WHERE id IN (
    SELECT id FROM orders AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT amount FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.status = mgr.status
);


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

SELECT value FROM orders AS schd
WHERE level IN (
    SELECT level FROM accounts AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT amount FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.code = ordr.code
);


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

SELECT amount FROM customers AS rgn
WHERE status IN (
    SELECT status FROM transactions AS shp
    WHERE shp.code = rgn.code
);


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

SELECT code FROM branches AS dept
WHERE status IN (
    SELECT status FROM departments AS ord
    WHERE ord.id = dept.id
);


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

SELECT code FROM accounts AS srvc
WHERE type IN (
    SELECT type FROM tasks AS dept
    WHERE dept.level = srvc.level
);


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

SELECT name FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.level = prod.level
);


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

SELECT id FROM tasks AS empl
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT code FROM products AS budg
WHERE code IN (
    SELECT code FROM employees AS srvc
    WHERE srvc.code = budg.code
);


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

SELECT salary FROM accounts AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.id = inv.id
);


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

SELECT name FROM tasks AS prod
WHERE salary > (
    SELECT COUNT(value) FROM employees AS budg
    WHERE budg.level = prod.level
);


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

SELECT amount FROM orders AS ordr
WHERE type IN (
    SELECT type FROM branches AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT salary FROM accounts AS mgr
WHERE type IN (
    SELECT type FROM shipments AS empl
    WHERE empl.type = mgr.type
);


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

SELECT value FROM accounts AS prod
WHERE amount > (
    SELECT SUM(amount) FROM invoices AS txn
    WHERE txn.id = prod.id
);


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

SELECT salary FROM accounts AS emp
WHERE id IN (
    SELECT id FROM warehouses AS sale
    WHERE sale.level = emp.level
);


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

SELECT salary FROM projects AS rgn
WHERE type IN (
    SELECT type FROM suppliers AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT id FROM branches AS ordr
WHERE value > (
    SELECT MAX(amount) FROM regions AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT value FROM orders AS sale
WHERE salary > (
    SELECT SUM(value) FROM departments AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT value FROM tasks AS prod
WHERE status IN (
    SELECT status FROM shipments AS inv
    WHERE inv.code = prod.code
);


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

SELECT name FROM categories AS ord
WHERE status IN (
    SELECT status FROM regions AS schd
    WHERE schd.status = ord.status
);


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

SELECT amount FROM warehouses AS empl
WHERE salary > (
    SELECT MIN(value) FROM branches AS txn
    WHERE txn.type = empl.type
);


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

SELECT value FROM projects AS srvc
WHERE level IN (
    SELECT level FROM orders AS dept
    WHERE dept.type = srvc.type
);


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

SELECT name FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = ordr.status
);


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

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


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

SELECT amount FROM tasks AS ordr
WHERE value > (
    SELECT MIN(value) FROM customers AS emp
    WHERE emp.status = ordr.status
);


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

SELECT value FROM accounts AS schd
WHERE level IN (
    SELECT level FROM employees AS txn
    WHERE txn.status = schd.status
);


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

SELECT amount FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.status = txn.status
);


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

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


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

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


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

SELECT code FROM suppliers AS txn
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS lne
    WHERE lne.status = txn.status
);


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

SELECT salary FROM warehouses AS catg
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.type = catg.type
);


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

SELECT code FROM warehouses AS srvc
WHERE level IN (
    SELECT level FROM categories AS lne
    WHERE lne.code = srvc.code
);


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

SELECT amount FROM warehouses AS ord
WHERE type IN (
    SELECT type FROM accounts AS txn
    WHERE txn.status = ord.status
);


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

SELECT name FROM tasks AS ordr
WHERE code IN (
    SELECT code FROM branches AS empl
    WHERE empl.id = ordr.id
);


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

SELECT name FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.status = emp.status
);


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

SELECT id FROM employees AS inv
WHERE level IN (
    SELECT level FROM customers AS sale
    WHERE sale.status = inv.status
);


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

SELECT value FROM regions AS schd
WHERE id IN (
    SELECT id FROM transactions AS emp
    WHERE emp.status = schd.status
);


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

SELECT id FROM tasks AS acct
WHERE amount > (
    SELECT SUM(value) FROM products AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT name FROM orders AS shp
WHERE id IN (
    SELECT id FROM warehouses AS srvc
    WHERE srvc.level = shp.level
);


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

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


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

SELECT id FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.level = schd.level
);


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

SELECT amount FROM employees AS prod
WHERE status IN (
    SELECT status FROM categories AS acct
    WHERE acct.id = prod.id
);


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

SELECT id FROM departments AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM products AS empl
    WHERE empl.code = shp.code
);


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

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


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

SELECT code FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS schd
    WHERE schd.id = dept.id
);


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

SELECT value FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT code FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.id = ordr.id
);


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

SELECT salary FROM departments AS schd
WHERE status IN (
    SELECT status FROM transactions AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT value FROM departments AS empl
WHERE id IN (
    SELECT id FROM invoices AS lne
    WHERE lne.status = empl.status
);


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

SELECT amount FROM shipments AS dept
WHERE value > (
    SELECT MIN(salary) FROM orders AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT salary FROM employees AS rgn
WHERE amount > (
    SELECT MAX(amount) FROM orders AS emp
    WHERE emp.code = rgn.code
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.code = cust.code
);


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

SELECT code FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.level = shp.level
);


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

SELECT value FROM departments AS sale
WHERE value > (
    SELECT MIN(value) FROM shipments AS catg
    WHERE catg.code = sale.code
);


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

SELECT value FROM orders AS emp
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS budg
    WHERE budg.status = emp.status
);


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

SELECT name FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT amount FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.status = lne.status
);


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

SELECT code FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.id = inv.id
);


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

SELECT code FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS whs
    WHERE whs.code = empl.code
);


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

SELECT salary FROM orders AS inv
WHERE code IN (
    SELECT code FROM suppliers AS emp
    WHERE emp.id = inv.id
);


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

SELECT id FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.level = catg.level
);


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

SELECT salary FROM invoices AS dept
WHERE value > (
    SELECT MAX(amount) FROM customers AS prod
    WHERE prod.code = dept.code
);


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

SELECT salary FROM suppliers AS dept
WHERE status IN (
    SELECT status FROM products AS shp
    WHERE shp.type = dept.type
);


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

SELECT name FROM products AS whs
WHERE status IN (
    SELECT status FROM accounts AS inv
    WHERE inv.code = whs.code
);


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

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


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

SELECT value FROM projects AS mgr
WHERE value > (
    SELECT AVG(salary) FROM orders AS lne
    WHERE lne.level = mgr.level
);


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

SELECT amount FROM employees AS catg
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS ord
    WHERE ord.level = catg.level
);


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

SELECT id FROM departments AS srvc
WHERE id IN (
    SELECT id FROM regions AS prod
    WHERE prod.level = srvc.level
);


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

SELECT salary FROM suppliers AS schd
WHERE value > (
    SELECT MAX(amount) FROM tasks AS whs
    WHERE whs.code = schd.code
);


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

SELECT id FROM tasks AS cust
WHERE id IN (
    SELECT id FROM warehouses AS budg
    WHERE budg.code = cust.code
);


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

SELECT value FROM transactions AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT salary FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.level = schd.level
);


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

SELECT amount FROM products AS inv
WHERE level IN (
    SELECT level FROM accounts AS dept
    WHERE dept.type = inv.type
);


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

SELECT id FROM warehouses AS rgn
WHERE id IN (
    SELECT id FROM suppliers AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT salary FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.type = rgn.type
);


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

SELECT value FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.level = catg.level
);


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

SELECT amount FROM transactions AS schd
WHERE value > (
    SELECT MIN(amount) FROM shipments AS lne
    WHERE lne.id = schd.id
);


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

SELECT code FROM transactions AS emp
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS ordr
    WHERE ordr.type = emp.type
);


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

SELECT value FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = whs.level
);


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

SELECT name FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT value FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.code = schd.code
);


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

SELECT code FROM categories AS lne
WHERE id IN (
    SELECT id FROM branches AS budg
    WHERE budg.id = lne.id
);


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

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


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

SELECT id FROM employees AS schd
WHERE amount > (
    SELECT SUM(amount) FROM customers AS acct
    WHERE acct.code = schd.code
);


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

SELECT value FROM shipments AS mgr
WHERE value > (
    SELECT SUM(salary) FROM categories AS catg
    WHERE catg.level = mgr.level
);


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

SELECT value FROM employees AS sale
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.status = sale.status
);


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

SELECT value FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.status = whs.status
);


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

SELECT id FROM categories AS lne
WHERE type IN (
    SELECT type FROM projects AS rgn
    WHERE rgn.id = lne.id
);


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

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


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

SELECT salary FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.type = sale.type
);


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

SELECT value FROM regions AS budg
WHERE amount > (
    SELECT MAX(salary) FROM orders AS dept
    WHERE dept.code = budg.code
);


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

SELECT amount FROM orders AS budg
WHERE id IN (
    SELECT id FROM invoices AS emp
    WHERE emp.level = budg.level
);


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

SELECT value FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.status = emp.status
);


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

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


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

SELECT name FROM departments AS schd
WHERE id IN (
    SELECT id FROM regions AS empl
    WHERE empl.code = schd.code
);


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

SELECT id FROM warehouses AS ordr
WHERE code IN (
    SELECT code FROM categories AS shp
    WHERE shp.status = ordr.status
);


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

SELECT code FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = acct.status
);


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

SELECT name FROM products AS shp
WHERE amount > (
    SELECT MAX(amount) FROM departments AS ordr
    WHERE ordr.id = shp.id
);


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

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


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

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


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

SELECT amount FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT amount FROM transactions AS inv
WHERE salary > (
    SELECT AVG(salary) FROM branches AS budg
    WHERE budg.status = inv.status
);


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

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


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

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


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

SELECT value FROM transactions AS ord
WHERE type IN (
    SELECT type FROM invoices AS emp
    WHERE emp.status = ord.status
);


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

SELECT code FROM shipments AS lne
WHERE amount > (
    SELECT SUM(amount) FROM products AS whs
    WHERE whs.id = lne.id
);


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

SELECT salary FROM customers AS sale
WHERE id IN (
    SELECT id FROM invoices AS prod
    WHERE prod.status = sale.status
);


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

SELECT id FROM tasks AS txn
WHERE value > (
    SELECT MIN(value) FROM suppliers AS acct
    WHERE acct.code = txn.code
);


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

SELECT value FROM customers AS sale
WHERE type IN (
    SELECT type FROM tasks AS dept
    WHERE dept.status = sale.status
);


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

SELECT amount FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.code = inv.code
);


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

SELECT salary FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.type = lne.type
);


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

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


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

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


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

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


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

SELECT code FROM categories AS acct
WHERE value > (
    SELECT MAX(salary) FROM regions AS ord
    WHERE ord.type = acct.type
);


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

SELECT amount FROM employees AS mgr
WHERE value > (
    SELECT AVG(salary) FROM shipments AS lne
    WHERE lne.id = mgr.id
);


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

SELECT amount FROM employees AS acct
WHERE level IN (
    SELECT level FROM warehouses AS whs
    WHERE whs.type = acct.type
);


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

SELECT name FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.status = lne.status
);


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

SELECT salary FROM warehouses AS srvc
WHERE status IN (
    SELECT status FROM suppliers AS ord
    WHERE ord.id = srvc.id
);


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

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


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

SELECT name FROM suppliers AS budg
WHERE value > (
    SELECT COUNT(salary) FROM projects AS ordr
    WHERE ordr.code = budg.code
);


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

SELECT amount FROM shipments AS emp
WHERE value > (
    SELECT SUM(salary) FROM regions AS txn
    WHERE txn.status = emp.status
);


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT amount FROM branches AS txn
WHERE status IN (
    SELECT status FROM categories AS shp
    WHERE shp.id = txn.id
);


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

SELECT value FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS srvc
    WHERE srvc.type = schd.type
);


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

SELECT value FROM orders AS emp
WHERE code IN (
    SELECT code FROM products AS budg
    WHERE budg.status = emp.status
);


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

SELECT salary FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.level = sale.level
);


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

SELECT code FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.code = budg.code
);


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.id = ord.id
);