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

SELECT code FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.status = acct.status
);


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

SELECT salary FROM invoices AS txn
WHERE type IN (
    SELECT type FROM products AS cust
    WHERE cust.type = txn.type
);


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

SELECT code FROM warehouses AS rgn
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS dept
    WHERE dept.id = rgn.id
);


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

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


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

SELECT code FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.code = ordr.code
);


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

SELECT name FROM transactions AS lne
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS whs
    WHERE whs.type = lne.type
);


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

SELECT salary FROM transactions AS sale
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS catg
    WHERE catg.status = sale.status
);


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

SELECT value FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM regions AS lne
    WHERE lne.level = budg.level
);


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

SELECT salary FROM tasks AS cust
WHERE code IN (
    SELECT code FROM transactions AS rgn
    WHERE rgn.status = cust.status
);


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

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


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

SELECT name FROM branches AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS inv
    WHERE inv.code = acct.code
);


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

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


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

SELECT value FROM categories AS catg
WHERE id IN (
    SELECT id FROM projects AS sale
    WHERE sale.code = catg.code
);


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

SELECT value FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.type = rgn.type
);


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

SELECT salary FROM employees AS srvc
WHERE value > (
    SELECT AVG(value) FROM customers AS lne
    WHERE lne.type = srvc.type
);


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.level = cust.level
);


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

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


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.level = catg.level
);


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

SELECT id FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.type = whs.type
);


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

SELECT name FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.code = ordr.code
);


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

SELECT amount FROM employees AS shp
WHERE status IN (
    SELECT status FROM transactions AS prod
    WHERE prod.id = shp.id
);


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

SELECT name FROM customers AS prod
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.status = prod.status
);


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

SELECT code FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT name FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.level = prod.level
);


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

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


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

SELECT id FROM branches AS budg
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.level = budg.level
);


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

SELECT code FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = schd.type
);


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

SELECT name FROM categories AS shp
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS cust
    WHERE cust.code = shp.code
);


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

SELECT salary FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.id = dept.id
);


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

SELECT name FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.level = inv.level
);


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

SELECT salary FROM branches AS mgr
WHERE value > (
    SELECT AVG(amount) FROM shipments AS budg
    WHERE budg.code = mgr.code
);


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

SELECT name FROM accounts AS txn
WHERE type IN (
    SELECT type FROM departments AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT amount FROM suppliers AS inv
WHERE status IN (
    SELECT status FROM shipments AS schd
    WHERE schd.id = inv.id
);


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

SELECT value FROM tasks AS cust
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.id = cust.id
);


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

SELECT id FROM employees AS catg
WHERE type IN (
    SELECT type FROM accounts AS srvc
    WHERE srvc.code = catg.code
);


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

SELECT salary FROM orders AS budg
WHERE salary > (
    SELECT MIN(value) FROM warehouses AS empl
    WHERE empl.type = budg.type
);


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

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


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

SELECT salary FROM transactions AS lne
WHERE code IN (
    SELECT code FROM regions AS cust
    WHERE cust.id = lne.id
);


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

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


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS sale
    WHERE sale.id = catg.id
);


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

SELECT code FROM departments AS ordr
WHERE status IN (
    SELECT status FROM products AS shp
    WHERE shp.type = ordr.type
);


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

SELECT id FROM projects AS txn
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT salary FROM regions AS acct
WHERE type IN (
    SELECT type FROM projects AS budg
    WHERE budg.level = acct.level
);


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

SELECT salary FROM branches AS dept
WHERE salary > (
    SELECT MAX(value) FROM products AS lne
    WHERE lne.level = dept.level
);


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

SELECT salary FROM suppliers AS sale
WHERE level IN (
    SELECT level FROM branches AS budg
    WHERE budg.level = sale.level
);


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

SELECT id FROM products AS empl
WHERE value > (
    SELECT MAX(amount) FROM invoices AS ordr
    WHERE ordr.id = empl.id
);


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

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


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

SELECT name FROM departments AS emp
WHERE salary > (
    SELECT MIN(value) FROM categories AS empl
    WHERE empl.level = emp.level
);


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

SELECT salary FROM regions AS prod
WHERE type IN (
    SELECT type FROM employees AS schd
    WHERE schd.code = prod.code
);


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

SELECT name FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.type = sale.type
);


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

SELECT salary FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.level = txn.level
);


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

SELECT salary FROM orders AS whs
WHERE amount > (
    SELECT MIN(salary) FROM transactions AS sale
    WHERE sale.id = whs.id
);


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

SELECT name FROM products AS budg
WHERE code IN (
    SELECT code FROM suppliers AS rgn
    WHERE rgn.code = budg.code
);


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

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


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

SELECT name FROM projects AS catg
WHERE value > (
    SELECT AVG(amount) FROM departments AS prod
    WHERE prod.status = catg.status
);


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

SELECT id FROM shipments AS mgr
WHERE amount > (
    SELECT MIN(amount) FROM transactions AS cust
    WHERE cust.level = mgr.level
);


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

SELECT id FROM shipments AS shp
WHERE code IN (
    SELECT code FROM employees AS sale
    WHERE sale.id = shp.id
);


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

SELECT name FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.status = empl.status
);


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

SELECT id FROM shipments AS shp
WHERE salary > (
    SELECT SUM(amount) FROM departments AS prod
    WHERE prod.id = shp.id
);


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

SELECT salary FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.code = srvc.code
);


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

SELECT id FROM accounts AS txn
WHERE id IN (
    SELECT id FROM departments AS empl
    WHERE empl.id = txn.id
);


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

SELECT id FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.status = emp.status
);


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

SELECT amount FROM orders AS mgr
WHERE amount > (
    SELECT SUM(value) FROM invoices AS prod
    WHERE prod.code = mgr.code
);


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

SELECT salary FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.code = catg.code
);


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

SELECT value FROM customers AS dept
WHERE code IN (
    SELECT code FROM branches AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT amount FROM branches AS schd
WHERE level IN (
    SELECT level FROM suppliers AS shp
    WHERE shp.code = schd.code
);


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

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


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

SELECT value FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.code = lne.code
);


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

SELECT code FROM shipments AS acct
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.id = acct.id
);


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

SELECT name FROM products AS ordr
WHERE value > (
    SELECT MAX(value) FROM categories AS inv
    WHERE inv.level = ordr.level
);


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

SELECT value FROM orders AS empl
WHERE type IN (
    SELECT type FROM projects AS inv
    WHERE inv.level = empl.level
);


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

SELECT amount FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.type = lne.type
);


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

SELECT amount FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.type = lne.type
);


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

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


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

SELECT value FROM departments AS mgr
WHERE level IN (
    SELECT level FROM orders AS cust
    WHERE cust.level = mgr.level
);


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

SELECT code FROM invoices AS txn
WHERE level IN (
    SELECT level FROM orders AS sale
    WHERE sale.type = txn.type
);


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

SELECT code FROM products AS ordr
WHERE level IN (
    SELECT level FROM customers AS schd
    WHERE schd.id = ordr.id
);


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

SELECT name FROM departments AS prod
WHERE id IN (
    SELECT id FROM invoices AS ord
    WHERE ord.code = prod.code
);


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

SELECT code FROM orders AS ordr
WHERE id IN (
    SELECT id FROM projects AS sale
    WHERE sale.type = ordr.type
);


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

SELECT amount FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.status = txn.status
);


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

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


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

SELECT amount FROM customers AS txn
WHERE type IN (
    SELECT type FROM branches AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT amount FROM shipments AS catg
WHERE type IN (
    SELECT type FROM departments AS acct
    WHERE acct.status = catg.status
);


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

SELECT value FROM suppliers AS sale
WHERE id IN (
    SELECT id FROM tasks AS txn
    WHERE txn.id = sale.id
);


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

SELECT name FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.code = ordr.code
);


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

SELECT code FROM employees AS cust
WHERE code IN (
    SELECT code FROM warehouses AS catg
    WHERE catg.level = cust.level
);


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

SELECT value FROM transactions AS emp
WHERE id IN (
    SELECT id FROM invoices AS txn
    WHERE txn.code = emp.code
);


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

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


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

SELECT code FROM departments AS inv
WHERE amount > (
    SELECT MIN(value) FROM customers AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT name FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.level = catg.level
);


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

SELECT amount FROM orders AS prod
WHERE value > (
    SELECT AVG(amount) FROM shipments AS budg
    WHERE budg.id = prod.id
);


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

SELECT salary FROM shipments AS txn
WHERE salary > (
    SELECT AVG(value) FROM branches AS srvc
    WHERE srvc.status = txn.status
);


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

SELECT name FROM categories AS ord
WHERE type IN (
    SELECT type FROM employees AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT salary FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.level = shp.level
);


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

SELECT value FROM products AS rgn
WHERE id IN (
    SELECT id FROM invoices AS budg
    WHERE budg.id = rgn.id
);


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

SELECT salary FROM accounts AS prod
WHERE amount > (
    SELECT MIN(amount) FROM orders AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT name FROM tasks AS sale
WHERE salary > (
    SELECT MAX(value) FROM regions AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT amount FROM regions AS ord
WHERE salary > (
    SELECT MAX(salary) FROM employees AS whs
    WHERE whs.level = ord.level
);


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

SELECT name FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.code = prod.code
);


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

SELECT value FROM categories AS lne
WHERE value > (
    SELECT MAX(salary) FROM orders AS rgn
    WHERE rgn.status = lne.status
);


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

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


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

SELECT code FROM departments AS emp
WHERE salary > (
    SELECT MIN(value) FROM branches AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT salary FROM departments AS schd
WHERE status IN (
    SELECT status FROM employees AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT name FROM orders AS shp
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.code = shp.code
);


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

SELECT code FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS emp
    WHERE emp.code = cust.code
);


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

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


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

SELECT amount FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.level = ordr.level
);


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

SELECT name FROM branches AS schd
WHERE id IN (
    SELECT id FROM warehouses AS budg
    WHERE budg.id = schd.id
);


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

SELECT name FROM employees AS ord
WHERE code IN (
    SELECT code FROM branches AS acct
    WHERE acct.level = ord.level
);


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

SELECT amount FROM customers AS cust
WHERE code IN (
    SELECT code FROM tasks AS budg
    WHERE budg.status = cust.status
);


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

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


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

SELECT code FROM regions AS acct
WHERE type IN (
    SELECT type FROM branches AS txn
    WHERE txn.type = acct.type
);


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

SELECT code FROM categories AS sale
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.level = sale.level
);


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

SELECT code FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.code = srvc.code
);


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

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


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

SELECT amount FROM employees AS prod
WHERE id IN (
    SELECT id FROM shipments AS emp
    WHERE emp.level = prod.level
);


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

SELECT id FROM transactions AS catg
WHERE id IN (
    SELECT id FROM categories AS lne
    WHERE lne.type = catg.type
);


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

SELECT id FROM shipments AS ord
WHERE level IN (
    SELECT level FROM tasks AS dept
    WHERE dept.level = ord.level
);


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

SELECT value FROM projects AS schd
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS srvc
    WHERE srvc.level = schd.level
);


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

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


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

SELECT amount FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.type = cust.type
);


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

SELECT name FROM invoices AS acct
WHERE status IN (
    SELECT status FROM departments AS prod
    WHERE prod.level = acct.level
);


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

SELECT name FROM warehouses AS lne
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS emp
    WHERE emp.type = lne.type
);


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

SELECT id FROM suppliers AS catg
WHERE amount > (
    SELECT MIN(salary) FROM branches AS txn
    WHERE txn.type = catg.type
);


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

SELECT salary FROM products AS schd
WHERE type IN (
    SELECT type FROM employees AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT salary FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT value FROM projects AS sale
WHERE code IN (
    SELECT code FROM tasks AS budg
    WHERE budg.code = sale.code
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.status = dept.status
);


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

SELECT code FROM orders AS rgn
WHERE salary > (
    SELECT MAX(value) FROM transactions AS prod
    WHERE prod.code = rgn.code
);


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

SELECT name FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.id = empl.id
);


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

SELECT code FROM invoices AS catg
WHERE type IN (
    SELECT type FROM categories AS budg
    WHERE budg.status = catg.status
);


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

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


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

SELECT amount FROM warehouses AS empl
WHERE amount > (
    SELECT MAX(value) FROM shipments AS ord
    WHERE ord.level = empl.level
);


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

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


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

SELECT salary FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.id = schd.id
);


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

SELECT amount FROM tasks AS cust
WHERE level IN (
    SELECT level FROM products AS emp
    WHERE emp.level = cust.level
);


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

SELECT id FROM departments AS dept
WHERE level IN (
    SELECT level FROM employees AS ordr
    WHERE ordr.level = dept.level
);


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

SELECT salary FROM accounts AS sale
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS dept
    WHERE dept.code = sale.code
);


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

SELECT code FROM invoices AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS dept
    WHERE dept.status = txn.status
);


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

SELECT id FROM shipments AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM branches AS prod
    WHERE prod.code = rgn.code
);


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

SELECT amount FROM invoices AS acct
WHERE salary > (
    SELECT SUM(amount) FROM employees AS sale
    WHERE sale.type = acct.type
);


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

SELECT value FROM suppliers AS prod
WHERE amount > (
    SELECT SUM(salary) FROM regions AS acct
    WHERE acct.type = prod.type
);


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

SELECT code FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.level = shp.level
);


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

SELECT amount FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.id = srvc.id
);


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

SELECT name FROM tasks AS inv
WHERE code IN (
    SELECT code FROM orders AS emp
    WHERE emp.level = inv.level
);


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

SELECT name FROM branches AS whs
WHERE type IN (
    SELECT type FROM suppliers AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT id FROM products AS cust
WHERE value > (
    SELECT COUNT(amount) FROM orders AS ord
    WHERE ord.type = cust.type
);


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

SELECT amount FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.code = emp.code
);


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

SELECT code FROM shipments AS empl
WHERE code IN (
    SELECT code FROM employees AS prod
    WHERE prod.code = empl.code
);


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

SELECT id FROM invoices AS emp
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS sale
    WHERE sale.id = emp.id
);


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

SELECT salary FROM projects AS inv
WHERE code IN (
    SELECT code FROM transactions AS ord
    WHERE ord.status = inv.status
);


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

SELECT code FROM branches AS inv
WHERE code IN (
    SELECT code FROM tasks AS cust
    WHERE cust.type = inv.type
);


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

SELECT value FROM suppliers AS dept
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.type = dept.type
);


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

SELECT code FROM employees AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM projects AS srvc
    WHERE srvc.level = ordr.level
);


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

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


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

SELECT id FROM accounts AS ord
WHERE level IN (
    SELECT level FROM products AS schd
    WHERE schd.id = ord.id
);


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

SELECT name FROM shipments AS prod
WHERE status IN (
    SELECT status FROM orders AS dept
    WHERE dept.type = prod.type
);


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

SELECT id FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.type = ord.type
);


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

SELECT name FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.status = empl.status
);


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

SELECT name FROM suppliers AS catg
WHERE level IN (
    SELECT level FROM categories AS sale
    WHERE sale.level = catg.level
);


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

SELECT salary FROM shipments AS lne
WHERE value > (
    SELECT MAX(salary) FROM regions AS prod
    WHERE prod.type = lne.type
);


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

SELECT salary FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = srvc.status
);


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

SELECT id FROM tasks AS whs
WHERE salary > (
    SELECT AVG(amount) FROM categories AS shp
    WHERE shp.level = whs.level
);


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

SELECT value FROM branches AS schd
WHERE status IN (
    SELECT status FROM projects AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT code FROM employees AS empl
WHERE code IN (
    SELECT code FROM products AS inv
    WHERE inv.code = empl.code
);


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

SELECT code FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.code = prod.code
);


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

SELECT value FROM suppliers AS rgn
WHERE value > (
    SELECT AVG(salary) FROM warehouses AS shp
    WHERE shp.id = rgn.id
);


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

SELECT id FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.id = lne.id
);


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

SELECT code FROM products AS shp
WHERE amount > (
    SELECT SUM(amount) FROM regions AS emp
    WHERE emp.level = shp.level
);


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

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


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

SELECT name FROM regions AS whs
WHERE code IN (
    SELECT code FROM customers AS rgn
    WHERE rgn.code = whs.code
);


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

SELECT salary FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.id = acct.id
);


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

SELECT amount FROM transactions AS prod
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.code = prod.code
);


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

SELECT id FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.code = lne.code
);


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

SELECT amount FROM warehouses AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM employees AS emp
    WHERE emp.level = rgn.level
);


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

SELECT code FROM branches AS rgn
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS lne
    WHERE lne.type = rgn.type
);


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

SELECT code FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.id = rgn.id
);


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

SELECT value FROM employees AS dept
WHERE amount > (
    SELECT SUM(amount) FROM departments AS schd
    WHERE schd.level = dept.level
);


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

SELECT salary FROM regions AS lne
WHERE salary > (
    SELECT COUNT(value) FROM transactions AS emp
    WHERE emp.id = lne.id
);


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

SELECT id FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.status = schd.status
);


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

SELECT value FROM projects AS rgn
WHERE level IN (
    SELECT level FROM products AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT amount FROM shipments AS whs
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.status = whs.status
);


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

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


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

SELECT amount FROM transactions AS schd
WHERE value > (
    SELECT MIN(salary) FROM warehouses AS lne
    WHERE lne.type = schd.type
);


Prompt:
Schema:
  warehouses (alias: budg)(amount, name, status, id)
  employees(amount, date, id, status)
Task: Retrieve id from warehouses with amount above the AVG(amount) of employees rows sharing the same type.
SQL:

SELECT id FROM warehouses AS budg
WHERE amount > (
    SELECT AVG(amount) FROM employees AS ord
    WHERE ord.type = budg.type
);


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

SELECT code FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.level = inv.level
);


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

SELECT code FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.id = whs.id
);


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

SELECT code FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = txn.level
);


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

SELECT salary FROM tasks AS ord
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS inv
    WHERE inv.id = ord.id
);


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

SELECT salary FROM shipments AS rgn
WHERE status IN (
    SELECT status FROM customers AS acct
    WHERE acct.level = rgn.level
);


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

SELECT name FROM suppliers AS whs
WHERE code IN (
    SELECT code FROM regions AS budg
    WHERE budg.status = whs.status
);


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

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


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

SELECT amount FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.status = inv.status
);


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

SELECT id FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.type = txn.type
);


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

SELECT code FROM regions AS empl
WHERE salary > (
    SELECT MIN(salary) FROM projects AS mgr
    WHERE mgr.code = empl.code
);


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

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


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

SELECT code FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.status = sale.status
);


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

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


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

SELECT name FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.level = ord.level
);


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

SELECT amount FROM products AS budg
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS inv
    WHERE inv.type = budg.type
);


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

SELECT id FROM invoices AS ordr
WHERE value > (
    SELECT AVG(amount) FROM tasks AS lne
    WHERE lne.type = ordr.type
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT salary FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.id = shp.id
);


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

SELECT value FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.level = inv.level
);


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

SELECT value FROM suppliers AS srvc
WHERE value > (
    SELECT COUNT(value) FROM tasks AS schd
    WHERE schd.status = srvc.status
);


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

SELECT value FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.code = shp.code
);


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

SELECT salary FROM shipments AS sale
WHERE code IN (
    SELECT code FROM customers AS shp
    WHERE shp.status = sale.status
);


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

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


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

SELECT name FROM tasks AS cust
WHERE amount > (
    SELECT MAX(salary) FROM categories AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT value FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.code = inv.code
);


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

SELECT name FROM invoices AS inv
WHERE status IN (
    SELECT status FROM employees AS budg
    WHERE budg.status = inv.status
);


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

SELECT name FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.id = ord.id
);


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

SELECT value FROM customers AS inv
WHERE amount > (
    SELECT SUM(value) FROM projects AS dept
    WHERE dept.status = inv.status
);


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

SELECT amount FROM customers AS empl
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.code = empl.code
);


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

SELECT name FROM categories AS catg
WHERE status IN (
    SELECT status FROM regions AS budg
    WHERE budg.code = catg.code
);


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

SELECT code FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.level = prod.level
);


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

SELECT code FROM tasks AS shp
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS txn
    WHERE txn.status = shp.status
);


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

SELECT value FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.code = prod.code
);


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

SELECT name FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.code = prod.code
);


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

SELECT amount FROM transactions AS rgn
WHERE amount > (
    SELECT MIN(salary) FROM regions AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT code FROM invoices AS prod
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.code = prod.code
);


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

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


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

SELECT name FROM orders AS budg
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS whs
    WHERE whs.code = budg.code
);


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

SELECT id FROM tasks AS dept
WHERE salary > (
    SELECT MAX(salary) FROM branches AS schd
    WHERE schd.code = dept.code
);


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

SELECT code FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT id FROM regions AS srvc
WHERE salary > (
    SELECT AVG(value) FROM projects AS whs
    WHERE whs.type = srvc.type
);


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

SELECT salary FROM tasks AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS acct
    WHERE acct.id = srvc.id
);


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

SELECT name FROM products AS srvc
WHERE value > (
    SELECT AVG(salary) FROM employees AS schd
    WHERE schd.type = srvc.type
);


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

SELECT amount FROM suppliers AS whs
WHERE id IN (
    SELECT id FROM categories AS dept
    WHERE dept.level = whs.level
);


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

SELECT id FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.type = ordr.type
);


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

SELECT code FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.level = lne.level
);


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

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


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

SELECT amount FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT amount FROM shipments AS lne
WHERE salary > (
    SELECT SUM(salary) FROM orders AS inv
    WHERE inv.id = lne.id
);


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

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


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

SELECT code FROM branches AS empl
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.status = empl.status
);


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

SELECT code FROM warehouses AS srvc
WHERE code IN (
    SELECT code FROM projects AS sale
    WHERE sale.status = srvc.status
);


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

SELECT name FROM transactions AS txn
WHERE amount > (
    SELECT SUM(value) FROM employees AS sale
    WHERE sale.code = txn.code
);


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

SELECT amount FROM shipments AS whs
WHERE value > (
    SELECT AVG(value) FROM orders AS empl
    WHERE empl.type = whs.type
);


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

SELECT id FROM departments AS inv
WHERE salary > (
    SELECT SUM(amount) FROM warehouses AS emp
    WHERE emp.status = inv.status
);


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

SELECT id FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM customers AS prod
    WHERE prod.id = rgn.id
);


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

SELECT id FROM employees AS catg
WHERE id IN (
    SELECT id FROM customers AS ordr
    WHERE ordr.status = catg.status
);


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

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


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

SELECT code FROM shipments AS whs
WHERE status IN (
    SELECT status FROM departments AS schd
    WHERE schd.code = whs.code
);


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

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


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

SELECT code FROM branches AS rgn
WHERE type IN (
    SELECT type FROM shipments AS emp
    WHERE emp.status = rgn.status
);


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

SELECT value FROM categories AS mgr
WHERE salary > (
    SELECT MIN(value) FROM transactions AS whs
    WHERE whs.level = mgr.level
);


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

SELECT id FROM products AS inv
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT name FROM warehouses AS budg
WHERE salary > (
    SELECT AVG(value) FROM projects AS emp
    WHERE emp.type = budg.type
);


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

SELECT amount FROM warehouses AS inv
WHERE value > (
    SELECT AVG(salary) FROM orders AS prod
    WHERE prod.id = inv.id
);


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

SELECT name FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.status = emp.status
);


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

SELECT amount FROM branches AS empl
WHERE level IN (
    SELECT level FROM departments AS mgr
    WHERE mgr.level = empl.level
);


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

SELECT code FROM departments AS prod
WHERE type IN (
    SELECT type FROM orders AS sale
    WHERE sale.status = prod.status
);


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

SELECT code FROM orders AS rgn
WHERE salary > (
    SELECT SUM(value) FROM projects AS dept
    WHERE dept.type = rgn.type
);


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

SELECT salary FROM invoices AS sale
WHERE value > (
    SELECT MIN(amount) FROM projects AS budg
    WHERE budg.status = sale.status
);


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

SELECT id FROM shipments AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.status = prod.status
);


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

SELECT salary FROM branches AS acct
WHERE id IN (
    SELECT id FROM transactions AS cust
    WHERE cust.level = acct.level
);


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

SELECT amount FROM warehouses AS inv
WHERE value > (
    SELECT AVG(value) FROM customers AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT code FROM customers AS rgn
WHERE id IN (
    SELECT id FROM accounts AS emp
    WHERE emp.status = rgn.status
);


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

SELECT id FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.status = srvc.status
);


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

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


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

SELECT id FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.type = schd.type
);


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

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


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

SELECT id FROM customers AS ordr
WHERE value > (
    SELECT SUM(value) FROM invoices AS schd
    WHERE schd.code = ordr.code
);


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

SELECT value FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.id = prod.id
);


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

SELECT code FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.id = mgr.id
);


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

SELECT amount FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.status = ord.status
);


Prompt:
Schema:
  suppliers (alias: budg)(code, salary, type, date)
  customers(type, salary, date, name)
Task: Find code from suppliers where code appears in customers entries with matching code.
SQL:

SELECT code FROM suppliers AS budg
WHERE code IN (
    SELECT code FROM customers AS schd
    WHERE schd.code = budg.code
);


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

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


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

SELECT id FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT value FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.level = budg.level
);


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

SELECT amount FROM orders AS cust
WHERE value > (
    SELECT AVG(value) FROM departments AS catg
    WHERE catg.level = cust.level
);


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

SELECT code FROM customers AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM invoices AS ordr
    WHERE ordr.code = sale.code
);


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

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


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

SELECT code FROM employees AS catg
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS dept
    WHERE dept.code = catg.code
);


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

SELECT salary FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.code = txn.code
);


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

SELECT amount FROM shipments AS shp
WHERE code IN (
    SELECT code FROM projects AS whs
    WHERE whs.level = shp.level
);


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

SELECT id FROM departments AS sale
WHERE value > (
    SELECT MAX(value) FROM suppliers AS txn
    WHERE txn.type = sale.type
);


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

SELECT salary FROM projects AS shp
WHERE amount > (
    SELECT SUM(value) FROM suppliers AS dept
    WHERE dept.type = shp.type
);


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

SELECT salary FROM accounts AS schd
WHERE status IN (
    SELECT status FROM departments AS sale
    WHERE sale.level = schd.level
);


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

SELECT code FROM categories AS prod
WHERE amount > (
    SELECT SUM(salary) FROM warehouses AS sale
    WHERE sale.code = prod.code
);


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

SELECT id FROM warehouses AS acct
WHERE amount > (
    SELECT MIN(amount) FROM customers AS txn
    WHERE txn.status = acct.status
);


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

SELECT code FROM categories AS ord
WHERE code IN (
    SELECT code FROM tasks AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT name FROM invoices AS srvc
WHERE id IN (
    SELECT id FROM products AS schd
    WHERE schd.id = srvc.id
);


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

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


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

SELECT name FROM categories AS budg
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS whs
    WHERE whs.level = budg.level
);


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

SELECT id FROM employees AS catg
WHERE status IN (
    SELECT status FROM orders AS whs
    WHERE whs.status = catg.status
);


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

SELECT id FROM categories AS shp
WHERE id IN (
    SELECT id FROM orders AS acct
    WHERE acct.level = shp.level
);


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

SELECT name FROM tasks AS budg
WHERE salary > (
    SELECT SUM(value) FROM invoices AS schd
    WHERE schd.type = budg.type
);


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

SELECT value FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.status = mgr.status
);


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

SELECT value FROM shipments AS budg
WHERE value > (
    SELECT SUM(value) FROM invoices AS cust
    WHERE cust.id = budg.id
);


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

SELECT code FROM orders AS ordr
WHERE amount > (
    SELECT MIN(value) FROM warehouses AS whs
    WHERE whs.status = ordr.status
);


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

SELECT amount FROM orders AS srvc
WHERE value > (
    SELECT SUM(value) FROM invoices AS txn
    WHERE txn.type = srvc.type
);


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

SELECT code FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM branches AS ord
    WHERE ord.status = rgn.status
);


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

SELECT name FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.type = sale.type
);