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

SELECT amount FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.type = srvc.type
);


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

SELECT code FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.id = catg.id
);


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

SELECT amount FROM invoices AS shp
WHERE level IN (
    SELECT level FROM employees AS emp
    WHERE emp.id = shp.id
);


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

SELECT name FROM employees AS srvc
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS prod
    WHERE prod.id = srvc.id
);


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

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


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

SELECT amount FROM suppliers AS acct
WHERE level IN (
    SELECT level FROM customers AS lne
    WHERE lne.code = acct.code
);


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

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


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

SELECT amount FROM departments AS budg
WHERE id IN (
    SELECT id FROM tasks AS catg
    WHERE catg.status = budg.status
);


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

SELECT name FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.type = budg.type
);


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

SELECT id FROM products AS catg
WHERE code IN (
    SELECT code FROM projects AS sale
    WHERE sale.level = catg.level
);


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

SELECT value FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.status = inv.status
);


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

SELECT amount FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.level = emp.level
);


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

SELECT amount FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.level = empl.level
);


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

SELECT code FROM orders AS srvc
WHERE value > (
    SELECT AVG(value) FROM suppliers AS lne
    WHERE lne.code = srvc.code
);


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

SELECT salary FROM accounts AS dept
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS cust
    WHERE cust.code = dept.code
);


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

SELECT id FROM shipments AS catg
WHERE level IN (
    SELECT level FROM employees AS acct
    WHERE acct.code = catg.code
);


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

SELECT id FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = lne.status
);


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

SELECT amount FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS lne
    WHERE lne.level = whs.level
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.code = budg.code
);


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

SELECT salary FROM categories AS mgr
WHERE code IN (
    SELECT code FROM departments AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT name FROM warehouses AS shp
WHERE value > (
    SELECT COUNT(value) FROM shipments AS dept
    WHERE dept.id = shp.id
);


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

SELECT id FROM products AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.code = shp.code
);


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

SELECT name FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT code FROM invoices AS emp
WHERE type IN (
    SELECT type FROM shipments AS prod
    WHERE prod.code = emp.code
);


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

SELECT salary FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.id = mgr.id
);


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

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


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

SELECT amount FROM employees AS lne
WHERE id IN (
    SELECT id FROM suppliers AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT id FROM accounts AS mgr
WHERE type IN (
    SELECT type FROM customers AS whs
    WHERE whs.level = mgr.level
);


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

SELECT salary FROM orders AS lne
WHERE code IN (
    SELECT code FROM invoices AS schd
    WHERE schd.status = lne.status
);


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

SELECT code FROM warehouses AS inv
WHERE status IN (
    SELECT status FROM customers AS budg
    WHERE budg.code = inv.code
);


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

SELECT amount FROM projects AS shp
WHERE level IN (
    SELECT level FROM regions AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT id FROM orders AS mgr
WHERE status IN (
    SELECT status FROM employees AS acct
    WHERE acct.type = mgr.type
);


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

SELECT salary FROM departments AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS catg
    WHERE catg.id = rgn.id
);


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

SELECT value FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.type = cust.type
);


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

SELECT code FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.code = inv.code
);


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

SELECT salary FROM tasks AS budg
WHERE status IN (
    SELECT status FROM projects AS sale
    WHERE sale.type = budg.type
);


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

SELECT code FROM customers AS inv
WHERE code IN (
    SELECT code FROM categories AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT code FROM transactions AS cust
WHERE status IN (
    SELECT status FROM customers AS prod
    WHERE prod.id = cust.id
);


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

SELECT name FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.level = emp.level
);


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

SELECT id FROM shipments AS mgr
WHERE level IN (
    SELECT level FROM projects AS sale
    WHERE sale.code = mgr.code
);


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

SELECT code FROM regions AS ordr
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS rgn
    WHERE rgn.type = ordr.type
);


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

SELECT code FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.type = lne.type
);


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

SELECT id FROM tasks AS cust
WHERE salary > (
    SELECT COUNT(amount) FROM customers AS inv
    WHERE inv.level = cust.level
);


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

SELECT salary FROM invoices AS inv
WHERE id IN (
    SELECT id FROM accounts AS emp
    WHERE emp.code = inv.code
);


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

SELECT amount FROM categories AS budg
WHERE status IN (
    SELECT status FROM transactions AS cust
    WHERE cust.code = budg.code
);


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

SELECT name FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.type = dept.type
);


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

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


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

SELECT code FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.status = empl.status
);


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

SELECT code FROM transactions AS txn
WHERE type IN (
    SELECT type FROM warehouses AS inv
    WHERE inv.level = txn.level
);


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

SELECT id FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.level = mgr.level
);


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

SELECT amount FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.id = catg.id
);


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

SELECT id FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT salary FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = catg.status
);


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

SELECT code FROM employees AS budg
WHERE level IN (
    SELECT level FROM accounts AS srvc
    WHERE srvc.status = budg.status
);


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

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


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

SELECT salary FROM departments AS budg
WHERE amount > (
    SELECT SUM(amount) FROM employees AS schd
    WHERE schd.id = budg.id
);


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

SELECT salary FROM regions AS ordr
WHERE id IN (
    SELECT id FROM departments AS acct
    WHERE acct.type = ordr.type
);


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

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


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

SELECT value FROM regions AS whs
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT amount FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT id FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.status = rgn.status
);


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

SELECT amount FROM warehouses AS empl
WHERE salary > (
    SELECT MAX(amount) FROM transactions AS inv
    WHERE inv.level = empl.level
);


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

SELECT value FROM products AS whs
WHERE value > (
    SELECT SUM(amount) FROM transactions AS schd
    WHERE schd.type = whs.type
);


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

SELECT code FROM departments AS catg
WHERE code IN (
    SELECT code FROM branches AS prod
    WHERE prod.code = catg.code
);


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

SELECT salary FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = rgn.level
);


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

SELECT amount FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.code = mgr.code
);


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

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


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

SELECT value FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.level = rgn.level
);


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

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


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

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


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

SELECT code FROM projects AS whs
WHERE status IN (
    SELECT status FROM accounts AS empl
    WHERE empl.level = whs.level
);


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

SELECT code FROM transactions AS srvc
WHERE level IN (
    SELECT level FROM warehouses AS prod
    WHERE prod.type = srvc.type
);


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

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


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

SELECT salary FROM regions AS shp
WHERE value > (
    SELECT MAX(value) FROM departments AS rgn
    WHERE rgn.level = shp.level
);


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

SELECT code FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.level = whs.level
);


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

SELECT code FROM transactions AS inv
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS acct
    WHERE acct.code = inv.code
);


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

SELECT name FROM products AS whs
WHERE id IN (
    SELECT id FROM customers AS srvc
    WHERE srvc.level = whs.level
);


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

SELECT value FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.level = prod.level
);


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

SELECT name FROM departments AS emp
WHERE type IN (
    SELECT type FROM transactions AS catg
    WHERE catg.level = emp.level
);


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

SELECT salary FROM products AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM employees AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT name FROM regions AS ordr
WHERE value > (
    SELECT MAX(value) FROM accounts AS empl
    WHERE empl.type = ordr.type
);


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

SELECT name FROM categories AS sale
WHERE salary > (
    SELECT SUM(salary) FROM branches AS lne
    WHERE lne.code = sale.code
);


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

SELECT name FROM suppliers AS lne
WHERE code IN (
    SELECT code FROM shipments AS catg
    WHERE catg.status = lne.status
);


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

SELECT code FROM transactions AS txn
WHERE salary > (
    SELECT COUNT(value) FROM customers AS prod
    WHERE prod.level = txn.level
);


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

SELECT amount FROM departments AS txn
WHERE type IN (
    SELECT type FROM invoices AS budg
    WHERE budg.code = txn.code
);


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

SELECT amount FROM orders AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS emp
    WHERE emp.id = catg.id
);


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

SELECT code FROM regions AS budg
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.id = budg.id
);


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

SELECT id FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT salary FROM products AS dept
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS shp
    WHERE shp.level = dept.level
);


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

SELECT amount FROM orders AS emp
WHERE type IN (
    SELECT type FROM transactions AS inv
    WHERE inv.status = emp.status
);


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

SELECT name FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.type = catg.type
);


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

SELECT name FROM accounts AS ord
WHERE amount > (
    SELECT MAX(salary) FROM orders AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT id FROM invoices AS ord
WHERE level IN (
    SELECT level FROM categories AS ordr
    WHERE ordr.id = ord.id
);


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

SELECT salary FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.code = ord.code
);


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

SELECT salary FROM suppliers AS ord
WHERE level IN (
    SELECT level FROM customers AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT code FROM categories AS rgn
WHERE type IN (
    SELECT type FROM transactions AS whs
    WHERE whs.level = rgn.level
);


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

SELECT value FROM transactions AS mgr
WHERE level IN (
    SELECT level FROM products AS srvc
    WHERE srvc.level = mgr.level
);


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

SELECT amount FROM tasks AS srvc
WHERE status IN (
    SELECT status FROM products AS ordr
    WHERE ordr.level = srvc.level
);


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

SELECT amount FROM categories AS acct
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS catg
    WHERE catg.type = acct.type
);


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

SELECT name FROM customers AS sale
WHERE code IN (
    SELECT code FROM employees AS dept
    WHERE dept.level = sale.level
);


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

SELECT salary FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT code FROM regions AS ordr
WHERE salary > (
    SELECT MAX(value) FROM employees AS acct
    WHERE acct.code = ordr.code
);


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

SELECT value FROM projects AS ordr
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.code = ordr.code
);


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

SELECT value FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.status = rgn.status
);


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

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


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

SELECT code FROM suppliers AS ord
WHERE level IN (
    SELECT level FROM branches AS cust
    WHERE cust.type = ord.type
);


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

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


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

SELECT value FROM suppliers AS txn
WHERE value > (
    SELECT SUM(value) FROM orders AS cust
    WHERE cust.code = txn.code
);


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

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


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

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


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

SELECT code FROM transactions AS ord
WHERE value > (
    SELECT SUM(amount) FROM customers AS inv
    WHERE inv.status = ord.status
);


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

SELECT id FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.code = whs.code
);


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

SELECT amount FROM departments AS acct
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS prod
    WHERE prod.level = acct.level
);


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

SELECT code FROM customers AS srvc
WHERE id IN (
    SELECT id FROM warehouses AS shp
    WHERE shp.id = srvc.id
);


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

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


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

SELECT code FROM products AS txn
WHERE level IN (
    SELECT level FROM projects AS budg
    WHERE budg.level = txn.level
);


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

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


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

SELECT code FROM transactions AS mgr
WHERE status IN (
    SELECT status FROM branches AS txn
    WHERE txn.type = mgr.type
);


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

SELECT name FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.code = cust.code
);


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

SELECT name FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT amount FROM invoices AS schd
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS ord
    WHERE ord.status = schd.status
);


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

SELECT amount FROM projects AS sale
WHERE value > (
    SELECT SUM(salary) FROM tasks AS whs
    WHERE whs.status = sale.status
);


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

SELECT code FROM branches AS ord
WHERE value > (
    SELECT AVG(amount) FROM transactions AS dept
    WHERE dept.status = ord.status
);


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

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


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

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


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

SELECT id FROM products AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS ord
    WHERE ord.code = ordr.code
);


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

SELECT code FROM categories AS sale
WHERE level IN (
    SELECT level FROM customers AS empl
    WHERE empl.status = sale.status
);


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

SELECT name FROM projects AS ord
WHERE level IN (
    SELECT level FROM invoices AS schd
    WHERE schd.status = ord.status
);


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

SELECT name FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT value FROM transactions AS cust
WHERE code IN (
    SELECT code FROM tasks AS sale
    WHERE sale.status = cust.status
);


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

SELECT code FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.code = sale.code
);


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

SELECT id FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.level = shp.level
);


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

SELECT name FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.level = rgn.level
);


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

SELECT value FROM tasks AS acct
WHERE status IN (
    SELECT status FROM employees AS txn
    WHERE txn.id = acct.id
);


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

SELECT code FROM shipments AS acct
WHERE amount > (
    SELECT MAX(value) FROM employees AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT amount FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.level = srvc.level
);


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

SELECT salary FROM warehouses AS inv
WHERE code IN (
    SELECT code FROM orders AS shp
    WHERE shp.id = inv.id
);


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

SELECT salary FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.id = ordr.id
);


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

SELECT name FROM branches AS shp
WHERE level IN (
    SELECT level FROM invoices AS prod
    WHERE prod.code = shp.code
);


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

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


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

SELECT code FROM products AS rgn
WHERE status IN (
    SELECT status FROM orders AS srvc
    WHERE srvc.code = rgn.code
);


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

SELECT value FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS lne
    WHERE lne.code = shp.code
);


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

SELECT id FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.status = dept.status
);


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

SELECT amount FROM projects AS dept
WHERE amount > (
    SELECT MIN(value) FROM customers AS whs
    WHERE whs.level = dept.level
);


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

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


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

SELECT value FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = dept.type
);


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

SELECT amount FROM suppliers AS prod
WHERE type IN (
    SELECT type FROM customers AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT name FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = prod.id
);


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

SELECT amount FROM customers AS lne
WHERE status IN (
    SELECT status FROM invoices AS sale
    WHERE sale.code = lne.code
);


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

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


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.status = rgn.status
);


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

SELECT salary FROM tasks AS srvc
WHERE type IN (
    SELECT type FROM shipments AS empl
    WHERE empl.id = srvc.id
);


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

SELECT salary FROM transactions AS dept
WHERE amount > (
    SELECT SUM(value) FROM warehouses AS txn
    WHERE txn.level = dept.level
);


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

SELECT salary FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.id = whs.id
);


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

SELECT id FROM warehouses AS srvc
WHERE id IN (
    SELECT id FROM projects AS rgn
    WHERE rgn.status = srvc.status
);


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

SELECT name FROM shipments AS whs
WHERE id IN (
    SELECT id FROM projects AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT id FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.type = ord.type
);


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

SELECT name FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = catg.id
);


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

SELECT value FROM suppliers AS acct
WHERE code IN (
    SELECT code FROM orders AS empl
    WHERE empl.id = acct.id
);


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

SELECT id FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT amount FROM orders AS lne
WHERE value > (
    SELECT MIN(amount) FROM regions AS sale
    WHERE sale.code = lne.code
);


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

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


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

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


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

SELECT amount FROM customers AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS txn
    WHERE txn.id = mgr.id
);


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

SELECT value FROM categories AS schd
WHERE salary > (
    SELECT SUM(salary) FROM transactions AS txn
    WHERE txn.code = schd.code
);


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

SELECT salary FROM projects AS acct
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS shp
    WHERE shp.status = acct.status
);


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

SELECT value FROM warehouses AS acct
WHERE value > (
    SELECT SUM(amount) FROM transactions AS catg
    WHERE catg.level = acct.level
);


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

SELECT code FROM shipments AS catg
WHERE id IN (
    SELECT id FROM suppliers AS cust
    WHERE cust.level = catg.level
);


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

SELECT id FROM tasks AS acct
WHERE id IN (
    SELECT id FROM employees AS catg
    WHERE catg.level = acct.level
);


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

SELECT salary FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.type = ordr.type
);


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

SELECT name FROM transactions AS whs
WHERE type IN (
    SELECT type FROM shipments AS cust
    WHERE cust.code = whs.code
);


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

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


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

SELECT code FROM branches AS acct
WHERE status IN (
    SELECT status FROM warehouses AS cust
    WHERE cust.status = acct.status
);


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

SELECT name FROM customers AS budg
WHERE type IN (
    SELECT type FROM regions AS ord
    WHERE ord.status = budg.status
);


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

SELECT value FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.level = rgn.level
);


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

SELECT name FROM departments AS budg
WHERE code IN (
    SELECT code FROM shipments AS acct
    WHERE acct.id = budg.id
);


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

SELECT value FROM invoices AS inv
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS prod
    WHERE prod.code = inv.code
);


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

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


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

SELECT code FROM projects AS schd
WHERE amount > (
    SELECT MAX(value) FROM employees AS budg
    WHERE budg.level = schd.level
);


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

SELECT salary FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.level = emp.level
);


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

SELECT value FROM employees AS sale
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS lne
    WHERE lne.type = sale.type
);


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

SELECT name FROM suppliers AS whs
WHERE code IN (
    SELECT code FROM invoices AS mgr
    WHERE mgr.type = whs.type
);


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

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


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

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


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

SELECT id FROM categories AS srvc
WHERE amount > (
    SELECT COUNT(amount) FROM tasks AS dept
    WHERE dept.type = srvc.type
);


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

SELECT value FROM suppliers AS emp
WHERE code IN (
    SELECT code FROM transactions AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT value FROM branches AS schd
WHERE code IN (
    SELECT code FROM products AS ord
    WHERE ord.type = schd.type
);


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

SELECT amount FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.code = sale.code
);


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

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


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

SELECT value FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS budg
    WHERE budg.level = srvc.level
);


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

SELECT value FROM suppliers AS txn
WHERE value > (
    SELECT MAX(value) FROM projects AS srvc
    WHERE srvc.type = txn.type
);


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

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


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

SELECT amount FROM departments AS sale
WHERE code IN (
    SELECT code FROM invoices AS shp
    WHERE shp.status = sale.status
);


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

SELECT amount FROM shipments AS prod
WHERE amount > (
    SELECT MIN(amount) FROM projects AS whs
    WHERE whs.level = prod.level
);


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

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


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

SELECT code FROM suppliers AS empl
WHERE value > (
    SELECT MAX(salary) FROM accounts AS lne
    WHERE lne.type = empl.type
);


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

SELECT name FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.code = sale.code
);


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

SELECT value FROM customers AS schd
WHERE value > (
    SELECT MAX(amount) FROM shipments AS sale
    WHERE sale.level = schd.level
);


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

SELECT name FROM invoices AS empl
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.type = empl.type
);


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

SELECT id FROM categories AS budg
WHERE type IN (
    SELECT type FROM shipments AS inv
    WHERE inv.level = budg.level
);


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

SELECT id FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.status = budg.status
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.level = srvc.level
);


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

SELECT salary FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS acct
    WHERE acct.level = sale.level
);


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

SELECT name FROM transactions AS prod
WHERE status IN (
    SELECT status FROM orders AS empl
    WHERE empl.id = prod.id
);


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

SELECT salary FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.level = dept.level
);


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

SELECT value FROM invoices AS lne
WHERE id IN (
    SELECT id FROM orders AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT name FROM products AS whs
WHERE amount > (
    SELECT MIN(value) FROM regions AS emp
    WHERE emp.code = whs.code
);


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

SELECT name FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.id = prod.id
);


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

SELECT value FROM suppliers AS cust
WHERE value > (
    SELECT MAX(value) FROM projects AS mgr
    WHERE mgr.type = cust.type
);


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

SELECT name FROM customers AS ord
WHERE id IN (
    SELECT id FROM shipments AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT salary FROM suppliers AS emp
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS shp
    WHERE shp.level = emp.level
);


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

SELECT amount FROM warehouses AS catg
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS prod
    WHERE prod.code = catg.code
);


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

SELECT id FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.code = sale.code
);


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

SELECT value FROM shipments AS sale
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT code FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.level = lne.level
);


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

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


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

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


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

SELECT salary FROM projects AS inv
WHERE code IN (
    SELECT code FROM transactions AS empl
    WHERE empl.id = inv.id
);


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

SELECT salary FROM departments AS emp
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS ord
    WHERE ord.level = emp.level
);


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

SELECT code FROM regions AS cust
WHERE status IN (
    SELECT status FROM suppliers AS prod
    WHERE prod.level = cust.level
);


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

SELECT id FROM warehouses AS mgr
WHERE value > (
    SELECT AVG(value) FROM invoices AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT id FROM orders AS srvc
WHERE salary > (
    SELECT MAX(salary) FROM accounts AS sale
    WHERE sale.id = srvc.id
);


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

SELECT value FROM regions AS srvc
WHERE type IN (
    SELECT type FROM orders AS catg
    WHERE catg.status = srvc.status
);


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

SELECT salary FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.code = shp.code
);


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

SELECT value FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS budg
    WHERE budg.code = schd.code
);


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

SELECT amount FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.level = lne.level
);


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

SELECT salary FROM employees AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.level = acct.level
);


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

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


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

SELECT code FROM transactions AS budg
WHERE amount > (
    SELECT AVG(value) FROM products AS sale
    WHERE sale.id = budg.id
);


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

SELECT amount FROM orders AS srvc
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS schd
    WHERE schd.status = srvc.status
);


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

SELECT amount FROM shipments AS ordr
WHERE id IN (
    SELECT id FROM orders AS empl
    WHERE empl.level = ordr.level
);


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

SELECT salary FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.type = rgn.type
);


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

SELECT id FROM categories AS prod
WHERE level IN (
    SELECT level FROM departments AS sale
    WHERE sale.code = prod.code
);


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

SELECT amount FROM categories AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM employees AS sale
    WHERE sale.status = ordr.status
);


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

SELECT name FROM products AS catg
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.status = catg.status
);


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

SELECT salary FROM warehouses AS shp
WHERE type IN (
    SELECT type FROM products AS mgr
    WHERE mgr.status = shp.status
);


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

SELECT name FROM tasks AS sale
WHERE code IN (
    SELECT code FROM shipments AS emp
    WHERE emp.type = sale.type
);


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

SELECT value FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = schd.id
);


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

SELECT amount FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.code = prod.code
);


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

SELECT name FROM transactions AS lne
WHERE amount > (
    SELECT SUM(salary) FROM employees AS whs
    WHERE whs.code = lne.code
);


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

SELECT salary FROM products AS prod
WHERE id IN (
    SELECT id FROM accounts AS acct
    WHERE acct.level = prod.level
);


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

SELECT amount FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.type = dept.type
);


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

SELECT salary FROM invoices AS catg
WHERE amount > (
    SELECT COUNT(value) FROM regions AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT id FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.level = schd.level
);


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

SELECT id FROM accounts AS txn
WHERE salary > (
    SELECT AVG(salary) FROM shipments AS cust
    WHERE cust.level = txn.level
);


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

SELECT id FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.level = txn.level
);


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

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


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

SELECT amount FROM accounts AS acct
WHERE amount > (
    SELECT MIN(amount) FROM branches AS emp
    WHERE emp.level = acct.level
);


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

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


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

SELECT salary FROM tasks AS ord
WHERE salary > (
    SELECT SUM(value) FROM categories AS lne
    WHERE lne.code = ord.code
);


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

SELECT value FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.type = prod.type
);


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

SELECT code FROM employees AS emp
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS ord
    WHERE ord.type = emp.type
);


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

SELECT name FROM regions AS prod
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS mgr
    WHERE mgr.type = prod.type
);


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

SELECT name FROM accounts AS rgn
WHERE value > (
    SELECT SUM(amount) FROM orders AS shp
    WHERE shp.level = rgn.level
);


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

SELECT name FROM accounts AS cust
WHERE amount > (
    SELECT MIN(value) FROM products AS srvc
    WHERE srvc.id = cust.id
);


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

SELECT code FROM regions AS txn
WHERE value > (
    SELECT AVG(value) FROM warehouses AS shp
    WHERE shp.code = txn.code
);


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

SELECT amount FROM categories AS prod
WHERE status IN (
    SELECT status FROM customers AS empl
    WHERE empl.type = prod.type
);


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

SELECT name FROM employees AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.type = catg.type
);


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

SELECT amount FROM warehouses AS prod
WHERE salary > (
    SELECT MIN(amount) FROM customers AS whs
    WHERE whs.id = prod.id
);


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

SELECT name FROM suppliers AS catg
WHERE status IN (
    SELECT status FROM warehouses AS cust
    WHERE cust.status = catg.status
);


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

SELECT name FROM projects AS cust
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS dept
    WHERE dept.id = cust.id
);


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

SELECT code FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.id = srvc.id
);


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

SELECT salary FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.id = whs.id
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT COUNT(value) FROM tasks AS ordr
    WHERE ordr.status = txn.status
);


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

SELECT amount FROM categories AS acct
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS cust
    WHERE cust.status = acct.status
);


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

SELECT code FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.type = srvc.type
);


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

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


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

SELECT value FROM branches AS dept
WHERE value > (
    SELECT AVG(value) FROM tasks AS empl
    WHERE empl.code = dept.code
);


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

SELECT value FROM accounts AS ordr
WHERE amount > (
    SELECT MAX(value) FROM suppliers AS acct
    WHERE acct.level = ordr.level
);


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

SELECT code FROM products AS dept
WHERE id IN (
    SELECT id FROM tasks AS cust
    WHERE cust.id = dept.id
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.type = budg.type
);


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

SELECT amount FROM suppliers AS catg
WHERE code IN (
    SELECT code FROM orders AS budg
    WHERE budg.code = catg.code
);


Prompt:
Schema:
  projects (alias: rgn)(code, date, name, level)
  tasks(level, code, id, value)
Task: Retrieve code from projects with salary above the MIN(value) of tasks rows sharing the same id.
SQL:

SELECT code FROM projects AS rgn
WHERE salary > (
    SELECT MIN(value) FROM tasks AS sale
    WHERE sale.id = rgn.id
);


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

SELECT id FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.type = catg.type
);


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

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


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

SELECT id FROM invoices AS dept
WHERE id IN (
    SELECT id FROM categories AS prod
    WHERE prod.id = dept.id
);


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

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


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

SELECT amount FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.status = whs.status
);


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

SELECT name FROM branches AS emp
WHERE status IN (
    SELECT status FROM regions AS acct
    WHERE acct.id = emp.id
);


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

SELECT salary FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT id FROM invoices AS prod
WHERE salary > (
    SELECT SUM(salary) FROM tasks AS srvc
    WHERE srvc.status = prod.status
);


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

SELECT amount FROM regions AS acct
WHERE id IN (
    SELECT id FROM accounts AS cust
    WHERE cust.code = acct.code
);


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

SELECT id FROM shipments AS dept
WHERE code IN (
    SELECT code FROM customers AS txn
    WHERE txn.id = dept.id
);


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

SELECT amount FROM projects AS emp
WHERE value > (
    SELECT SUM(value) FROM invoices AS empl
    WHERE empl.type = emp.type
);


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

SELECT id FROM categories AS ord
WHERE value > (
    SELECT COUNT(amount) FROM invoices AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT name FROM projects AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.type = acct.type
);


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

SELECT salary FROM shipments AS acct
WHERE type IN (
    SELECT type FROM regions AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT code FROM categories AS ordr
WHERE value > (
    SELECT MAX(value) FROM departments AS acct
    WHERE acct.status = ordr.status
);


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

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


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

SELECT value FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT id FROM suppliers AS mgr
WHERE value > (
    SELECT AVG(value) FROM tasks AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT amount FROM categories AS sale
WHERE salary > (
    SELECT AVG(salary) FROM customers AS ord
    WHERE ord.status = sale.status
);


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

SELECT name FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.id = ordr.id
);