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

SELECT name FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.status = ordr.status
);


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

SELECT value FROM projects AS acct
WHERE status IN (
    SELECT status FROM regions AS empl
    WHERE empl.code = acct.code
);


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

SELECT value FROM shipments AS prod
WHERE status IN (
    SELECT status FROM suppliers AS shp
    WHERE shp.status = prod.status
);


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

SELECT code FROM suppliers AS mgr
WHERE level IN (
    SELECT level FROM regions AS txn
    WHERE txn.level = mgr.level
);


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

SELECT code FROM customers AS budg
WHERE value > (
    SELECT MAX(value) FROM products AS srvc
    WHERE srvc.id = budg.id
);


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

SELECT value FROM products AS prod
WHERE value > (
    SELECT SUM(amount) FROM customers AS dept
    WHERE dept.id = prod.id
);


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

SELECT salary FROM branches AS ord
WHERE status IN (
    SELECT status FROM transactions AS emp
    WHERE emp.status = ord.status
);


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

SELECT id FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.level = inv.level
);


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.code = empl.code
);


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

SELECT id FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.code = whs.code
);


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

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


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

SELECT code FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.type = txn.type
);


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

SELECT name FROM departments AS shp
WHERE id IN (
    SELECT id FROM projects AS emp
    WHERE emp.status = shp.status
);


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

SELECT id FROM products AS inv
WHERE id IN (
    SELECT id FROM branches AS budg
    WHERE budg.type = inv.type
);


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

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


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

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


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

SELECT value FROM warehouses AS ordr
WHERE code IN (
    SELECT code FROM suppliers AS catg
    WHERE catg.status = ordr.status
);


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

SELECT salary FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT salary FROM employees AS mgr
WHERE id IN (
    SELECT id FROM accounts AS emp
    WHERE emp.id = mgr.id
);


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

SELECT salary FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = dept.level
);


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

SELECT amount FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.id = schd.id
);


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

SELECT salary FROM branches AS shp
WHERE amount > (
    SELECT AVG(salary) FROM employees AS budg
    WHERE budg.level = shp.level
);


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

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


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

SELECT code FROM suppliers AS ord
WHERE amount > (
    SELECT MIN(value) FROM tasks AS shp
    WHERE shp.type = ord.type
);


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

SELECT salary FROM invoices AS mgr
WHERE status IN (
    SELECT status FROM regions AS lne
    WHERE lne.type = mgr.type
);


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

SELECT value FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.level = srvc.level
);


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

SELECT code FROM projects AS catg
WHERE amount > (
    SELECT COUNT(value) FROM branches AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT code FROM orders AS rgn
WHERE status IN (
    SELECT status FROM branches AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT value FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT amount FROM warehouses AS acct
WHERE type IN (
    SELECT type FROM accounts AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT amount FROM transactions AS lne
WHERE amount > (
    SELECT MAX(value) FROM products AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT code FROM branches AS ordr
WHERE value > (
    SELECT COUNT(value) FROM projects AS prod
    WHERE prod.status = ordr.status
);


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

SELECT salary FROM regions AS dept
WHERE salary > (
    SELECT MIN(value) FROM accounts AS sale
    WHERE sale.id = dept.id
);


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

SELECT id FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = cust.type
);


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

SELECT name FROM products AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS dept
    WHERE dept.type = lne.type
);


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

SELECT value FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.status = emp.status
);


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

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


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

SELECT salary FROM employees AS mgr
WHERE level IN (
    SELECT level FROM suppliers AS cust
    WHERE cust.code = mgr.code
);


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

SELECT value FROM accounts AS rgn
WHERE type IN (
    SELECT type FROM orders AS cust
    WHERE cust.type = rgn.type
);


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

SELECT name FROM projects AS prod
WHERE salary > (
    SELECT COUNT(value) FROM branches AS inv
    WHERE inv.type = prod.type
);


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

SELECT code FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT name FROM employees AS sale
WHERE status IN (
    SELECT status FROM products AS cust
    WHERE cust.level = sale.level
);


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

SELECT id FROM projects AS srvc
WHERE level IN (
    SELECT level FROM categories AS budg
    WHERE budg.id = srvc.id
);


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

SELECT value FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.type = srvc.type
);


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

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


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

SELECT salary FROM shipments AS inv
WHERE amount > (
    SELECT SUM(value) FROM products AS shp
    WHERE shp.level = inv.level
);


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

SELECT amount FROM customers AS rgn
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS catg
    WHERE catg.id = rgn.id
);


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

SELECT name FROM transactions AS catg
WHERE id IN (
    SELECT id FROM warehouses AS ord
    WHERE ord.id = catg.id
);


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

SELECT salary FROM tasks AS budg
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS inv
    WHERE inv.id = budg.id
);


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

SELECT name FROM tasks AS catg
WHERE level IN (
    SELECT level FROM accounts AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.type = shp.type
);


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

SELECT code FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.type = sale.type
);


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

SELECT amount FROM invoices AS empl
WHERE id IN (
    SELECT id FROM categories AS whs
    WHERE whs.id = empl.id
);


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

SELECT name FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.code = ordr.code
);


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

SELECT name FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.type = whs.type
);


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

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


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

SELECT amount FROM accounts AS empl
WHERE status IN (
    SELECT status FROM departments AS txn
    WHERE txn.type = empl.type
);


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

SELECT value FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS shp
    WHERE shp.status = catg.status
);


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

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


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

SELECT amount FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.type = budg.type
);


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

SELECT amount FROM employees AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = inv.type
);


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

SELECT code FROM employees AS schd
WHERE id IN (
    SELECT id FROM categories AS shp
    WHERE shp.level = schd.level
);


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

SELECT amount FROM transactions AS acct
WHERE value > (
    SELECT MIN(amount) FROM invoices AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT name FROM invoices AS mgr
WHERE level IN (
    SELECT level FROM employees AS whs
    WHERE whs.id = mgr.id
);


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

SELECT salary FROM warehouses AS shp
WHERE salary > (
    SELECT MAX(salary) FROM branches AS dept
    WHERE dept.status = shp.status
);


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

SELECT id FROM projects AS ordr
WHERE type IN (
    SELECT type FROM tasks AS dept
    WHERE dept.code = ordr.code
);


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

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


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

SELECT name FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.status = sale.status
);


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

SELECT name FROM transactions AS inv
WHERE status IN (
    SELECT status FROM branches AS lne
    WHERE lne.level = inv.level
);


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

SELECT value FROM projects AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM employees AS budg
    WHERE budg.id = srvc.id
);


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

SELECT salary FROM categories AS empl
WHERE salary > (
    SELECT SUM(amount) FROM products AS inv
    WHERE inv.status = empl.status
);


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

SELECT name FROM tasks AS emp
WHERE code IN (
    SELECT code FROM invoices AS lne
    WHERE lne.id = emp.id
);


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

SELECT amount FROM regions AS empl
WHERE id IN (
    SELECT id FROM accounts AS lne
    WHERE lne.status = empl.status
);


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

SELECT code FROM departments AS mgr
WHERE code IN (
    SELECT code FROM suppliers AS dept
    WHERE dept.code = mgr.code
);


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

SELECT salary FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.id = srvc.id
);


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

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


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

SELECT id FROM shipments AS empl
WHERE id IN (
    SELECT id FROM suppliers AS lne
    WHERE lne.type = empl.type
);


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

SELECT code FROM transactions AS cust
WHERE value > (
    SELECT MIN(value) FROM warehouses AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.code = empl.code
);


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

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


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

SELECT amount FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.type = schd.type
);


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

SELECT amount FROM departments AS cust
WHERE type IN (
    SELECT type FROM accounts AS catg
    WHERE catg.id = cust.id
);


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

SELECT id FROM categories AS lne
WHERE status IN (
    SELECT status FROM invoices AS ord
    WHERE ord.code = lne.code
);


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

SELECT code FROM tasks AS schd
WHERE salary > (
    SELECT COUNT(value) FROM customers AS rgn
    WHERE rgn.status = schd.status
);


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

SELECT value FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.id = whs.id
);


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

SELECT name FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.status = dept.status
);


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

SELECT value FROM shipments AS dept
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.type = dept.type
);


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

SELECT value FROM regions AS budg
WHERE type IN (
    SELECT type FROM suppliers AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT code FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.id = dept.id
);


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

SELECT name FROM projects AS inv
WHERE level IN (
    SELECT level FROM products AS srvc
    WHERE srvc.level = inv.level
);


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

SELECT code FROM products AS emp
WHERE level IN (
    SELECT level FROM branches AS empl
    WHERE empl.type = emp.type
);


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

SELECT code FROM transactions AS budg
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS catg
    WHERE catg.id = budg.id
);


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

SELECT amount FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.level = sale.level
);


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

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


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

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


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

SELECT code FROM regions AS emp
WHERE value > (
    SELECT SUM(salary) FROM invoices AS empl
    WHERE empl.code = emp.code
);


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

SELECT code FROM transactions AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = shp.type
);


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

SELECT id FROM projects AS prod
WHERE status IN (
    SELECT status FROM shipments AS schd
    WHERE schd.code = prod.code
);


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

SELECT code FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.id = ordr.id
);


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

SELECT salary FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.level = sale.level
);


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

SELECT value FROM shipments AS catg
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS budg
    WHERE budg.id = catg.id
);


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

SELECT salary FROM employees AS ord
WHERE type IN (
    SELECT type FROM transactions AS inv
    WHERE inv.level = ord.level
);


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

SELECT name FROM warehouses AS srvc
WHERE amount > (
    SELECT COUNT(salary) FROM employees AS emp
    WHERE emp.id = srvc.id
);


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

SELECT amount FROM suppliers AS mgr
WHERE type IN (
    SELECT type FROM branches AS budg
    WHERE budg.status = mgr.status
);


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

SELECT value FROM departments AS ord
WHERE level IN (
    SELECT level FROM regions AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT amount FROM employees AS empl
WHERE id IN (
    SELECT id FROM categories AS cust
    WHERE cust.level = empl.level
);


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

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


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

SELECT id FROM suppliers AS sale
WHERE salary > (
    SELECT MIN(salary) FROM employees AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT value FROM employees AS dept
WHERE status IN (
    SELECT status FROM products AS whs
    WHERE whs.id = dept.id
);


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

SELECT id FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.status = ord.status
);


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

SELECT salary FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.level = ordr.level
);


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

SELECT amount FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.level = shp.level
);


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

SELECT salary FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.type = srvc.type
);


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

SELECT code FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.status = empl.status
);


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

SELECT code FROM products AS budg
WHERE code IN (
    SELECT code FROM invoices AS shp
    WHERE shp.level = budg.level
);


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

SELECT amount FROM projects AS srvc
WHERE status IN (
    SELECT status FROM invoices AS budg
    WHERE budg.level = srvc.level
);


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

SELECT code FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.id = catg.id
);


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

SELECT id FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.code = dept.code
);


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

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


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

SELECT amount FROM projects AS cust
WHERE salary > (
    SELECT AVG(value) FROM transactions AS schd
    WHERE schd.status = cust.status
);


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

SELECT code FROM transactions AS catg
WHERE level IN (
    SELECT level FROM invoices AS emp
    WHERE emp.level = catg.level
);


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

SELECT salary FROM regions AS schd
WHERE id IN (
    SELECT id FROM shipments AS whs
    WHERE whs.type = schd.type
);


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

SELECT salary FROM projects AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS acct
    WHERE acct.code = schd.code
);


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

SELECT value FROM tasks AS sale
WHERE value > (
    SELECT MAX(amount) FROM branches AS shp
    WHERE shp.id = sale.id
);


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

SELECT amount FROM tasks AS catg
WHERE salary > (
    SELECT AVG(value) FROM accounts AS budg
    WHERE budg.level = catg.level
);


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

SELECT value FROM tasks AS inv
WHERE code IN (
    SELECT code FROM warehouses AS ordr
    WHERE ordr.code = inv.code
);


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

SELECT code FROM branches AS ordr
WHERE status IN (
    SELECT status FROM transactions AS schd
    WHERE schd.id = ordr.id
);


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

SELECT value FROM regions AS srvc
WHERE level IN (
    SELECT level FROM shipments AS ordr
    WHERE ordr.type = srvc.type
);


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

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


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

SELECT amount FROM warehouses AS mgr
WHERE id IN (
    SELECT id FROM suppliers AS prod
    WHERE prod.code = mgr.code
);


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

SELECT name FROM transactions AS srvc
WHERE value > (
    SELECT AVG(value) FROM products AS ord
    WHERE ord.code = srvc.code
);


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

SELECT code FROM branches AS sale
WHERE code IN (
    SELECT code FROM products AS cust
    WHERE cust.id = sale.id
);


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

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


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

SELECT id FROM suppliers AS prod
WHERE code IN (
    SELECT code FROM accounts AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT code FROM regions AS shp
WHERE status IN (
    SELECT status FROM departments AS inv
    WHERE inv.code = shp.code
);


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

SELECT salary FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.level = dept.level
);


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

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


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

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


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

SELECT code FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.type = whs.type
);


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

SELECT code FROM regions AS shp
WHERE value > (
    SELECT MIN(value) FROM invoices AS emp
    WHERE emp.code = shp.code
);


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

SELECT salary FROM regions AS inv
WHERE level IN (
    SELECT level FROM orders AS sale
    WHERE sale.type = inv.type
);


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

SELECT id FROM shipments AS mgr
WHERE id IN (
    SELECT id FROM categories AS budg
    WHERE budg.status = mgr.status
);


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

SELECT salary FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.level = ord.level
);


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

SELECT name FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.code = cust.code
);


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

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


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

SELECT amount FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.status = mgr.status
);


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

SELECT salary FROM invoices AS dept
WHERE status IN (
    SELECT status FROM transactions AS acct
    WHERE acct.type = dept.type
);


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

SELECT salary FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.type = budg.type
);


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

SELECT name FROM projects AS acct
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.status = acct.status
);


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

SELECT amount FROM products AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.id = txn.id
);


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

SELECT name FROM shipments AS srvc
WHERE status IN (
    SELECT status FROM branches AS lne
    WHERE lne.status = srvc.status
);


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

SELECT code FROM accounts AS schd
WHERE type IN (
    SELECT type FROM orders AS dept
    WHERE dept.id = schd.id
);


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

SELECT value FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS cust
    WHERE cust.status = catg.status
);


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

SELECT salary FROM transactions AS cust
WHERE amount > (
    SELECT SUM(amount) FROM departments AS emp
    WHERE emp.type = cust.type
);


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

SELECT code FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.level = cust.level
);


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

SELECT code FROM products AS empl
WHERE amount > (
    SELECT MIN(value) FROM regions AS dept
    WHERE dept.type = empl.type
);


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

SELECT amount FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.code = catg.code
);


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

SELECT name FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.id = whs.id
);


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

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


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

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


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

SELECT amount FROM suppliers AS prod
WHERE salary > (
    SELECT AVG(value) FROM warehouses AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT amount FROM customers AS lne
WHERE level IN (
    SELECT level FROM invoices AS shp
    WHERE shp.level = lne.level
);


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

SELECT code FROM transactions AS srvc
WHERE value > (
    SELECT SUM(value) FROM accounts AS budg
    WHERE budg.type = srvc.type
);


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

SELECT amount FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT amount FROM transactions AS empl
WHERE level IN (
    SELECT level FROM products AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT amount FROM products AS budg
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS emp
    WHERE emp.type = budg.type
);


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

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


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

SELECT code FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.id = cust.id
);


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

SELECT salary FROM transactions AS inv
WHERE amount > (
    SELECT AVG(value) FROM products AS emp
    WHERE emp.code = inv.code
);


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

SELECT amount FROM regions AS cust
WHERE salary > (
    SELECT MIN(value) FROM projects AS txn
    WHERE txn.level = cust.level
);


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

SELECT amount FROM shipments AS whs
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT value FROM branches AS catg
WHERE value > (
    SELECT COUNT(amount) FROM invoices AS schd
    WHERE schd.code = catg.code
);


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

SELECT name FROM projects AS acct
WHERE salary > (
    SELECT SUM(value) FROM employees AS sale
    WHERE sale.type = acct.type
);


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

SELECT code FROM branches AS whs
WHERE type IN (
    SELECT type FROM invoices AS sale
    WHERE sale.type = whs.type
);


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

SELECT amount FROM regions AS whs
WHERE value > (
    SELECT SUM(salary) FROM categories AS lne
    WHERE lne.type = whs.type
);


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

SELECT value FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.code = emp.code
);


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

SELECT code FROM invoices AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS whs
    WHERE whs.code = empl.code
);


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

SELECT id FROM regions AS rgn
WHERE level IN (
    SELECT level FROM customers AS whs
    WHERE whs.type = rgn.type
);


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

SELECT amount FROM tasks AS cust
WHERE type IN (
    SELECT type FROM regions AS sale
    WHERE sale.code = cust.code
);


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

SELECT salary FROM shipments AS shp
WHERE salary > (
    SELECT SUM(value) FROM invoices AS dept
    WHERE dept.level = shp.level
);


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

SELECT value FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.level = mgr.level
);


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

SELECT code FROM transactions AS prod
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.level = prod.level
);


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

SELECT amount FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = budg.level
);


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

SELECT id FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.type = budg.type
);


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

SELECT name FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.level = mgr.level
);


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

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


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

SELECT name FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.level = shp.level
);


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

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


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.type = inv.type
);


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

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


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

SELECT salary FROM shipments AS shp
WHERE value > (
    SELECT AVG(amount) FROM transactions AS budg
    WHERE budg.level = shp.level
);


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

SELECT salary FROM warehouses AS sale
WHERE salary > (
    SELECT MAX(amount) FROM suppliers AS cust
    WHERE cust.code = sale.code
);


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

SELECT code FROM shipments AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS sale
    WHERE sale.status = catg.status
);


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

SELECT code FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.code = lne.code
);


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

SELECT code FROM customers AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.type = catg.type
);


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

SELECT code FROM tasks AS txn
WHERE amount > (
    SELECT COUNT(value) FROM orders AS shp
    WHERE shp.code = txn.code
);


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

SELECT value FROM branches AS shp
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.type = shp.type
);


Prompt:
Schema:
  projects (alias: txn)(level, name, amount, salary)
  regions(name, id, status, level)
Task: Retrieve amount from projects with amount above the MIN(amount) of regions rows sharing the same status.
SQL:

SELECT amount FROM projects AS txn
WHERE amount > (
    SELECT MIN(amount) FROM regions AS prod
    WHERE prod.status = txn.status
);


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

SELECT id FROM tasks AS shp
WHERE salary > (
    SELECT MAX(salary) FROM orders AS ordr
    WHERE ordr.type = shp.type
);


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

SELECT code FROM customers AS ord
WHERE status IN (
    SELECT status FROM categories AS prod
    WHERE prod.id = ord.id
);


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

SELECT amount FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.level = sale.level
);


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

SELECT salary FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = cust.type
);


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

SELECT salary FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.code = cust.code
);


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

SELECT value FROM transactions AS sale
WHERE type IN (
    SELECT type FROM orders AS catg
    WHERE catg.code = sale.code
);


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

SELECT id FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.type = empl.type
);


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

SELECT amount FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.type = whs.type
);


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

SELECT code FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.status = budg.status
);


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

SELECT name FROM orders AS mgr
WHERE level IN (
    SELECT level FROM accounts AS ord
    WHERE ord.id = mgr.id
);


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

SELECT amount FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.code = acct.code
);


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

SELECT id FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.code = rgn.code
);


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

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


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

SELECT id FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.type = dept.type
);


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

SELECT amount FROM invoices AS whs
WHERE code IN (
    SELECT code FROM products AS srvc
    WHERE srvc.status = whs.status
);


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

SELECT salary FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.code = ordr.code
);


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

SELECT code FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = emp.status
);


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.level = dept.level
);


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

SELECT amount FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.code = txn.code
);


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

SELECT amount FROM tasks AS dept
WHERE salary > (
    SELECT SUM(salary) FROM orders AS whs
    WHERE whs.id = dept.id
);


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

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


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

SELECT amount FROM departments AS schd
WHERE code IN (
    SELECT code FROM suppliers AS prod
    WHERE prod.type = schd.type
);


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

SELECT name FROM shipments AS txn
WHERE type IN (
    SELECT type FROM branches AS srvc
    WHERE srvc.id = txn.id
);


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

SELECT salary FROM departments AS sale
WHERE amount > (
    SELECT COUNT(value) FROM warehouses AS budg
    WHERE budg.level = sale.level
);


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

SELECT salary FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = mgr.status
);


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

SELECT id FROM transactions AS budg
WHERE type IN (
    SELECT type FROM branches AS txn
    WHERE txn.type = budg.type
);


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

SELECT name FROM orders AS emp
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT amount FROM categories AS whs
WHERE type IN (
    SELECT type FROM suppliers AS cust
    WHERE cust.id = whs.id
);


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

SELECT value FROM shipments AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.status = ord.status
);


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

SELECT salary FROM warehouses AS ordr
WHERE level IN (
    SELECT level FROM departments AS lne
    WHERE lne.status = ordr.status
);


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

SELECT amount FROM regions AS inv
WHERE value > (
    SELECT MIN(amount) FROM departments AS whs
    WHERE whs.code = inv.code
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS ord
    WHERE ord.level = acct.level
);


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

SELECT salary FROM categories AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.status = dept.status
);


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

SELECT name FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.id = shp.id
);


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

SELECT amount FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.type = sale.type
);


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

SELECT name FROM employees AS whs
WHERE value > (
    SELECT AVG(value) FROM tasks AS srvc
    WHERE srvc.id = whs.id
);


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

SELECT code FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.code = emp.code
);


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

SELECT amount FROM orders AS sale
WHERE code IN (
    SELECT code FROM shipments AS schd
    WHERE schd.code = sale.code
);


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

SELECT salary FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.code = inv.code
);


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

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


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

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


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

SELECT value FROM products AS rgn
WHERE salary > (
    SELECT COUNT(value) FROM categories AS acct
    WHERE acct.level = rgn.level
);


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

SELECT value FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.status = catg.status
);


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

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


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

SELECT salary FROM warehouses AS catg
WHERE id IN (
    SELECT id FROM suppliers AS inv
    WHERE inv.type = catg.type
);


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

SELECT value FROM tasks AS acct
WHERE id IN (
    SELECT id FROM accounts AS budg
    WHERE budg.level = acct.level
);


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

SELECT amount FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.status = rgn.status
);


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

SELECT value FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.status = emp.status
);


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

SELECT salary FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.level = budg.level
);


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

SELECT value FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.level = budg.level
);


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

SELECT id FROM suppliers AS rgn
WHERE id IN (
    SELECT id FROM employees AS budg
    WHERE budg.status = rgn.status
);


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

SELECT value FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.code = rgn.code
);


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

SELECT id FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.type = inv.type
);


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

SELECT name FROM suppliers AS emp
WHERE value > (
    SELECT MAX(value) FROM customers AS catg
    WHERE catg.level = emp.level
);


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

SELECT id FROM projects AS budg
WHERE level IN (
    SELECT level FROM warehouses AS acct
    WHERE acct.type = budg.type
);


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

SELECT code FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.status = catg.status
);


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

SELECT amount FROM accounts AS mgr
WHERE type IN (
    SELECT type FROM orders AS empl
    WHERE empl.code = mgr.code
);


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

SELECT code FROM employees AS srvc
WHERE status IN (
    SELECT status FROM accounts AS sale
    WHERE sale.id = srvc.id
);


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

SELECT code FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.level = ord.level
);


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

SELECT salary FROM transactions AS rgn
WHERE amount > (
    SELECT MAX(amount) FROM branches AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT value FROM invoices AS dept
WHERE id IN (
    SELECT id FROM transactions AS whs
    WHERE whs.status = dept.status
);


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

SELECT id FROM customers AS empl
WHERE status IN (
    SELECT status FROM branches AS lne
    WHERE lne.status = empl.status
);


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

SELECT name FROM employees AS srvc
WHERE level IN (
    SELECT level FROM categories AS ordr
    WHERE ordr.type = srvc.type
);


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

SELECT id FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.type = rgn.type
);


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

SELECT code FROM departments AS sale
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS prod
    WHERE prod.status = sale.status
);


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

SELECT salary FROM products AS prod
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.type = prod.type
);


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

SELECT name FROM orders AS mgr
WHERE status IN (
    SELECT status FROM transactions AS lne
    WHERE lne.status = mgr.status
);


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

SELECT amount FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.status = budg.status
);


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

SELECT code FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.status = dept.status
);


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

SELECT value FROM accounts AS budg
WHERE salary > (
    SELECT MIN(value) FROM orders AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT value FROM employees AS empl
WHERE amount > (
    SELECT AVG(salary) FROM products AS ord
    WHERE ord.code = empl.code
);


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

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


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

SELECT amount FROM customers AS dept
WHERE status IN (
    SELECT status FROM warehouses AS shp
    WHERE shp.level = dept.level
);


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

SELECT salary FROM accounts AS dept
WHERE value > (
    SELECT AVG(value) FROM projects AS cust
    WHERE cust.status = dept.status
);


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

SELECT amount FROM invoices AS dept
WHERE salary > (
    SELECT AVG(value) FROM categories AS lne
    WHERE lne.level = dept.level
);


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

SELECT code FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.status = rgn.status
);


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

SELECT name FROM warehouses AS prod
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS shp
    WHERE shp.level = prod.level
);


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

SELECT name FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.level = catg.level
);


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

SELECT code FROM warehouses AS txn
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS empl
    WHERE empl.status = txn.status
);


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

SELECT salary FROM regions AS acct
WHERE value > (
    SELECT MIN(value) FROM categories AS inv
    WHERE inv.code = acct.code
);


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

SELECT amount FROM shipments AS lne
WHERE salary > (
    SELECT MAX(value) FROM employees AS ord
    WHERE ord.code = lne.code
);


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

SELECT salary FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = ord.id
);


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

SELECT value FROM accounts AS inv
WHERE salary > (
    SELECT SUM(value) FROM suppliers AS cust
    WHERE cust.level = inv.level
);


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

SELECT value FROM accounts AS whs
WHERE amount > (
    SELECT MAX(amount) FROM departments AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT value FROM invoices AS txn
WHERE type IN (
    SELECT type FROM departments AS catg
    WHERE catg.level = txn.level
);


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

SELECT code FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.type = emp.type
);


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

SELECT name FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.id = lne.id
);


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

SELECT id FROM accounts AS catg
WHERE type IN (
    SELECT type FROM shipments AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT amount FROM projects AS empl
WHERE level IN (
    SELECT level FROM accounts AS emp
    WHERE emp.code = empl.code
);


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

SELECT value FROM employees AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM projects AS mgr
    WHERE mgr.type = whs.type
);


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

SELECT value FROM employees AS ordr
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS cust
    WHERE cust.status = ordr.status
);


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

SELECT salary FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.status = catg.status
);


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

SELECT amount FROM shipments AS mgr
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS cust
    WHERE cust.code = mgr.code
);


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

SELECT amount FROM employees AS empl
WHERE value > (
    SELECT COUNT(amount) FROM projects AS prod
    WHERE prod.status = empl.status
);


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

SELECT salary FROM customers AS emp
WHERE id IN (
    SELECT id FROM categories AS txn
    WHERE txn.type = emp.type
);