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

SELECT value FROM regions AS schd
WHERE value > (
    SELECT MIN(value) FROM tasks AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT salary FROM invoices AS inv
WHERE status IN (
    SELECT status FROM shipments AS budg
    WHERE budg.status = inv.status
);


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

SELECT id FROM warehouses AS srvc
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS cust
    WHERE cust.id = srvc.id
);


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

SELECT id FROM regions AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM employees AS schd
    WHERE schd.status = ord.status
);


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

SELECT value FROM warehouses AS prod
WHERE status IN (
    SELECT status FROM projects AS inv
    WHERE inv.code = prod.code
);


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

SELECT name FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.level = srvc.level
);


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

SELECT name FROM accounts AS sale
WHERE level IN (
    SELECT level FROM invoices AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT name FROM transactions AS dept
WHERE salary > (
    SELECT COUNT(amount) FROM categories AS ord
    WHERE ord.type = dept.type
);


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

SELECT amount FROM projects AS schd
WHERE value > (
    SELECT SUM(amount) FROM branches AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT name FROM accounts AS cust
WHERE salary > (
    SELECT SUM(value) FROM invoices AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT code FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.status = ordr.status
);


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

SELECT name FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT name FROM tasks AS emp
WHERE salary > (
    SELECT SUM(value) FROM products AS txn
    WHERE txn.status = emp.status
);


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

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


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

SELECT amount FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM transactions AS inv
    WHERE inv.level = budg.level
);


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

SELECT name FROM tasks AS whs
WHERE status IN (
    SELECT status FROM orders AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT id FROM categories AS catg
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.level = catg.level
);


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

SELECT name FROM suppliers AS acct
WHERE status IN (
    SELECT status FROM products AS whs
    WHERE whs.code = acct.code
);


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

SELECT amount FROM categories AS ordr
WHERE salary > (
    SELECT SUM(value) FROM accounts AS prod
    WHERE prod.status = ordr.status
);


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

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


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

SELECT id FROM transactions AS whs
WHERE status IN (
    SELECT status FROM regions AS ord
    WHERE ord.type = whs.type
);


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

SELECT salary FROM shipments AS inv
WHERE type IN (
    SELECT type FROM transactions AS mgr
    WHERE mgr.status = inv.status
);


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

SELECT value FROM departments AS cust
WHERE level IN (
    SELECT level FROM categories AS emp
    WHERE emp.status = cust.status
);


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

SELECT value FROM employees AS catg
WHERE value > (
    SELECT SUM(value) FROM warehouses AS ord
    WHERE ord.code = catg.code
);


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

SELECT code FROM orders AS sale
WHERE level IN (
    SELECT level FROM products AS budg
    WHERE budg.level = sale.level
);


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

SELECT value FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.type = ordr.type
);


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

SELECT id FROM regions AS prod
WHERE salary > (
    SELECT MIN(amount) FROM tasks AS sale
    WHERE sale.level = prod.level
);


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

SELECT value FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.level = empl.level
);


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

SELECT id FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.code = srvc.code
);


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

SELECT salary FROM categories AS dept
WHERE value > (
    SELECT MIN(salary) FROM shipments AS empl
    WHERE empl.code = dept.code
);


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

SELECT code FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.id = ordr.id
);


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

SELECT id FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.code = mgr.code
);


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

SELECT code FROM warehouses AS sale
WHERE id IN (
    SELECT id FROM accounts AS cust
    WHERE cust.type = sale.type
);


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

SELECT name FROM projects AS emp
WHERE value > (
    SELECT MIN(salary) FROM employees AS sale
    WHERE sale.code = emp.code
);


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

SELECT salary FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.id = srvc.id
);


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

SELECT code FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.status = schd.status
);


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

SELECT id FROM shipments AS ordr
WHERE level IN (
    SELECT level FROM products AS emp
    WHERE emp.type = ordr.type
);


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

SELECT value FROM tasks AS whs
WHERE status IN (
    SELECT status FROM categories AS dept
    WHERE dept.code = whs.code
);


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

SELECT salary FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.id = budg.id
);


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

SELECT name FROM tasks AS ord
WHERE amount > (
    SELECT SUM(salary) FROM regions AS txn
    WHERE txn.level = ord.level
);


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

SELECT value FROM regions AS emp
WHERE code IN (
    SELECT code FROM suppliers AS lne
    WHERE lne.level = emp.level
);


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

SELECT salary FROM orders AS sale
WHERE salary > (
    SELECT MIN(salary) FROM departments AS catg
    WHERE catg.status = sale.status
);


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

SELECT id FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM branches AS schd
    WHERE schd.type = mgr.type
);


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

SELECT name FROM products AS lne
WHERE status IN (
    SELECT status FROM regions AS dept
    WHERE dept.level = lne.level
);


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

SELECT id FROM employees AS srvc
WHERE salary > (
    SELECT AVG(salary) FROM categories AS schd
    WHERE schd.id = srvc.id
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.status = rgn.status
);


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

SELECT salary FROM categories AS dept
WHERE code IN (
    SELECT code FROM tasks AS budg
    WHERE budg.level = dept.level
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.type = acct.type
);


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

SELECT salary FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.status = acct.status
);


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

SELECT amount FROM regions AS catg
WHERE status IN (
    SELECT status FROM transactions AS ordr
    WHERE ordr.code = catg.code
);


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

SELECT name FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.id = ord.id
);


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

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


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

SELECT salary FROM suppliers AS cust
WHERE salary > (
    SELECT COUNT(value) FROM tasks AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT salary FROM tasks AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM customers AS cust
    WHERE cust.type = ordr.type
);


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

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


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

SELECT id FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.level = whs.level
);


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

SELECT id FROM regions AS ordr
WHERE status IN (
    SELECT status FROM warehouses AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT salary FROM accounts AS ord
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS empl
    WHERE empl.type = ord.type
);


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

SELECT id FROM customers AS emp
WHERE level IN (
    SELECT level FROM suppliers AS budg
    WHERE budg.code = emp.code
);


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

SELECT name FROM categories AS budg
WHERE value > (
    SELECT MIN(salary) FROM projects AS txn
    WHERE txn.type = budg.type
);


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

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


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

SELECT amount FROM projects AS shp
WHERE level IN (
    SELECT level FROM customers AS empl
    WHERE empl.level = shp.level
);


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

SELECT amount FROM branches AS srvc
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS shp
    WHERE shp.code = srvc.code
);


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

SELECT name FROM departments AS prod
WHERE value > (
    SELECT MIN(salary) FROM customers AS budg
    WHERE budg.id = prod.id
);


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

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


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

SELECT name FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.code = dept.code
);


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

SELECT code FROM departments AS emp
WHERE code IN (
    SELECT code FROM transactions AS srvc
    WHERE srvc.status = emp.status
);


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

SELECT amount FROM customers AS catg
WHERE value > (
    SELECT AVG(amount) FROM products AS shp
    WHERE shp.type = catg.type
);


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.status = cust.status
);


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

SELECT amount FROM departments AS rgn
WHERE salary > (
    SELECT MIN(salary) FROM branches AS ordr
    WHERE ordr.level = rgn.level
);


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

SELECT salary FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.level = cust.level
);


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

SELECT code FROM tasks AS sale
WHERE code IN (
    SELECT code FROM invoices AS acct
    WHERE acct.status = sale.status
);


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

SELECT code FROM employees AS shp
WHERE value > (
    SELECT MAX(value) FROM suppliers AS emp
    WHERE emp.status = shp.status
);


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

SELECT salary FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.type = sale.type
);


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

SELECT name FROM customers AS acct
WHERE value > (
    SELECT AVG(salary) FROM accounts AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT value FROM suppliers AS sale
WHERE value > (
    SELECT SUM(value) FROM warehouses AS budg
    WHERE budg.level = sale.level
);


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

SELECT id FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.status = whs.status
);


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

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


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

SELECT code FROM employees AS inv
WHERE amount > (
    SELECT MAX(value) FROM tasks AS schd
    WHERE schd.code = inv.code
);


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

SELECT name FROM invoices AS prod
WHERE salary > (
    SELECT AVG(amount) FROM products AS schd
    WHERE schd.type = prod.type
);


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

SELECT value FROM branches AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM orders AS txn
    WHERE txn.status = rgn.status
);


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

SELECT value FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.status = catg.status
);


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

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


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

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


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

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


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

SELECT id FROM transactions AS prod
WHERE amount > (
    SELECT MIN(value) FROM regions AS empl
    WHERE empl.code = prod.code
);


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

SELECT code FROM tasks AS rgn
WHERE value > (
    SELECT SUM(value) FROM warehouses AS ord
    WHERE ord.status = rgn.status
);


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

SELECT name FROM shipments AS empl
WHERE status IN (
    SELECT status FROM suppliers AS acct
    WHERE acct.id = empl.id
);


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

SELECT name FROM invoices AS inv
WHERE code IN (
    SELECT code FROM accounts AS schd
    WHERE schd.code = inv.code
);


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

SELECT id FROM categories AS srvc
WHERE type IN (
    SELECT type FROM suppliers AS ordr
    WHERE ordr.level = srvc.level
);


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

SELECT value FROM employees AS empl
WHERE amount > (
    SELECT MIN(salary) FROM projects AS dept
    WHERE dept.type = empl.type
);


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

SELECT value FROM customers AS ordr
WHERE code IN (
    SELECT code FROM tasks AS empl
    WHERE empl.id = ordr.id
);


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

SELECT amount FROM branches AS schd
WHERE value > (
    SELECT COUNT(amount) FROM departments AS ordr
    WHERE ordr.type = schd.type
);


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

SELECT value FROM regions AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS shp
    WHERE shp.code = lne.code
);


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

SELECT id FROM warehouses AS dept
WHERE id IN (
    SELECT id FROM departments AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT name FROM projects AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT id FROM orders AS shp
WHERE salary > (
    SELECT SUM(amount) FROM employees AS budg
    WHERE budg.level = shp.level
);


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

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


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

SELECT name FROM branches AS lne
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.type = lne.type
);


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

SELECT amount FROM suppliers AS inv
WHERE level IN (
    SELECT level FROM categories AS ord
    WHERE ord.status = inv.status
);


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

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


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

SELECT name FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT salary FROM warehouses AS budg
WHERE amount > (
    SELECT SUM(value) FROM customers AS catg
    WHERE catg.code = budg.code
);


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

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


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

SELECT amount FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.status = acct.status
);


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

SELECT salary FROM branches AS inv
WHERE type IN (
    SELECT type FROM products AS acct
    WHERE acct.status = inv.status
);


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

SELECT id FROM warehouses AS acct
WHERE type IN (
    SELECT type FROM orders AS txn
    WHERE txn.level = acct.level
);


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

SELECT amount FROM invoices AS schd
WHERE value > (
    SELECT MAX(value) FROM suppliers AS emp
    WHERE emp.id = schd.id
);


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

SELECT code FROM categories AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM transactions AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT value FROM shipments AS schd
WHERE status IN (
    SELECT status FROM employees AS inv
    WHERE inv.code = schd.code
);


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

SELECT amount FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.level = empl.level
);


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

SELECT value FROM shipments AS empl
WHERE status IN (
    SELECT status FROM products AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT name FROM invoices AS rgn
WHERE amount > (
    SELECT SUM(value) FROM tasks AS txn
    WHERE txn.level = rgn.level
);


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

SELECT amount FROM accounts AS sale
WHERE salary > (
    SELECT MIN(value) FROM invoices AS prod
    WHERE prod.id = sale.id
);


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

SELECT code FROM accounts AS schd
WHERE amount > (
    SELECT SUM(amount) FROM suppliers AS whs
    WHERE whs.id = schd.id
);


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

SELECT value FROM branches AS ordr
WHERE amount > (
    SELECT COUNT(value) FROM regions AS emp
    WHERE emp.level = ordr.level
);


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

SELECT code FROM orders AS rgn
WHERE value > (
    SELECT AVG(salary) FROM projects AS whs
    WHERE whs.status = rgn.status
);


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

SELECT value FROM categories AS txn
WHERE amount > (
    SELECT SUM(salary) FROM orders AS catg
    WHERE catg.code = txn.code
);


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

SELECT name FROM accounts AS emp
WHERE status IN (
    SELECT status FROM customers AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT salary FROM suppliers AS cust
WHERE type IN (
    SELECT type FROM categories AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT code FROM employees AS rgn
WHERE status IN (
    SELECT status FROM products AS whs
    WHERE whs.id = rgn.id
);


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

SELECT code FROM accounts AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS sale
    WHERE sale.code = shp.code
);


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

SELECT code FROM departments AS emp
WHERE level IN (
    SELECT level FROM accounts AS ord
    WHERE ord.id = emp.id
);


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

SELECT name FROM tasks AS txn
WHERE salary > (
    SELECT AVG(amount) FROM invoices AS inv
    WHERE inv.status = txn.status
);


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

SELECT id FROM departments AS shp
WHERE code IN (
    SELECT code FROM invoices AS whs
    WHERE whs.type = shp.type
);


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

SELECT amount FROM warehouses AS acct
WHERE level IN (
    SELECT level FROM tasks AS budg
    WHERE budg.id = acct.id
);


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

SELECT value FROM shipments AS cust
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS lne
    WHERE lne.status = cust.status
);


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

SELECT id FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.status = whs.status
);


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

SELECT value FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.id = empl.id
);


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

SELECT id FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.code = lne.code
);


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

SELECT name FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT salary FROM tasks AS ordr
WHERE id IN (
    SELECT id FROM customers AS inv
    WHERE inv.status = ordr.status
);


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

SELECT value FROM accounts AS ordr
WHERE code IN (
    SELECT code FROM invoices AS whs
    WHERE whs.code = ordr.code
);


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

SELECT id FROM invoices AS ordr
WHERE code IN (
    SELECT code FROM suppliers AS dept
    WHERE dept.id = ordr.id
);


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

SELECT code FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = rgn.code
);


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

SELECT name FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.code = shp.code
);


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

SELECT code FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT name FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.code = lne.code
);


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

SELECT code FROM orders AS sale
WHERE value > (
    SELECT AVG(value) FROM projects AS rgn
    WHERE rgn.level = sale.level
);


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

SELECT value FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = dept.level
);


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

SELECT id FROM projects AS srvc
WHERE level IN (
    SELECT level FROM products AS rgn
    WHERE rgn.code = srvc.code
);


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

SELECT name FROM products AS txn
WHERE type IN (
    SELECT type FROM categories AS mgr
    WHERE mgr.type = txn.type
);


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

SELECT value FROM transactions AS empl
WHERE id IN (
    SELECT id FROM regions AS srvc
    WHERE srvc.type = empl.type
);


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

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


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

SELECT amount FROM transactions AS inv
WHERE level IN (
    SELECT level FROM categories AS schd
    WHERE schd.id = inv.id
);


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

SELECT id FROM customers AS ordr
WHERE value > (
    SELECT MAX(amount) FROM warehouses AS sale
    WHERE sale.id = ordr.id
);


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

SELECT code FROM departments AS catg
WHERE level IN (
    SELECT level FROM shipments AS inv
    WHERE inv.id = catg.id
);


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

SELECT salary FROM transactions AS schd
WHERE id IN (
    SELECT id FROM shipments AS txn
    WHERE txn.level = schd.level
);


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

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


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

SELECT value FROM accounts AS cust
WHERE status IN (
    SELECT status FROM employees AS shp
    WHERE shp.level = cust.level
);


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

SELECT value FROM branches AS catg
WHERE value > (
    SELECT MAX(amount) FROM customers AS shp
    WHERE shp.type = catg.type
);


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

SELECT salary FROM regions AS empl
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS emp
    WHERE emp.level = empl.level
);


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

SELECT code FROM regions AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.level = budg.level
);


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

SELECT amount FROM transactions AS srvc
WHERE value > (
    SELECT COUNT(amount) FROM categories AS ordr
    WHERE ordr.code = srvc.code
);


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

SELECT code FROM shipments AS inv
WHERE level IN (
    SELECT level FROM employees AS rgn
    WHERE rgn.id = inv.id
);


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

SELECT amount FROM transactions AS sale
WHERE id IN (
    SELECT id FROM projects AS acct
    WHERE acct.status = sale.status
);


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

SELECT name FROM accounts AS ordr
WHERE type IN (
    SELECT type FROM projects AS inv
    WHERE inv.code = ordr.code
);


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

SELECT amount FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = lne.status
);


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

SELECT amount FROM transactions AS lne
WHERE amount > (
    SELECT AVG(amount) FROM projects AS schd
    WHERE schd.type = lne.type
);


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

SELECT value FROM products AS rgn
WHERE value > (
    SELECT AVG(salary) FROM categories AS cust
    WHERE cust.code = rgn.code
);


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

SELECT name FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.id = sale.id
);


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

SELECT value FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = ord.type
);


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

SELECT amount FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.code = rgn.code
);


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

SELECT code FROM products AS lne
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.status = lne.status
);


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

SELECT value FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.id = catg.id
);


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

SELECT value FROM warehouses AS cust
WHERE id IN (
    SELECT id FROM employees AS lne
    WHERE lne.type = cust.type
);


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

SELECT value FROM shipments AS acct
WHERE id IN (
    SELECT id FROM departments AS catg
    WHERE catg.status = acct.status
);


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

SELECT value FROM employees AS empl
WHERE salary > (
    SELECT SUM(amount) FROM orders AS prod
    WHERE prod.id = empl.id
);


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

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


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

SELECT amount FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.status = empl.status
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.level = ord.level
);


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

SELECT name FROM transactions AS ord
WHERE amount > (
    SELECT SUM(amount) FROM warehouses AS acct
    WHERE acct.status = ord.status
);


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

SELECT code FROM warehouses AS cust
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT id FROM products AS inv
WHERE value > (
    SELECT SUM(salary) FROM regions AS schd
    WHERE schd.level = inv.level
);


Prompt:
Schema:
  categories (alias: budg)(type, salary, level, amount)
  warehouses(status, salary, name, level)
Task: Retrieve id from categories with amount above the MAX(salary) of warehouses rows sharing the same status.
SQL:

SELECT id FROM categories AS budg
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS acct
    WHERE acct.status = budg.status
);


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

SELECT id FROM invoices AS srvc
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT name FROM branches AS empl
WHERE id IN (
    SELECT id FROM customers AS txn
    WHERE txn.code = empl.code
);


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

SELECT name FROM invoices AS whs
WHERE id IN (
    SELECT id FROM products AS shp
    WHERE shp.type = whs.type
);


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

SELECT code FROM orders AS cust
WHERE id IN (
    SELECT id FROM suppliers AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT code FROM invoices AS whs
WHERE value > (
    SELECT AVG(value) FROM employees AS empl
    WHERE empl.status = whs.status
);


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

SELECT value FROM orders AS empl
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.type = empl.type
);


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

SELECT salary FROM departments AS txn
WHERE salary > (
    SELECT AVG(value) FROM invoices AS lne
    WHERE lne.level = txn.level
);


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

SELECT amount FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = sale.level
);


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

SELECT name FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.status = lne.status
);


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

SELECT code FROM shipments AS cust
WHERE value > (
    SELECT AVG(salary) FROM customers AS prod
    WHERE prod.level = cust.level
);


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

SELECT id FROM tasks AS mgr
WHERE salary > (
    SELECT COUNT(amount) FROM orders AS whs
    WHERE whs.status = mgr.status
);


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

SELECT amount FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.type = acct.type
);


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

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


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

SELECT name FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.code = sale.code
);


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

SELECT name FROM accounts AS cust
WHERE value > (
    SELECT MAX(amount) FROM shipments AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT salary FROM employees AS shp
WHERE salary > (
    SELECT MAX(amount) FROM suppliers AS lne
    WHERE lne.type = shp.type
);


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

SELECT code FROM regions AS emp
WHERE type IN (
    SELECT type FROM employees AS whs
    WHERE whs.type = emp.type
);


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

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


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

SELECT value FROM regions AS sale
WHERE code IN (
    SELECT code FROM tasks AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT name FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT amount FROM transactions AS catg
WHERE value > (
    SELECT SUM(salary) FROM tasks AS mgr
    WHERE mgr.id = catg.id
);


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

SELECT name FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.type = prod.type
);


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

SELECT value FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.type = ord.type
);


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

SELECT id FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.type = txn.type
);


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

SELECT code FROM tasks AS mgr
WHERE value > (
    SELECT MIN(value) FROM invoices AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT id FROM accounts AS lne
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS ordr
    WHERE ordr.type = lne.type
);


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

SELECT name FROM projects AS sale
WHERE level IN (
    SELECT level FROM customers AS prod
    WHERE prod.code = sale.code
);


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

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


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

SELECT code FROM shipments AS catg
WHERE amount > (
    SELECT AVG(salary) FROM employees AS prod
    WHERE prod.level = catg.level
);


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

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


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

SELECT name FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.id = srvc.id
);


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

SELECT name FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT id FROM warehouses AS prod
WHERE type IN (
    SELECT type FROM regions AS txn
    WHERE txn.code = prod.code
);


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

SELECT name FROM suppliers AS emp
WHERE id IN (
    SELECT id FROM warehouses AS acct
    WHERE acct.id = emp.id
);


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

SELECT code FROM projects AS whs
WHERE amount > (
    SELECT MAX(value) FROM transactions AS cust
    WHERE cust.code = whs.code
);


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

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


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

SELECT id FROM products AS ord
WHERE status IN (
    SELECT status FROM tasks AS whs
    WHERE whs.code = ord.code
);


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

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


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

SELECT salary FROM branches AS whs
WHERE value > (
    SELECT AVG(amount) FROM suppliers AS inv
    WHERE inv.level = whs.level
);


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

SELECT id FROM invoices AS lne
WHERE level IN (
    SELECT level FROM accounts AS shp
    WHERE shp.status = lne.status
);


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

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


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

SELECT id FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.type = dept.type
);


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

SELECT value FROM accounts AS budg
WHERE code IN (
    SELECT code FROM departments AS srvc
    WHERE srvc.type = budg.type
);


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

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


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

SELECT id FROM transactions AS srvc
WHERE level IN (
    SELECT level FROM regions AS catg
    WHERE catg.level = srvc.level
);


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

SELECT salary FROM tasks AS srvc
WHERE status IN (
    SELECT status FROM shipments AS txn
    WHERE txn.id = srvc.id
);


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

SELECT value FROM employees AS acct
WHERE amount > (
    SELECT AVG(salary) FROM products AS dept
    WHERE dept.type = acct.type
);


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

SELECT name FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.level = mgr.level
);


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

SELECT code FROM tasks AS mgr
WHERE amount > (
    SELECT COUNT(salary) FROM products AS lne
    WHERE lne.level = mgr.level
);


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

SELECT salary FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.type = emp.type
);


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

SELECT id FROM products AS mgr
WHERE value > (
    SELECT SUM(value) FROM branches AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT code FROM customers AS empl
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS txn
    WHERE txn.code = empl.code
);


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

SELECT id FROM projects AS mgr
WHERE salary > (
    SELECT MIN(salary) FROM categories AS cust
    WHERE cust.status = mgr.status
);


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

SELECT id FROM tasks AS emp
WHERE status IN (
    SELECT status FROM invoices AS empl
    WHERE empl.type = emp.type
);


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

SELECT name FROM customers AS ord
WHERE level IN (
    SELECT level FROM tasks AS whs
    WHERE whs.code = ord.code
);


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

SELECT salary FROM departments AS emp
WHERE amount > (
    SELECT AVG(amount) FROM branches AS whs
    WHERE whs.code = emp.code
);


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

SELECT name FROM categories AS inv
WHERE value > (
    SELECT MIN(salary) FROM customers AS ord
    WHERE ord.code = inv.code
);


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

SELECT code FROM departments AS emp
WHERE amount > (
    SELECT MIN(value) FROM suppliers AS empl
    WHERE empl.level = emp.level
);


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

SELECT id FROM categories AS ord
WHERE amount > (
    SELECT MIN(value) FROM products AS empl
    WHERE empl.code = ord.code
);


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

SELECT code FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.status = whs.status
);


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

SELECT name FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.level = emp.level
);


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

SELECT amount FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.level = prod.level
);


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

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


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

SELECT amount FROM projects AS ordr
WHERE level IN (
    SELECT level FROM orders AS sale
    WHERE sale.type = ordr.type
);


Prompt:
Schema:
  orders (alias: srvc)(salary, value, code, name)
  tasks(level, amount, code, type)
Task: Retrieve value from orders with salary above the SUM(salary) of tasks rows sharing the same level.
SQL:

SELECT value FROM orders AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS acct
    WHERE acct.level = srvc.level
);


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

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


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

SELECT value FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.id = dept.id
);


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

SELECT id FROM branches AS srvc
WHERE amount > (
    SELECT MAX(value) FROM tasks AS rgn
    WHERE rgn.level = srvc.level
);


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

SELECT amount FROM employees AS ordr
WHERE type IN (
    SELECT type FROM accounts AS rgn
    WHERE rgn.type = ordr.type
);


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

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


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

SELECT salary FROM accounts AS whs
WHERE code IN (
    SELECT code FROM departments AS sale
    WHERE sale.code = whs.code
);


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

SELECT amount FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.code = prod.code
);


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

SELECT salary FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.type = prod.type
);


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

SELECT code FROM categories AS acct
WHERE level IN (
    SELECT level FROM suppliers AS srvc
    WHERE srvc.id = acct.id
);


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

SELECT name FROM shipments AS whs
WHERE status IN (
    SELECT status FROM products AS inv
    WHERE inv.id = whs.id
);


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

SELECT value FROM accounts AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.id = txn.id
);


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

SELECT id FROM branches AS ord
WHERE salary > (
    SELECT AVG(amount) FROM projects AS empl
    WHERE empl.type = ord.type
);


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

SELECT value FROM shipments AS prod
WHERE level IN (
    SELECT level FROM departments AS sale
    WHERE sale.id = prod.id
);


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

SELECT value FROM shipments AS dept
WHERE salary > (
    SELECT AVG(value) FROM tasks AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT value FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM departments AS emp
    WHERE emp.code = rgn.code
);


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

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


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

SELECT value FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.status = rgn.status
);


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

SELECT name FROM invoices AS emp
WHERE value > (
    SELECT MAX(value) FROM warehouses AS ord
    WHERE ord.code = emp.code
);


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

SELECT amount FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.code = acct.code
);


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

SELECT name FROM regions AS whs
WHERE status IN (
    SELECT status FROM shipments AS catg
    WHERE catg.status = whs.status
);


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

SELECT salary FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.type = emp.type
);


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

SELECT name FROM categories AS acct
WHERE status IN (
    SELECT status FROM accounts AS schd
    WHERE schd.code = acct.code
);


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

SELECT id FROM branches AS budg
WHERE status IN (
    SELECT status FROM tasks AS txn
    WHERE txn.status = budg.status
);


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

SELECT amount FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT salary FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.id = srvc.id
);


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

SELECT value FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS budg
    WHERE budg.status = srvc.status
);


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

SELECT id FROM orders AS budg
WHERE type IN (
    SELECT type FROM employees AS cust
    WHERE cust.code = budg.code
);


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

SELECT value FROM categories AS schd
WHERE level IN (
    SELECT level FROM customers AS budg
    WHERE budg.code = schd.code
);


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

SELECT value FROM accounts AS schd
WHERE id IN (
    SELECT id FROM warehouses AS txn
    WHERE txn.id = schd.id
);


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

SELECT amount FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.level = shp.level
);


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

SELECT salary FROM categories AS sale
WHERE salary > (
    SELECT MAX(salary) FROM regions AS empl
    WHERE empl.id = sale.id
);


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

SELECT salary FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.type = acct.type
);


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

SELECT code FROM orders AS budg
WHERE value > (
    SELECT COUNT(amount) FROM projects AS lne
    WHERE lne.code = budg.code
);


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

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


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

SELECT name FROM employees AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM products AS inv
    WHERE inv.id = catg.id
);


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

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


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

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


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

SELECT value FROM categories AS cust
WHERE type IN (
    SELECT type FROM suppliers AS shp
    WHERE shp.level = cust.level
);


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

SELECT amount FROM regions AS lne
WHERE id IN (
    SELECT id FROM customers AS ordr
    WHERE ordr.level = lne.level
);


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

SELECT value FROM transactions AS txn
WHERE level IN (
    SELECT level FROM departments AS sale
    WHERE sale.id = txn.id
);


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

SELECT id FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.level = lne.level
);


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

SELECT id FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.status = cust.status
);


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

SELECT code FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT code FROM projects AS whs
WHERE amount > (
    SELECT SUM(salary) FROM categories AS catg
    WHERE catg.level = whs.level
);


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

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


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

SELECT value FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.type = srvc.type
);


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

SELECT code FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.code = ord.code
);


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

SELECT salary FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS whs
    WHERE whs.type = shp.type
);


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

SELECT name FROM departments AS txn
WHERE amount > (
    SELECT MAX(value) FROM warehouses AS catg
    WHERE catg.id = txn.id
);


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

SELECT name FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.status = lne.status
);


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

SELECT salary FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.type = dept.type
);


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

SELECT value FROM employees AS schd
WHERE value > (
    SELECT SUM(value) FROM branches AS ord
    WHERE ord.code = schd.code
);


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

SELECT name FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = mgr.type
);