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

SELECT name FROM projects AS lne
WHERE type IN (
    SELECT type FROM regions AS whs
    WHERE whs.id = lne.id
);


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

SELECT value FROM tasks AS srvc
WHERE value > (
    SELECT AVG(value) FROM shipments AS dept
    WHERE dept.status = srvc.status
);


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

SELECT salary FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.level = shp.level
);


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

SELECT id FROM warehouses AS cust
WHERE level IN (
    SELECT level FROM shipments AS txn
    WHERE txn.id = cust.id
);


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

SELECT code FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.level = ordr.level
);


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

SELECT value FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT amount FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.level = srvc.level
);


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

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


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

SELECT value FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT value FROM invoices AS whs
WHERE salary > (
    SELECT SUM(salary) FROM branches AS sale
    WHERE sale.status = whs.status
);


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

SELECT salary FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.code = ord.code
);


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

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


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

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


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

SELECT salary FROM tasks AS lne
WHERE amount > (
    SELECT COUNT(value) FROM warehouses AS ord
    WHERE ord.type = lne.type
);


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

SELECT code FROM projects AS sale
WHERE level IN (
    SELECT level FROM warehouses AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT name FROM transactions AS inv
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS empl
    WHERE empl.status = inv.status
);


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

SELECT code FROM orders AS cust
WHERE salary > (
    SELECT MIN(value) FROM departments AS empl
    WHERE empl.level = cust.level
);


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

SELECT id FROM categories AS budg
WHERE value > (
    SELECT AVG(salary) FROM suppliers AS ord
    WHERE ord.code = budg.code
);


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

SELECT id FROM categories AS dept
WHERE value > (
    SELECT AVG(amount) FROM branches AS txn
    WHERE txn.level = dept.level
);


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

SELECT salary FROM shipments AS dept
WHERE amount > (
    SELECT COUNT(value) FROM departments AS ord
    WHERE ord.level = dept.level
);


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

SELECT code FROM orders AS prod
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS acct
    WHERE acct.id = prod.id
);


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

SELECT code FROM departments AS mgr
WHERE amount > (
    SELECT MIN(value) FROM orders AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT value FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.type = empl.type
);


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

SELECT name FROM tasks AS schd
WHERE type IN (
    SELECT type FROM suppliers AS catg
    WHERE catg.status = schd.status
);


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

SELECT amount FROM warehouses AS mgr
WHERE amount > (
    SELECT AVG(salary) FROM regions AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT amount FROM invoices AS dept
WHERE level IN (
    SELECT level FROM products AS inv
    WHERE inv.id = dept.id
);


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

SELECT amount FROM accounts AS catg
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT amount FROM shipments AS budg
WHERE level IN (
    SELECT level FROM employees AS acct
    WHERE acct.type = budg.type
);


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

SELECT code FROM products AS lne
WHERE amount > (
    SELECT MIN(salary) FROM categories AS ord
    WHERE ord.code = lne.code
);


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

SELECT salary FROM customers AS cust
WHERE salary > (
    SELECT SUM(amount) FROM employees AS rgn
    WHERE rgn.status = cust.status
);


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

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


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

SELECT amount FROM shipments AS shp
WHERE status IN (
    SELECT status FROM projects AS cust
    WHERE cust.status = shp.status
);


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

SELECT code FROM projects AS emp
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS catg
    WHERE catg.status = emp.status
);


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

SELECT id FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.status = ordr.status
);


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

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


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

SELECT value FROM transactions AS shp
WHERE amount > (
    SELECT MAX(value) FROM accounts AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT amount FROM categories AS cust
WHERE code IN (
    SELECT code FROM suppliers AS shp
    WHERE shp.type = cust.type
);


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

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


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

SELECT code FROM departments AS catg
WHERE value > (
    SELECT MIN(amount) FROM projects AS acct
    WHERE acct.level = catg.level
);


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

SELECT name FROM orders AS txn
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS ordr
    WHERE ordr.code = txn.code
);


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

SELECT salary FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.status = shp.status
);


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

SELECT id FROM suppliers AS budg
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.level = budg.level
);


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

SELECT value FROM orders AS cust
WHERE value > (
    SELECT MAX(salary) FROM shipments AS lne
    WHERE lne.level = cust.level
);


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

SELECT value FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.id = srvc.id
);


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

SELECT value FROM branches AS rgn
WHERE amount > (
    SELECT SUM(value) FROM departments AS sale
    WHERE sale.id = rgn.id
);


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

SELECT name FROM invoices AS catg
WHERE status IN (
    SELECT status FROM transactions AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT salary FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.status = ord.status
);


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

SELECT name FROM departments AS ordr
WHERE type IN (
    SELECT type FROM orders AS shp
    WHERE shp.id = ordr.id
);


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

SELECT name FROM departments AS dept
WHERE value > (
    SELECT COUNT(value) FROM shipments AS prod
    WHERE prod.code = dept.code
);


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

SELECT code FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.type = cust.type
);


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

SELECT code FROM customers AS emp
WHERE type IN (
    SELECT type FROM invoices AS ord
    WHERE ord.code = emp.code
);


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

SELECT salary FROM transactions AS ordr
WHERE type IN (
    SELECT type FROM shipments AS catg
    WHERE catg.level = ordr.level
);


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

SELECT value FROM products AS budg
WHERE value > (
    SELECT SUM(amount) FROM categories AS mgr
    WHERE mgr.id = budg.id
);


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

SELECT id FROM invoices AS acct
WHERE status IN (
    SELECT status FROM departments AS inv
    WHERE inv.id = acct.id
);


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

SELECT salary FROM orders AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.status = catg.status
);


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

SELECT id FROM shipments AS budg
WHERE level IN (
    SELECT level FROM transactions AS lne
    WHERE lne.type = budg.type
);


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

SELECT code FROM departments AS ordr
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.level = ordr.level
);


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

SELECT salary FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.code = budg.code
);


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

SELECT value FROM transactions AS lne
WHERE type IN (
    SELECT type FROM invoices AS shp
    WHERE shp.id = lne.id
);


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

SELECT id FROM shipments AS txn
WHERE value > (
    SELECT MAX(amount) FROM tasks AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT salary FROM employees AS emp
WHERE status IN (
    SELECT status FROM regions AS schd
    WHERE schd.type = emp.type
);


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

SELECT value FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.id = acct.id
);


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

SELECT name FROM tasks AS whs
WHERE value > (
    SELECT COUNT(salary) FROM accounts AS rgn
    WHERE rgn.status = whs.status
);


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

SELECT code FROM branches AS mgr
WHERE salary > (
    SELECT MIN(salary) FROM warehouses AS lne
    WHERE lne.code = mgr.code
);


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

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


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

SELECT value FROM suppliers AS prod
WHERE salary > (
    SELECT AVG(value) FROM branches AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT salary FROM accounts AS shp
WHERE type IN (
    SELECT type FROM suppliers AS prod
    WHERE prod.level = shp.level
);


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

SELECT code FROM warehouses AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT salary FROM warehouses AS empl
WHERE value > (
    SELECT MAX(value) FROM regions AS acct
    WHERE acct.type = empl.type
);


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

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


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

SELECT value FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.id = lne.id
);


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

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


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

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


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

SELECT id FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.code = srvc.code
);


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

SELECT amount FROM customers AS txn
WHERE level IN (
    SELECT level FROM invoices AS emp
    WHERE emp.type = txn.type
);


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

SELECT code FROM products AS rgn
WHERE amount > (
    SELECT MIN(value) FROM shipments AS schd
    WHERE schd.id = rgn.id
);


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

SELECT id FROM shipments AS acct
WHERE id IN (
    SELECT id FROM suppliers AS emp
    WHERE emp.level = acct.level
);


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

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


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

SELECT name FROM branches AS lne
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS prod
    WHERE prod.id = lne.id
);


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

SELECT salary FROM invoices AS srvc
WHERE type IN (
    SELECT type FROM orders AS acct
    WHERE acct.level = srvc.level
);


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

SELECT code FROM orders AS lne
WHERE amount > (
    SELECT MIN(salary) FROM branches AS sale
    WHERE sale.id = lne.id
);


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

SELECT id FROM products AS prod
WHERE code IN (
    SELECT code FROM orders AS ordr
    WHERE ordr.id = prod.id
);


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

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


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

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


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

SELECT salary FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.type = ordr.type
);


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

SELECT code FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.level = emp.level
);


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

SELECT amount FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.type = rgn.type
);


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

SELECT id FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.level = acct.level
);


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

SELECT name FROM employees AS txn
WHERE type IN (
    SELECT type FROM warehouses AS shp
    WHERE shp.level = txn.level
);


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

SELECT amount FROM departments AS inv
WHERE level IN (
    SELECT level FROM tasks AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT code FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = lne.id
);


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

SELECT value FROM orders AS rgn
WHERE value > (
    SELECT SUM(salary) FROM branches AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT name FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.level = acct.level
);


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

SELECT salary FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.level = txn.level
);


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

SELECT id FROM regions AS sale
WHERE code IN (
    SELECT code FROM departments AS whs
    WHERE whs.status = sale.status
);


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

SELECT value FROM branches AS whs
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT amount FROM projects AS catg
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.code = catg.code
);


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

SELECT salary FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.type = mgr.type
);


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

SELECT code FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = rgn.level
);


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

SELECT code FROM regions AS empl
WHERE code IN (
    SELECT code FROM accounts AS lne
    WHERE lne.level = empl.level
);


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

SELECT amount FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.level = cust.level
);


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

SELECT amount FROM departments AS empl
WHERE amount > (
    SELECT COUNT(value) FROM warehouses AS acct
    WHERE acct.type = empl.type
);


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

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


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

SELECT value FROM transactions AS emp
WHERE status IN (
    SELECT status FROM products AS schd
    WHERE schd.level = emp.level
);


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

SELECT salary FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = empl.status
);


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

SELECT name FROM transactions AS lne
WHERE value > (
    SELECT AVG(value) FROM products AS acct
    WHERE acct.id = lne.id
);


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

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


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

SELECT value FROM invoices AS catg
WHERE amount > (
    SELECT MAX(value) FROM accounts AS shp
    WHERE shp.code = catg.code
);


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

SELECT amount FROM departments AS catg
WHERE status IN (
    SELECT status FROM branches AS empl
    WHERE empl.type = catg.type
);


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

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


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

SELECT salary FROM branches AS emp
WHERE amount > (
    SELECT SUM(amount) FROM categories AS schd
    WHERE schd.id = emp.id
);


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

SELECT amount FROM orders AS ordr
WHERE status IN (
    SELECT status FROM categories AS prod
    WHERE prod.id = ordr.id
);


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

SELECT salary FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.level = budg.level
);


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

SELECT salary FROM transactions AS budg
WHERE level IN (
    SELECT level FROM accounts AS dept
    WHERE dept.status = budg.status
);


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

SELECT amount FROM customers AS inv
WHERE id IN (
    SELECT id FROM shipments AS shp
    WHERE shp.type = inv.type
);


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

SELECT salary FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.level = srvc.level
);


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

SELECT amount FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.id = mgr.id
);


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

SELECT amount FROM regions AS mgr
WHERE code IN (
    SELECT code FROM shipments AS lne
    WHERE lne.type = mgr.type
);


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

SELECT amount FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.id = budg.id
);


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

SELECT code FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.code = lne.code
);


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

SELECT amount FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.code = rgn.code
);


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

SELECT value FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.code = whs.code
);


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

SELECT code FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.status = shp.status
);


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

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


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.code = ord.code
);


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

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


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

SELECT id FROM warehouses AS catg
WHERE value > (
    SELECT MIN(salary) FROM suppliers AS schd
    WHERE schd.status = catg.status
);


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

SELECT salary FROM suppliers AS empl
WHERE type IN (
    SELECT type FROM projects AS budg
    WHERE budg.type = empl.type
);


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

SELECT amount FROM customers AS lne
WHERE amount > (
    SELECT MIN(value) FROM shipments AS ord
    WHERE ord.status = lne.status
);


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

SELECT code FROM projects AS ord
WHERE id IN (
    SELECT id FROM employees AS budg
    WHERE budg.id = ord.id
);


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

SELECT amount FROM tasks AS whs
WHERE id IN (
    SELECT id FROM products AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT name FROM products AS dept
WHERE status IN (
    SELECT status FROM employees AS rgn
    WHERE rgn.level = dept.level
);


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

SELECT code FROM projects AS ord
WHERE salary > (
    SELECT MIN(value) FROM warehouses AS schd
    WHERE schd.status = ord.status
);


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

SELECT salary FROM projects AS rgn
WHERE level IN (
    SELECT level FROM products AS budg
    WHERE budg.status = rgn.status
);


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

SELECT salary FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = budg.type
);


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

SELECT value FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.status = mgr.status
);


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

SELECT id FROM products AS ord
WHERE amount > (
    SELECT MIN(amount) FROM employees AS shp
    WHERE shp.code = ord.code
);


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

SELECT code FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.level = acct.level
);


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

SELECT amount FROM suppliers AS sale
WHERE level IN (
    SELECT level FROM branches AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT name FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.type = inv.type
);


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

SELECT code FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.level = budg.level
);


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

SELECT name FROM departments AS lne
WHERE value > (
    SELECT SUM(value) FROM customers AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT name FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.status = schd.status
);


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

SELECT value FROM accounts AS ord
WHERE id IN (
    SELECT id FROM projects AS prod
    WHERE prod.id = ord.id
);


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

SELECT salary FROM accounts AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.level = inv.level
);


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

SELECT value FROM orders AS ordr
WHERE id IN (
    SELECT id FROM customers AS schd
    WHERE schd.code = ordr.code
);


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

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


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

SELECT name FROM shipments AS empl
WHERE value > (
    SELECT MIN(salary) FROM accounts AS schd
    WHERE schd.type = empl.type
);


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

SELECT amount FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.id = acct.id
);


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

SELECT salary FROM regions AS lne
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.id = lne.id
);


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

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


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

SELECT value FROM products AS prod
WHERE code IN (
    SELECT code FROM accounts AS schd
    WHERE schd.status = prod.status
);


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

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


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

SELECT name FROM orders AS ord
WHERE code IN (
    SELECT code FROM invoices AS catg
    WHERE catg.type = ord.type
);


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

SELECT salary FROM accounts AS shp
WHERE salary > (
    SELECT MAX(value) FROM suppliers AS dept
    WHERE dept.code = shp.code
);


Prompt:
Schema:
  invoices (alias: shp)(status, amount, value, salary)
  branches(salary, id, status, date)
Task: Retrieve value from invoices with amount above the COUNT(amount) of branches rows sharing the same id.
SQL:

SELECT value FROM invoices AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS cust
    WHERE cust.id = shp.id
);


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

SELECT code FROM tasks AS rgn
WHERE status IN (
    SELECT status FROM branches AS srvc
    WHERE srvc.code = rgn.code
);


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

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


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

SELECT id FROM invoices AS whs
WHERE level IN (
    SELECT level FROM customers AS mgr
    WHERE mgr.code = whs.code
);


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

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


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

SELECT amount FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.type = srvc.type
);


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

SELECT amount FROM products AS budg
WHERE type IN (
    SELECT type FROM suppliers AS empl
    WHERE empl.code = budg.code
);


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

SELECT name FROM orders AS catg
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS emp
    WHERE emp.level = catg.level
);


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

SELECT value FROM branches AS txn
WHERE value > (
    SELECT AVG(value) FROM tasks AS cust
    WHERE cust.level = txn.level
);


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

SELECT name FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = empl.type
);


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

SELECT code FROM products AS dept
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT code FROM products AS empl
WHERE id IN (
    SELECT id FROM categories AS lne
    WHERE lne.level = empl.level
);


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

SELECT name FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.status = mgr.status
);


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

SELECT amount FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.id = ord.id
);


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

SELECT code FROM customers AS rgn
WHERE value > (
    SELECT MAX(amount) FROM tasks AS srvc
    WHERE srvc.type = rgn.type
);


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

SELECT value FROM categories AS cust
WHERE salary > (
    SELECT SUM(value) FROM customers AS catg
    WHERE catg.type = cust.type
);


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

SELECT value FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = txn.level
);


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

SELECT salary FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT name FROM orders AS cust
WHERE value > (
    SELECT AVG(salary) FROM customers AS lne
    WHERE lne.code = cust.code
);


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

SELECT salary FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.type = prod.type
);


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

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


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

SELECT salary FROM products AS cust
WHERE status IN (
    SELECT status FROM warehouses AS lne
    WHERE lne.id = cust.id
);


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

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


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

SELECT amount FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = cust.level
);


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

SELECT amount FROM orders AS inv
WHERE code IN (
    SELECT code FROM employees AS shp
    WHERE shp.id = inv.id
);


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

SELECT amount FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.level = sale.level
);


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

SELECT salary FROM shipments AS cust
WHERE value > (
    SELECT MIN(salary) FROM branches AS emp
    WHERE emp.level = cust.level
);


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

SELECT name FROM accounts AS cust
WHERE amount > (
    SELECT SUM(amount) FROM products AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT salary FROM tasks AS whs
WHERE value > (
    SELECT COUNT(salary) FROM projects AS ord
    WHERE ord.id = whs.id
);


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

SELECT value FROM departments AS cust
WHERE value > (
    SELECT MIN(value) FROM transactions AS empl
    WHERE empl.id = cust.id
);


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

SELECT salary FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.level = schd.level
);


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

SELECT salary FROM regions AS mgr
WHERE code IN (
    SELECT code FROM categories AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT name FROM accounts AS prod
WHERE value > (
    SELECT COUNT(value) FROM employees AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT id FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT value FROM regions AS ordr
WHERE status IN (
    SELECT status FROM employees AS prod
    WHERE prod.status = ordr.status
);


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

SELECT name FROM employees AS schd
WHERE type IN (
    SELECT type FROM suppliers AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT id FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.status = srvc.status
);


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

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


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

SELECT value FROM invoices AS inv
WHERE salary > (
    SELECT SUM(amount) FROM categories AS acct
    WHERE acct.status = inv.status
);


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.level = txn.level
);


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

SELECT code FROM employees AS emp
WHERE value > (
    SELECT SUM(amount) FROM categories AS sale
    WHERE sale.code = emp.code
);


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

SELECT name FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.type = mgr.type
);


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

SELECT value FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.status = rgn.status
);


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

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


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

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


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

SELECT name FROM warehouses AS dept
WHERE level IN (
    SELECT level FROM tasks AS cust
    WHERE cust.code = dept.code
);


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

SELECT salary FROM orders AS mgr
WHERE value > (
    SELECT SUM(salary) FROM shipments AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT id FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.type = budg.type
);


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

SELECT id FROM regions AS shp
WHERE salary > (
    SELECT AVG(salary) FROM transactions AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT amount FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.type = acct.type
);


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

SELECT code FROM regions AS schd
WHERE level IN (
    SELECT level FROM accounts AS empl
    WHERE empl.status = schd.status
);


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

SELECT amount FROM projects AS dept
WHERE status IN (
    SELECT status FROM products AS cust
    WHERE cust.status = dept.status
);


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

SELECT salary FROM categories AS whs
WHERE id IN (
    SELECT id FROM invoices AS ord
    WHERE ord.type = whs.type
);


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

SELECT amount FROM invoices AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS prod
    WHERE prod.status = empl.status
);


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

SELECT name FROM branches AS acct
WHERE amount > (
    SELECT COUNT(value) FROM departments AS schd
    WHERE schd.code = acct.code
);


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

SELECT id FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT name FROM transactions AS emp
WHERE amount > (
    SELECT MAX(value) FROM invoices AS rgn
    WHERE rgn.id = emp.id
);


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

SELECT value FROM tasks AS txn
WHERE level IN (
    SELECT level FROM categories AS shp
    WHERE shp.type = txn.type
);


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

SELECT value FROM employees AS sale
WHERE id IN (
    SELECT id FROM accounts AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT value FROM categories AS empl
WHERE id IN (
    SELECT id FROM invoices AS shp
    WHERE shp.code = empl.code
);


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

SELECT amount FROM departments AS budg
WHERE level IN (
    SELECT level FROM regions AS prod
    WHERE prod.level = budg.level
);


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

SELECT name FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT value FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.code = mgr.code
);


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

SELECT code FROM transactions AS lne
WHERE salary > (
    SELECT SUM(value) FROM branches AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT id FROM warehouses AS txn
WHERE amount > (
    SELECT SUM(salary) FROM categories AS catg
    WHERE catg.level = txn.level
);


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

SELECT name FROM branches AS sale
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS mgr
    WHERE mgr.id = sale.id
);


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

SELECT id FROM products AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.code = srvc.code
);


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

SELECT amount FROM suppliers AS rgn
WHERE status IN (
    SELECT status FROM departments AS catg
    WHERE catg.level = rgn.level
);


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

SELECT value FROM shipments AS acct
WHERE value > (
    SELECT COUNT(value) FROM accounts AS shp
    WHERE shp.status = acct.status
);


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

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


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

SELECT code FROM employees AS empl
WHERE value > (
    SELECT SUM(salary) FROM branches AS emp
    WHERE emp.id = empl.id
);


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

SELECT code FROM products AS catg
WHERE level IN (
    SELECT level FROM accounts AS txn
    WHERE txn.code = catg.code
);


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

SELECT value FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.status = acct.status
);


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

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


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

SELECT code FROM branches AS acct
WHERE value > (
    SELECT MAX(amount) FROM categories AS prod
    WHERE prod.status = acct.status
);


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

SELECT id FROM accounts AS budg
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS empl
    WHERE empl.type = budg.type
);


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

SELECT amount FROM suppliers AS ordr
WHERE value > (
    SELECT SUM(amount) FROM employees AS lne
    WHERE lne.id = ordr.id
);


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

SELECT name FROM suppliers AS dept
WHERE value > (
    SELECT MAX(salary) FROM transactions AS inv
    WHERE inv.status = dept.status
);


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

SELECT code FROM departments AS prod
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT code FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = mgr.status
);


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

SELECT value FROM products AS schd
WHERE status IN (
    SELECT status FROM transactions AS emp
    WHERE emp.type = schd.type
);


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

SELECT code FROM products AS emp
WHERE amount > (
    SELECT MAX(salary) FROM employees AS shp
    WHERE shp.id = emp.id
);


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

SELECT value FROM categories AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS budg
    WHERE budg.type = ord.type
);


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

SELECT salary FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.code = srvc.code
);


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

SELECT id FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.status = lne.status
);


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

SELECT amount FROM orders AS ordr
WHERE value > (
    SELECT SUM(value) FROM accounts AS txn
    WHERE txn.level = ordr.level
);


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

SELECT salary FROM products AS sale
WHERE amount > (
    SELECT COUNT(value) FROM branches AS shp
    WHERE shp.code = sale.code
);


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

SELECT value FROM orders AS inv
WHERE type IN (
    SELECT type FROM suppliers AS shp
    WHERE shp.status = inv.status
);


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

SELECT amount FROM orders AS inv
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS catg
    WHERE catg.code = inv.code
);


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

SELECT id FROM projects AS inv
WHERE level IN (
    SELECT level FROM tasks AS budg
    WHERE budg.level = inv.level
);


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

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


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

SELECT salary FROM suppliers AS catg
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS empl
    WHERE empl.level = catg.level
);


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

SELECT salary FROM shipments AS whs
WHERE id IN (
    SELECT id FROM categories AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT name FROM branches AS emp
WHERE level IN (
    SELECT level FROM suppliers AS ordr
    WHERE ordr.type = emp.type
);


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

SELECT id FROM employees AS ordr
WHERE level IN (
    SELECT level FROM tasks AS rgn
    WHERE rgn.level = ordr.level
);


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

SELECT amount FROM branches AS mgr
WHERE salary > (
    SELECT AVG(salary) FROM departments AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT code FROM products AS ordr
WHERE status IN (
    SELECT status FROM customers AS ord
    WHERE ord.code = ordr.code
);


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

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


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

SELECT code FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT amount FROM departments AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS inv
    WHERE inv.status = catg.status
);


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

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


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

SELECT amount FROM projects AS budg
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT name FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.status = catg.status
);


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

SELECT value FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.type = dept.type
);


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

SELECT id FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.id = schd.id
);


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

SELECT salary FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.status = catg.status
);


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

SELECT name FROM invoices AS lne
WHERE id IN (
    SELECT id FROM suppliers AS empl
    WHERE empl.code = lne.code
);


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

SELECT name FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.status = rgn.status
);


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

SELECT value FROM suppliers AS schd
WHERE id IN (
    SELECT id FROM departments AS budg
    WHERE budg.status = schd.status
);


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

SELECT amount FROM categories AS whs
WHERE code IN (
    SELECT code FROM products AS txn
    WHERE txn.id = whs.id
);


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

SELECT code FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS budg
    WHERE budg.type = ordr.type
);


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

SELECT name FROM shipments AS inv
WHERE salary > (
    SELECT SUM(value) FROM projects AS catg
    WHERE catg.status = inv.status
);


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

SELECT code FROM branches AS rgn
WHERE status IN (
    SELECT status FROM customers AS lne
    WHERE lne.level = rgn.level
);


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

SELECT value FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.type = ordr.type
);


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

SELECT amount FROM accounts AS emp
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS schd
    WHERE schd.type = emp.type
);


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

SELECT id FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT amount FROM shipments AS emp
WHERE type IN (
    SELECT type FROM regions AS whs
    WHERE whs.level = emp.level
);


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

SELECT code FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.code = whs.code
);


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

SELECT code FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT salary FROM categories AS inv
WHERE id IN (
    SELECT id FROM customers AS budg
    WHERE budg.id = inv.id
);


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

SELECT code FROM accounts AS schd
WHERE salary > (
    SELECT SUM(amount) FROM categories AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT salary FROM accounts AS lne
WHERE amount > (
    SELECT SUM(value) FROM products AS whs
    WHERE whs.code = lne.code
);


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

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


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

SELECT salary FROM branches AS rgn
WHERE value > (
    SELECT SUM(amount) FROM projects AS ordr
    WHERE ordr.level = rgn.level
);


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

SELECT amount FROM invoices AS ord
WHERE level IN (
    SELECT level FROM products AS sale
    WHERE sale.code = ord.code
);


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

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


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

SELECT salary FROM transactions AS catg
WHERE value > (
    SELECT MAX(salary) FROM employees AS lne
    WHERE lne.level = catg.level
);


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

SELECT amount FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.type = ordr.type
);


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

SELECT amount FROM customers AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM departments AS dept
    WHERE dept.code = rgn.code
);


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

SELECT value FROM shipments AS whs
WHERE value > (
    SELECT SUM(amount) FROM warehouses AS inv
    WHERE inv.id = whs.id
);


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

SELECT salary FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.level = empl.level
);


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

SELECT id FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS whs
    WHERE whs.status = acct.status
);


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

SELECT amount FROM regions AS lne
WHERE level IN (
    SELECT level FROM suppliers AS catg
    WHERE catg.level = lne.level
);


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

SELECT name FROM shipments AS dept
WHERE value > (
    SELECT MIN(value) FROM orders AS lne
    WHERE lne.type = dept.type
);


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

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


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

SELECT value FROM orders AS empl
WHERE code IN (
    SELECT code FROM branches AS schd
    WHERE schd.id = empl.id
);


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

SELECT id FROM transactions AS cust
WHERE level IN (
    SELECT level FROM regions AS dept
    WHERE dept.code = cust.code
);