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

SELECT amount FROM orders AS cust
WHERE status IN (
    SELECT status FROM projects AS schd
    WHERE schd.code = cust.code
);


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

SELECT amount FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT id FROM orders AS whs
WHERE salary > (
    SELECT AVG(salary) FROM shipments AS ord
    WHERE ord.type = whs.type
);


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

SELECT salary FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.code = emp.code
);


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

SELECT code FROM orders AS dept
WHERE type IN (
    SELECT type FROM products AS shp
    WHERE shp.type = dept.type
);


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

SELECT value FROM warehouses AS whs
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS ord
    WHERE ord.level = whs.level
);


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

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


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

SELECT code FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.type = sale.type
);


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

SELECT name FROM employees AS lne
WHERE value > (
    SELECT MIN(salary) FROM shipments AS prod
    WHERE prod.id = lne.id
);


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

SELECT code FROM departments AS mgr
WHERE id IN (
    SELECT id FROM branches AS txn
    WHERE txn.type = mgr.type
);


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

SELECT amount FROM departments AS txn
WHERE id IN (
    SELECT id FROM regions AS schd
    WHERE schd.id = txn.id
);


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

SELECT name FROM invoices AS emp
WHERE type IN (
    SELECT type FROM accounts AS ordr
    WHERE ordr.status = emp.status
);


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

SELECT amount FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.type = srvc.type
);


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

SELECT value FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.code = schd.code
);


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

SELECT name FROM categories AS ord
WHERE salary > (
    SELECT AVG(salary) FROM projects AS cust
    WHERE cust.status = ord.status
);


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

SELECT code FROM invoices AS txn
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS shp
    WHERE shp.id = txn.id
);


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

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


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

SELECT value FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.code = inv.code
);


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

SELECT value FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.code = rgn.code
);


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

SELECT salary FROM transactions AS lne
WHERE type IN (
    SELECT type FROM categories AS schd
    WHERE schd.type = lne.type
);


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

SELECT value FROM products AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.status = rgn.status
);


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

SELECT amount FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.id = sale.id
);


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

SELECT name FROM shipments AS ordr
WHERE status IN (
    SELECT status FROM warehouses AS shp
    WHERE shp.type = ordr.type
);


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

SELECT id FROM products AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.status = catg.status
);


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

SELECT salary FROM accounts AS lne
WHERE value > (
    SELECT COUNT(value) FROM orders AS inv
    WHERE inv.type = lne.type
);


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

SELECT salary FROM invoices AS acct
WHERE code IN (
    SELECT code FROM orders AS budg
    WHERE budg.status = acct.status
);


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

SELECT value FROM suppliers AS whs
WHERE id IN (
    SELECT id FROM projects AS dept
    WHERE dept.status = whs.status
);


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

SELECT salary FROM regions AS shp
WHERE value > (
    SELECT MIN(value) FROM accounts AS ord
    WHERE ord.status = shp.status
);


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

SELECT name FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.status = acct.status
);


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

SELECT salary FROM tasks AS budg
WHERE status IN (
    SELECT status FROM suppliers AS sale
    WHERE sale.id = budg.id
);


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

SELECT salary FROM projects AS inv
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.code = inv.code
);


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

SELECT amount FROM shipments AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS schd
    WHERE schd.status = whs.status
);


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

SELECT salary FROM projects AS dept
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS budg
    WHERE budg.id = dept.id
);


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

SELECT id FROM departments AS dept
WHERE code IN (
    SELECT code FROM shipments AS rgn
    WHERE rgn.code = dept.code
);


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

SELECT id FROM branches AS srvc
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS budg
    WHERE budg.level = srvc.level
);


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

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


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

SELECT value FROM transactions AS emp
WHERE status IN (
    SELECT status FROM warehouses AS catg
    WHERE catg.status = emp.status
);


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

SELECT amount FROM accounts AS prod
WHERE value > (
    SELECT AVG(value) FROM shipments AS mgr
    WHERE mgr.type = prod.type
);


Prompt:
Schema:
  shipments (alias: srvc)(status, date, id, salary)
  accounts(level, date, name, id)
Task: Retrieve value from shipments with value above the MIN(value) of accounts rows sharing the same status.
SQL:

SELECT value FROM shipments AS srvc
WHERE value > (
    SELECT MIN(value) FROM accounts AS catg
    WHERE catg.status = srvc.status
);


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

SELECT id FROM customers AS budg
WHERE type IN (
    SELECT type FROM tasks AS empl
    WHERE empl.type = budg.type
);


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

SELECT amount FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS lne
    WHERE lne.level = budg.level
);


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

SELECT name FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = mgr.type
);


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

SELECT salary FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = mgr.status
);


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

SELECT name FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.code = rgn.code
);


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

SELECT id FROM regions AS lne
WHERE value > (
    SELECT SUM(value) FROM tasks AS sale
    WHERE sale.id = lne.id
);


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

SELECT code FROM warehouses AS sale
WHERE id IN (
    SELECT id FROM categories AS inv
    WHERE inv.id = sale.id
);


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

SELECT name FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.id = lne.id
);


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

SELECT value FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.status = emp.status
);


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

SELECT amount FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT name FROM tasks AS inv
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.level = inv.level
);


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

SELECT id FROM branches AS schd
WHERE level IN (
    SELECT level FROM projects AS ord
    WHERE ord.id = schd.id
);


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

SELECT value FROM tasks AS acct
WHERE level IN (
    SELECT level FROM employees AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT salary FROM employees AS srvc
WHERE level IN (
    SELECT level FROM shipments AS acct
    WHERE acct.level = srvc.level
);


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

SELECT value FROM customers AS prod
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.level = prod.level
);


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

SELECT value FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.status = ordr.status
);


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

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


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

SELECT id FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.code = catg.code
);


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

SELECT name FROM customers AS emp
WHERE value > (
    SELECT MIN(value) FROM invoices AS txn
    WHERE txn.id = emp.id
);


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

SELECT value FROM departments AS empl
WHERE amount > (
    SELECT MIN(value) FROM products AS sale
    WHERE sale.status = empl.status
);


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

SELECT salary FROM branches AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.status = srvc.status
);


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

SELECT value FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.id = ordr.id
);


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

SELECT amount FROM products AS prod
WHERE type IN (
    SELECT type FROM categories AS ordr
    WHERE ordr.type = prod.type
);


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

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


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

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


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

SELECT value FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.type = whs.type
);


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

SELECT value FROM customers AS budg
WHERE value > (
    SELECT MIN(salary) FROM tasks AS catg
    WHERE catg.code = budg.code
);


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.type = empl.type
);


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

SELECT code FROM suppliers AS empl
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.id = empl.id
);


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

SELECT id FROM transactions AS whs
WHERE salary > (
    SELECT SUM(salary) FROM products AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT salary FROM invoices AS shp
WHERE amount > (
    SELECT AVG(value) FROM projects AS inv
    WHERE inv.code = shp.code
);


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

SELECT salary FROM projects AS mgr
WHERE value > (
    SELECT MIN(value) FROM tasks AS acct
    WHERE acct.type = mgr.type
);


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

SELECT value FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.status = shp.status
);


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

SELECT salary FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.type = empl.type
);


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

SELECT salary FROM branches AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.type = ordr.type
);


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

SELECT name FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM employees AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT salary FROM projects AS mgr
WHERE value > (
    SELECT AVG(value) FROM accounts AS sale
    WHERE sale.code = mgr.code
);


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

SELECT value FROM suppliers AS acct
WHERE code IN (
    SELECT code FROM branches AS empl
    WHERE empl.type = acct.type
);


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

SELECT salary FROM categories AS srvc
WHERE id IN (
    SELECT id FROM departments AS sale
    WHERE sale.code = srvc.code
);


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

SELECT id FROM shipments AS shp
WHERE value > (
    SELECT MAX(salary) FROM regions AS catg
    WHERE catg.type = shp.type
);


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

SELECT name FROM invoices AS dept
WHERE value > (
    SELECT MAX(salary) FROM transactions AS shp
    WHERE shp.id = dept.id
);


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

SELECT amount FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.id = sale.id
);


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

SELECT id FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS ord
    WHERE ord.type = inv.type
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.status = ord.status
);


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

SELECT amount FROM warehouses AS ordr
WHERE amount > (
    SELECT SUM(salary) FROM categories AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT code FROM tasks AS acct
WHERE id IN (
    SELECT id FROM suppliers AS schd
    WHERE schd.status = acct.status
);


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

SELECT amount FROM transactions AS mgr
WHERE status IN (
    SELECT status FROM warehouses AS sale
    WHERE sale.type = mgr.type
);


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

SELECT id FROM invoices AS srvc
WHERE value > (
    SELECT SUM(value) FROM regions AS budg
    WHERE budg.id = srvc.id
);


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

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


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

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


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

SELECT amount FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.id = catg.id
);


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

SELECT code FROM projects AS sale
WHERE salary > (
    SELECT SUM(salary) FROM regions AS txn
    WHERE txn.code = sale.code
);


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

SELECT amount FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.code = budg.code
);


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

SELECT id FROM shipments AS ord
WHERE id IN (
    SELECT id FROM departments AS empl
    WHERE empl.id = ord.id
);


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

SELECT salary FROM categories AS dept
WHERE amount > (
    SELECT SUM(salary) FROM products AS catg
    WHERE catg.id = dept.id
);


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

SELECT amount FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.status = prod.status
);


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

SELECT id FROM regions AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS shp
    WHERE shp.status = inv.status
);


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

SELECT amount FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.status = emp.status
);


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

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


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

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


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

SELECT salary FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.id = dept.id
);


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

SELECT name FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.type = rgn.type
);


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

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


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

SELECT value FROM branches AS schd
WHERE salary > (
    SELECT AVG(salary) FROM products AS sale
    WHERE sale.level = schd.level
);


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

SELECT id FROM departments AS inv
WHERE value > (
    SELECT MAX(value) FROM projects AS emp
    WHERE emp.code = inv.code
);


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

SELECT id FROM shipments AS ordr
WHERE code IN (
    SELECT code FROM warehouses AS dept
    WHERE dept.type = ordr.type
);


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

SELECT id FROM invoices AS whs
WHERE type IN (
    SELECT type FROM suppliers AS emp
    WHERE emp.level = whs.level
);


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

SELECT amount FROM tasks AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT name FROM regions AS whs
WHERE level IN (
    SELECT level FROM employees AS cust
    WHERE cust.status = whs.status
);


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

SELECT salary FROM orders AS budg
WHERE status IN (
    SELECT status FROM shipments AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT id FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.type = srvc.type
);


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

SELECT name FROM suppliers AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM invoices AS schd
    WHERE schd.type = rgn.type
);


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

SELECT amount FROM projects AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT salary FROM categories AS whs
WHERE code IN (
    SELECT code FROM accounts AS shp
    WHERE shp.type = whs.type
);


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

SELECT salary FROM orders AS prod
WHERE type IN (
    SELECT type FROM warehouses AS budg
    WHERE budg.type = prod.type
);


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

SELECT amount FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.type = prod.type
);


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

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


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

SELECT salary FROM tasks AS cust
WHERE status IN (
    SELECT status FROM shipments AS schd
    WHERE schd.level = cust.level
);


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

SELECT code FROM accounts AS schd
WHERE value > (
    SELECT MIN(amount) FROM orders AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT id FROM accounts AS inv
WHERE id IN (
    SELECT id FROM products AS empl
    WHERE empl.type = inv.type
);


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

SELECT salary FROM regions AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS acct
    WHERE acct.status = schd.status
);


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

SELECT code FROM customers AS empl
WHERE level IN (
    SELECT level FROM invoices AS prod
    WHERE prod.level = empl.level
);


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

SELECT name FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.code = mgr.code
);


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

SELECT id FROM invoices AS acct
WHERE status IN (
    SELECT status FROM employees AS emp
    WHERE emp.level = acct.level
);


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

SELECT code FROM branches AS catg
WHERE level IN (
    SELECT level FROM invoices AS shp
    WHERE shp.status = catg.status
);


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

SELECT value FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.id = txn.id
);


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

SELECT value FROM suppliers AS prod
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT name FROM transactions AS ord
WHERE code IN (
    SELECT code FROM products AS lne
    WHERE lne.level = ord.level
);


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

SELECT code FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.type = schd.type
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.code = catg.code
);


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

SELECT id FROM tasks AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.id = cust.id
);


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

SELECT value FROM employees AS schd
WHERE code IN (
    SELECT code FROM accounts AS lne
    WHERE lne.type = schd.type
);


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

SELECT name FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT name FROM projects AS inv
WHERE value > (
    SELECT MIN(value) FROM accounts AS shp
    WHERE shp.level = inv.level
);


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

SELECT value FROM tasks AS mgr
WHERE type IN (
    SELECT type FROM customers AS budg
    WHERE budg.type = mgr.type
);


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

SELECT id FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.level = rgn.level
);


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

SELECT id FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.level = mgr.level
);


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

SELECT id FROM regions AS ordr
WHERE type IN (
    SELECT type FROM projects AS budg
    WHERE budg.type = ordr.type
);


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

SELECT name FROM suppliers AS acct
WHERE id IN (
    SELECT id FROM categories AS schd
    WHERE schd.level = acct.level
);


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

SELECT salary FROM regions AS inv
WHERE type IN (
    SELECT type FROM accounts AS txn
    WHERE txn.id = inv.id
);


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

SELECT value FROM regions AS empl
WHERE code IN (
    SELECT code FROM accounts AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT name FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.code = budg.code
);


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

SELECT name FROM customers AS acct
WHERE amount > (
    SELECT COUNT(amount) FROM departments AS prod
    WHERE prod.type = acct.type
);


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

SELECT code FROM transactions AS shp
WHERE id IN (
    SELECT id FROM employees AS empl
    WHERE empl.type = shp.type
);


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

SELECT salary FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.code = empl.code
);


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

SELECT value FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.status = rgn.status
);


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

SELECT id FROM suppliers AS acct
WHERE type IN (
    SELECT type FROM transactions AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT code FROM accounts AS shp
WHERE salary > (
    SELECT MAX(amount) FROM categories AS prod
    WHERE prod.level = shp.level
);


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

SELECT id FROM shipments AS sale
WHERE code IN (
    SELECT code FROM products AS budg
    WHERE budg.status = sale.status
);


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

SELECT id FROM tasks AS acct
WHERE salary > (
    SELECT MAX(value) FROM employees AS budg
    WHERE budg.status = acct.status
);


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

SELECT code FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.code = rgn.code
);


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

SELECT id FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS cust
    WHERE cust.type = prod.type
);


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

SELECT name FROM customers AS empl
WHERE salary > (
    SELECT MIN(value) FROM transactions AS budg
    WHERE budg.level = empl.level
);


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

SELECT name FROM shipments AS rgn
WHERE code IN (
    SELECT code FROM warehouses AS cust
    WHERE cust.type = rgn.type
);


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

SELECT value FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.id = whs.id
);


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

SELECT amount FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS shp
    WHERE shp.level = empl.level
);


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

SELECT id FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = shp.status
);


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

SELECT value FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.status = dept.status
);


Prompt:
Schema:
  orders (alias: schd)(status, salary, date, level)
  customers(salary, type, level, status)
Task: Retrieve name from orders with amount above the AVG(salary) of customers rows sharing the same level.
SQL:

SELECT name FROM orders AS schd
WHERE amount > (
    SELECT AVG(salary) FROM customers AS empl
    WHERE empl.level = schd.level
);


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

SELECT value FROM orders AS ordr
WHERE type IN (
    SELECT type FROM suppliers AS catg
    WHERE catg.id = ordr.id
);


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

SELECT name FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM transactions AS whs
    WHERE whs.status = mgr.status
);


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

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


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

SELECT name FROM transactions AS lne
WHERE code IN (
    SELECT code FROM warehouses AS empl
    WHERE empl.level = lne.level
);


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

SELECT value FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT amount FROM regions AS txn
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.id = txn.id
);


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

SELECT value FROM departments AS whs
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS sale
    WHERE sale.level = whs.level
);


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

SELECT name FROM projects AS lne
WHERE type IN (
    SELECT type FROM products AS inv
    WHERE inv.status = lne.status
);


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

SELECT code FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.status = acct.status
);


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

SELECT amount FROM projects AS srvc
WHERE id IN (
    SELECT id FROM products AS txn
    WHERE txn.code = srvc.code
);


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

SELECT name FROM employees AS ord
WHERE id IN (
    SELECT id FROM orders AS inv
    WHERE inv.status = ord.status
);


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

SELECT id FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.level = acct.level
);


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

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


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

SELECT name FROM projects AS prod
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS cust
    WHERE cust.id = prod.id
);


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

SELECT salary FROM products AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM orders AS schd
    WHERE schd.type = rgn.type
);


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

SELECT id FROM accounts AS schd
WHERE salary > (
    SELECT SUM(salary) FROM branches AS txn
    WHERE txn.id = schd.id
);


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

SELECT value FROM accounts AS dept
WHERE id IN (
    SELECT id FROM transactions AS sale
    WHERE sale.type = dept.type
);


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

SELECT salary FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.status = emp.status
);


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

SELECT amount FROM categories AS empl
WHERE salary > (
    SELECT SUM(salary) FROM regions AS ord
    WHERE ord.code = empl.code
);


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

SELECT code FROM suppliers AS txn
WHERE salary > (
    SELECT MIN(salary) FROM branches AS lne
    WHERE lne.level = txn.level
);


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

SELECT id FROM orders AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.level = budg.level
);


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

SELECT code FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.status = empl.status
);


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

SELECT code FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.status = acct.status
);


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

SELECT salary FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = mgr.type
);


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

SELECT salary FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.level = inv.level
);


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

SELECT salary FROM transactions AS ord
WHERE amount > (
    SELECT MAX(amount) FROM suppliers AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT value FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS txn
    WHERE txn.level = ord.level
);


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

SELECT name FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.code = acct.code
);


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

SELECT salary FROM employees AS inv
WHERE type IN (
    SELECT type FROM departments AS sale
    WHERE sale.code = inv.code
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.code = catg.code
);


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

SELECT value FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT name FROM suppliers AS dept
WHERE salary > (
    SELECT MIN(amount) FROM orders AS budg
    WHERE budg.level = dept.level
);


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

SELECT name FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.status = lne.status
);


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

SELECT name FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = catg.status
);


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

SELECT code FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM suppliers AS emp
    WHERE emp.status = whs.status
);


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

SELECT id FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.status = emp.status
);


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

SELECT salary FROM suppliers AS schd
WHERE level IN (
    SELECT level FROM regions AS emp
    WHERE emp.id = schd.id
);


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

SELECT amount FROM branches AS sale
WHERE value > (
    SELECT MAX(amount) FROM departments AS catg
    WHERE catg.status = sale.status
);


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

SELECT id FROM products AS cust
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS shp
    WHERE shp.level = cust.level
);


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

SELECT code FROM transactions AS srvc
WHERE code IN (
    SELECT code FROM shipments AS ordr
    WHERE ordr.level = srvc.level
);


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

SELECT salary FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.status = acct.status
);


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

SELECT id FROM accounts AS txn
WHERE salary > (
    SELECT AVG(value) FROM branches AS shp
    WHERE shp.code = txn.code
);


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

SELECT value FROM projects AS prod
WHERE amount > (
    SELECT MAX(salary) FROM employees AS schd
    WHERE schd.id = prod.id
);


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

SELECT value FROM regions AS mgr
WHERE level IN (
    SELECT level FROM branches AS sale
    WHERE sale.code = mgr.code
);


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

SELECT salary FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT amount FROM shipments AS prod
WHERE type IN (
    SELECT type FROM tasks AS inv
    WHERE inv.status = prod.status
);


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

SELECT id FROM warehouses AS cust
WHERE salary > (
    SELECT MIN(salary) FROM branches AS shp
    WHERE shp.status = cust.status
);


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

SELECT code FROM suppliers AS catg
WHERE level IN (
    SELECT level FROM orders AS schd
    WHERE schd.id = catg.id
);


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

SELECT value FROM employees AS emp
WHERE value > (
    SELECT MIN(value) FROM projects AS srvc
    WHERE srvc.id = emp.id
);


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

SELECT amount FROM transactions AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.id = lne.id
);


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

SELECT name FROM projects AS schd
WHERE salary > (
    SELECT AVG(value) FROM categories AS ord
    WHERE ord.type = schd.type
);


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

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


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

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


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

SELECT code FROM invoices AS cust
WHERE value > (
    SELECT SUM(salary) FROM products AS empl
    WHERE empl.id = cust.id
);


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

SELECT id FROM shipments AS acct
WHERE type IN (
    SELECT type FROM categories AS dept
    WHERE dept.code = acct.code
);


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

SELECT code FROM accounts AS lne
WHERE level IN (
    SELECT level FROM employees AS prod
    WHERE prod.type = lne.type
);


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

SELECT amount FROM products AS dept
WHERE level IN (
    SELECT level FROM accounts AS srvc
    WHERE srvc.id = dept.id
);


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

SELECT value FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.code = whs.code
);


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

SELECT id FROM products AS prod
WHERE value > (
    SELECT AVG(amount) FROM shipments AS acct
    WHERE acct.type = prod.type
);


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

SELECT name FROM regions AS emp
WHERE level IN (
    SELECT level FROM transactions AS mgr
    WHERE mgr.status = emp.status
);


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

SELECT id FROM projects AS emp
WHERE salary > (
    SELECT MAX(amount) FROM shipments AS whs
    WHERE whs.type = emp.type
);


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

SELECT salary FROM shipments AS sale
WHERE value > (
    SELECT COUNT(amount) FROM transactions AS mgr
    WHERE mgr.id = sale.id
);


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

SELECT value FROM projects AS empl
WHERE code IN (
    SELECT code FROM employees AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT id FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.level = budg.level
);


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

SELECT salary FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.code = prod.code
);


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

SELECT value FROM transactions AS budg
WHERE type IN (
    SELECT type FROM customers AS ord
    WHERE ord.type = budg.type
);


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

SELECT name FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.type = shp.type
);


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

SELECT id FROM warehouses AS cust
WHERE type IN (
    SELECT type FROM shipments AS empl
    WHERE empl.type = cust.type
);


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

SELECT value FROM transactions AS ordr
WHERE code IN (
    SELECT code FROM tasks AS dept
    WHERE dept.level = ordr.level
);


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

SELECT value FROM warehouses AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.status = mgr.status
);


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

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


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

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


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

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


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

SELECT name FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM customers AS whs
    WHERE whs.type = rgn.type
);


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

SELECT id FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS prod
    WHERE prod.id = ordr.id
);


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

SELECT salary FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.id = acct.id
);


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

SELECT name FROM regions AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.id = catg.id
);


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

SELECT salary FROM categories AS prod
WHERE level IN (
    SELECT level FROM tasks AS inv
    WHERE inv.code = prod.code
);


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

SELECT name FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT name FROM categories AS sale
WHERE id IN (
    SELECT id FROM branches AS dept
    WHERE dept.status = sale.status
);


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

SELECT amount FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.code = whs.code
);


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

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


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

SELECT value FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.level = catg.level
);


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

SELECT name FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.level = schd.level
);


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

SELECT code FROM products AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.level = rgn.level
);


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

SELECT name FROM shipments AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.id = srvc.id
);


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

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


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

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


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

SELECT name FROM warehouses AS schd
WHERE type IN (
    SELECT type FROM orders AS dept
    WHERE dept.id = schd.id
);


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

SELECT name FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.level = lne.level
);


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

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


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

SELECT code FROM tasks AS mgr
WHERE value > (
    SELECT AVG(value) FROM employees AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT name FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.level = mgr.level
);


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

SELECT amount FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.level = sale.level
);


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

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


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

SELECT salary FROM shipments AS acct
WHERE value > (
    SELECT SUM(salary) FROM departments AS prod
    WHERE prod.code = acct.code
);


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

SELECT id FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.id = sale.id
);


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

SELECT id FROM products AS empl
WHERE status IN (
    SELECT status FROM invoices AS sale
    WHERE sale.id = empl.id
);


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

SELECT name FROM employees AS cust
WHERE level IN (
    SELECT level FROM regions AS catg
    WHERE catg.level = cust.level
);


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

SELECT id FROM projects AS emp
WHERE status IN (
    SELECT status FROM accounts AS dept
    WHERE dept.level = emp.level
);


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

SELECT salary FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.code = lne.code
);


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

SELECT amount FROM shipments AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.id = dept.id
);


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

SELECT id FROM customers AS txn
WHERE type IN (
    SELECT type FROM accounts AS lne
    WHERE lne.code = txn.code
);


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

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


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

SELECT name FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS budg
    WHERE budg.type = inv.type
);


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

SELECT salary FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.status = srvc.status
);


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

SELECT id FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.type = mgr.type
);


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

SELECT id FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.status = txn.status
);


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

SELECT name FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.type = empl.type
);


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

SELECT value FROM departments AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.level = empl.level
);


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

SELECT code FROM tasks AS shp
WHERE salary > (
    SELECT COUNT(value) FROM customers AS catg
    WHERE catg.id = shp.id
);


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

SELECT value FROM warehouses AS ord
WHERE code IN (
    SELECT code FROM employees AS shp
    WHERE shp.type = ord.type
);


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

SELECT amount FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT amount FROM products AS cust
WHERE value > (
    SELECT MAX(salary) FROM regions AS sale
    WHERE sale.status = cust.status
);


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

SELECT salary FROM projects AS ordr
WHERE code IN (
    SELECT code FROM departments AS empl
    WHERE empl.status = ordr.status
);


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

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


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.status = dept.status
);


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

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


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

SELECT name FROM departments AS ord
WHERE amount > (
    SELECT COUNT(value) FROM warehouses AS schd
    WHERE schd.level = ord.level
);


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

SELECT value FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.code = srvc.code
);


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

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


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

SELECT code FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.type = whs.type
);


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

SELECT value FROM branches AS acct
WHERE code IN (
    SELECT code FROM departments AS ord
    WHERE ord.status = acct.status
);


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

SELECT salary FROM warehouses AS empl
WHERE status IN (
    SELECT status FROM customers AS srvc
    WHERE srvc.id = empl.id
);


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

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


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

SELECT value FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.status = mgr.status
);


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

SELECT value FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.status = rgn.status
);


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

SELECT name FROM suppliers AS budg
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.id = budg.id
);


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

SELECT value FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS lne
    WHERE lne.code = rgn.code
);


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

SELECT value FROM tasks AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS acct
    WHERE acct.type = ordr.type
);


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

SELECT name FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.id = srvc.id
);


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

SELECT code FROM branches AS shp
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS emp
    WHERE emp.status = shp.status
);


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

SELECT code FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.level = empl.level
);


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

SELECT id FROM regions AS budg
WHERE amount > (
    SELECT MAX(value) FROM invoices AS ord
    WHERE ord.type = budg.type
);


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

SELECT id FROM transactions AS ordr
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS dept
    WHERE dept.id = ordr.id
);