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

SELECT value FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.type = empl.type
);


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

SELECT name FROM suppliers AS lne
WHERE type IN (
    SELECT type FROM tasks AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT code FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT name FROM invoices AS srvc
WHERE id IN (
    SELECT id FROM customers AS prod
    WHERE prod.id = srvc.id
);


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

SELECT code FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS whs
    WHERE whs.level = prod.level
);


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

SELECT amount FROM transactions AS empl
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.status = empl.status
);


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

SELECT salary FROM shipments AS mgr
WHERE amount > (
    SELECT MIN(amount) FROM departments AS inv
    WHERE inv.id = mgr.id
);


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

SELECT id FROM invoices AS schd
WHERE value > (
    SELECT COUNT(salary) FROM orders AS catg
    WHERE catg.status = schd.status
);


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

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


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

SELECT id FROM suppliers AS budg
WHERE amount > (
    SELECT SUM(value) FROM accounts AS prod
    WHERE prod.id = budg.id
);


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

SELECT salary FROM regions AS whs
WHERE id IN (
    SELECT id FROM categories AS txn
    WHERE txn.id = whs.id
);


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

SELECT name FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.status = prod.status
);


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

SELECT name FROM orders AS whs
WHERE status IN (
    SELECT status FROM tasks AS dept
    WHERE dept.level = whs.level
);


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

SELECT id FROM tasks AS ord
WHERE level IN (
    SELECT level FROM employees AS txn
    WHERE txn.level = ord.level
);


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

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


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

SELECT salary FROM departments AS srvc
WHERE status IN (
    SELECT status FROM categories AS acct
    WHERE acct.code = srvc.code
);


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

SELECT value FROM orders AS rgn
WHERE level IN (
    SELECT level FROM employees AS sale
    WHERE sale.level = rgn.level
);


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

SELECT amount FROM categories AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.id = emp.id
);


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

SELECT value FROM warehouses AS prod
WHERE level IN (
    SELECT level FROM invoices AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT value FROM invoices AS mgr
WHERE type IN (
    SELECT type FROM products AS shp
    WHERE shp.id = mgr.id
);


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

SELECT amount FROM customers AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT salary FROM projects AS emp
WHERE salary > (
    SELECT MAX(amount) FROM orders AS schd
    WHERE schd.id = emp.id
);


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

SELECT salary FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.level = cust.level
);


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

SELECT value FROM orders AS ord
WHERE status IN (
    SELECT status FROM invoices AS prod
    WHERE prod.level = ord.level
);


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

SELECT id FROM shipments AS budg
WHERE level IN (
    SELECT level FROM customers AS rgn
    WHERE rgn.id = budg.id
);


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

SELECT salary FROM transactions AS empl
WHERE level IN (
    SELECT level FROM categories AS prod
    WHERE prod.level = empl.level
);


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

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


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

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


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

SELECT salary FROM branches AS srvc
WHERE amount > (
    SELECT MAX(value) FROM invoices AS txn
    WHERE txn.id = srvc.id
);


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

SELECT salary FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.status = schd.status
);


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

SELECT amount FROM departments AS srvc
WHERE id IN (
    SELECT id FROM accounts AS schd
    WHERE schd.id = srvc.id
);


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

SELECT code FROM transactions AS ordr
WHERE salary > (
    SELECT COUNT(value) FROM accounts AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT value FROM suppliers AS ordr
WHERE value > (
    SELECT MAX(salary) FROM customers AS whs
    WHERE whs.code = ordr.code
);


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

SELECT salary FROM products AS dept
WHERE status IN (
    SELECT status FROM departments AS emp
    WHERE emp.type = dept.type
);


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

SELECT id FROM shipments AS rgn
WHERE salary > (
    SELECT SUM(value) FROM orders AS budg
    WHERE budg.level = rgn.level
);


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

SELECT id FROM shipments AS catg
WHERE salary > (
    SELECT MAX(salary) FROM departments AS schd
    WHERE schd.status = catg.status
);


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

SELECT code FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.id = acct.id
);


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

SELECT value FROM transactions AS ordr
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS dept
    WHERE dept.type = ordr.type
);


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

SELECT id FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM transactions AS mgr
    WHERE mgr.type = whs.type
);


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

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


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

SELECT name FROM categories AS sale
WHERE id IN (
    SELECT id FROM branches AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT id FROM shipments AS shp
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.type = shp.type
);


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

SELECT code FROM orders AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS inv
    WHERE inv.level = emp.level
);


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

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


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

SELECT name FROM transactions AS acct
WHERE status IN (
    SELECT status FROM departments AS rgn
    WHERE rgn.code = acct.code
);


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

SELECT amount FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.code = ordr.code
);


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

SELECT salary FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.status = lne.status
);


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

SELECT name FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.id = empl.id
);


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

SELECT code FROM branches AS lne
WHERE value > (
    SELECT MAX(amount) FROM tasks AS acct
    WHERE acct.level = lne.level
);


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

SELECT amount FROM regions AS lne
WHERE amount > (
    SELECT AVG(value) FROM projects AS txn
    WHERE txn.level = lne.level
);


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

SELECT salary FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.status = schd.status
);


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

SELECT salary FROM shipments AS catg
WHERE type IN (
    SELECT type FROM categories AS lne
    WHERE lne.type = catg.type
);


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

SELECT amount FROM transactions AS acct
WHERE type IN (
    SELECT type FROM branches AS catg
    WHERE catg.level = acct.level
);


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

SELECT value FROM departments AS shp
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS rgn
    WHERE rgn.id = shp.id
);


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

SELECT salary FROM tasks AS srvc
WHERE level IN (
    SELECT level FROM accounts AS prod
    WHERE prod.code = srvc.code
);


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

SELECT value FROM customers AS acct
WHERE salary > (
    SELECT MAX(value) FROM departments AS empl
    WHERE empl.code = acct.code
);


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

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


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

SELECT code FROM tasks AS budg
WHERE salary > (
    SELECT MAX(salary) FROM invoices AS dept
    WHERE dept.status = budg.status
);


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

SELECT name FROM tasks AS empl
WHERE code IN (
    SELECT code FROM warehouses AS acct
    WHERE acct.status = empl.status
);


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

SELECT code FROM departments AS ord
WHERE status IN (
    SELECT status FROM employees AS lne
    WHERE lne.code = ord.code
);


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

SELECT code FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.level = rgn.level
);


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

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


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

SELECT amount FROM departments AS rgn
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS empl
    WHERE empl.status = rgn.status
);


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

SELECT id FROM accounts AS budg
WHERE type IN (
    SELECT type FROM branches AS schd
    WHERE schd.type = budg.type
);


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

SELECT amount FROM orders AS mgr
WHERE salary > (
    SELECT MIN(amount) FROM categories AS empl
    WHERE empl.level = mgr.level
);


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

SELECT salary FROM invoices AS inv
WHERE type IN (
    SELECT type FROM orders AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT amount FROM accounts AS budg
WHERE amount > (
    SELECT MIN(salary) FROM shipments AS whs
    WHERE whs.level = budg.level
);


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

SELECT name FROM warehouses AS schd
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.status = schd.status
);


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

SELECT code FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.level = lne.level
);


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

SELECT amount FROM transactions AS shp
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS inv
    WHERE inv.id = shp.id
);


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

SELECT salary FROM branches AS lne
WHERE value > (
    SELECT SUM(amount) FROM products AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT value FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.status = prod.status
);


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

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


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

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


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

SELECT salary FROM transactions AS ordr
WHERE type IN (
    SELECT type FROM products AS budg
    WHERE budg.type = ordr.type
);


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

SELECT id FROM employees AS sale
WHERE id IN (
    SELECT id FROM products AS schd
    WHERE schd.status = sale.status
);


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

SELECT amount FROM accounts AS shp
WHERE code IN (
    SELECT code FROM products AS schd
    WHERE schd.code = shp.code
);


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

SELECT value FROM customers AS shp
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS ord
    WHERE ord.code = shp.code
);


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

SELECT amount FROM transactions AS srvc
WHERE amount > (
    SELECT AVG(value) FROM accounts AS shp
    WHERE shp.level = srvc.level
);


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

SELECT id FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.type = mgr.type
);


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

SELECT salary FROM customers AS mgr
WHERE code IN (
    SELECT code FROM categories AS shp
    WHERE shp.status = mgr.status
);


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

SELECT salary FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.type = dept.type
);


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

SELECT id FROM shipments AS ordr
WHERE status IN (
    SELECT status FROM invoices AS empl
    WHERE empl.code = ordr.code
);


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

SELECT code FROM orders AS rgn
WHERE type IN (
    SELECT type FROM shipments AS srvc
    WHERE srvc.code = rgn.code
);


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

SELECT name FROM regions AS lne
WHERE value > (
    SELECT MIN(value) FROM branches AS ordr
    WHERE ordr.level = lne.level
);


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

SELECT value FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = shp.type
);


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

SELECT id FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.status = budg.status
);


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

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


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

SELECT amount FROM employees AS srvc
WHERE status IN (
    SELECT status FROM branches AS txn
    WHERE txn.status = srvc.status
);


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

SELECT id FROM products AS sale
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS whs
    WHERE whs.type = sale.type
);


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

SELECT name FROM tasks AS prod
WHERE level IN (
    SELECT level FROM categories AS ord
    WHERE ord.status = prod.status
);


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

SELECT amount FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.level = ordr.level
);


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

SELECT value FROM orders AS ordr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.id = ordr.id
);


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

SELECT salary FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS prod
    WHERE prod.id = inv.id
);


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

SELECT value FROM departments AS shp
WHERE amount > (
    SELECT AVG(salary) FROM products AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT amount FROM products AS inv
WHERE level IN (
    SELECT level FROM warehouses AS catg
    WHERE catg.code = inv.code
);


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

SELECT name FROM tasks AS sale
WHERE value > (
    SELECT MAX(salary) FROM categories AS txn
    WHERE txn.code = sale.code
);


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

SELECT amount FROM orders AS whs
WHERE id IN (
    SELECT id FROM departments AS inv
    WHERE inv.id = whs.id
);


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

SELECT code FROM employees AS budg
WHERE value > (
    SELECT COUNT(amount) FROM orders AS txn
    WHERE txn.type = budg.type
);


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

SELECT code FROM categories AS srvc
WHERE amount > (
    SELECT AVG(amount) FROM accounts AS cust
    WHERE cust.code = srvc.code
);


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

SELECT code FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.status = mgr.status
);


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

SELECT id FROM categories AS whs
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS cust
    WHERE cust.id = whs.id
);


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

SELECT value FROM customers AS txn
WHERE salary > (
    SELECT SUM(amount) FROM employees AS dept
    WHERE dept.type = txn.type
);


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

SELECT salary FROM warehouses AS emp
WHERE status IN (
    SELECT status FROM departments AS prod
    WHERE prod.level = emp.level
);


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

SELECT id FROM accounts AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.code = empl.code
);


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

SELECT code FROM products AS schd
WHERE value > (
    SELECT MAX(salary) FROM regions AS inv
    WHERE inv.type = schd.type
);


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

SELECT salary FROM customers AS rgn
WHERE salary > (
    SELECT MAX(amount) FROM employees AS dept
    WHERE dept.id = rgn.id
);


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

SELECT salary FROM employees AS catg
WHERE code IN (
    SELECT code FROM tasks AS srvc
    WHERE srvc.type = catg.type
);


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

SELECT code FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.level = lne.level
);


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

SELECT name FROM branches AS dept
WHERE salary > (
    SELECT MIN(amount) FROM categories AS lne
    WHERE lne.id = dept.id
);


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

SELECT id FROM accounts AS srvc
WHERE value > (
    SELECT MIN(amount) FROM projects AS shp
    WHERE shp.id = srvc.id
);


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

SELECT value FROM employees AS inv
WHERE id IN (
    SELECT id FROM transactions AS empl
    WHERE empl.id = inv.id
);


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

SELECT value FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.level = sale.level
);


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

SELECT id FROM regions AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM suppliers AS emp
    WHERE emp.level = ordr.level
);


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

SELECT code FROM products AS budg
WHERE amount > (
    SELECT COUNT(value) FROM accounts AS catg
    WHERE catg.status = budg.status
);


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

SELECT amount FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.status = cust.status
);


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

SELECT value FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.level = srvc.level
);


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

SELECT code FROM orders AS lne
WHERE value > (
    SELECT COUNT(value) FROM departments AS schd
    WHERE schd.level = lne.level
);


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

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


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

SELECT code FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT value FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.level = emp.level
);


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

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


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

SELECT id FROM warehouses AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = acct.level
);


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

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


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

SELECT code FROM departments AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM employees AS dept
    WHERE dept.status = rgn.status
);


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

SELECT value FROM regions AS empl
WHERE level IN (
    SELECT level FROM products AS cust
    WHERE cust.status = empl.status
);


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

SELECT id FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.status = lne.status
);


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

SELECT name FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT name FROM employees AS prod
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT id FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.level = acct.level
);


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

SELECT id FROM orders AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM departments AS schd
    WHERE schd.code = ordr.code
);


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

SELECT code FROM orders AS acct
WHERE amount > (
    SELECT SUM(value) FROM invoices AS dept
    WHERE dept.status = acct.status
);


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

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


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

SELECT name FROM tasks AS cust
WHERE value > (
    SELECT MIN(value) FROM branches AS whs
    WHERE whs.level = cust.level
);


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

SELECT value FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.status = whs.status
);


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

SELECT id FROM categories AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.code = shp.code
);


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

SELECT code FROM invoices AS dept
WHERE value > (
    SELECT COUNT(value) FROM branches AS budg
    WHERE budg.type = dept.type
);


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

SELECT amount FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.code = inv.code
);


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

SELECT id FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.status = txn.status
);


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

SELECT value FROM warehouses AS mgr
WHERE salary > (
    SELECT MIN(amount) FROM projects AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT salary FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.type = srvc.type
);


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

SELECT amount FROM invoices AS rgn
WHERE level IN (
    SELECT level FROM employees AS cust
    WHERE cust.code = rgn.code
);


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

SELECT code FROM invoices AS dept
WHERE id IN (
    SELECT id FROM branches AS lne
    WHERE lne.type = dept.type
);


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

SELECT id FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.id = mgr.id
);


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

SELECT name FROM invoices AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM suppliers AS sale
    WHERE sale.id = rgn.id
);


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

SELECT id FROM transactions AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.type = cust.type
);


Prompt:
Schema:
  customers (alias: acct)(date, id, level, value)
  accounts(date, code, id, type)
Task: Retrieve code from customers with salary above the AVG(salary) of accounts rows sharing the same id.
SQL:

SELECT code FROM customers AS acct
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS prod
    WHERE prod.id = acct.id
);


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

SELECT value FROM orders AS txn
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS inv
    WHERE inv.status = txn.status
);


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

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


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

SELECT salary FROM orders AS empl
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT amount FROM customers AS budg
WHERE value > (
    SELECT MIN(amount) FROM orders AS prod
    WHERE prod.level = budg.level
);


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

SELECT salary FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.level = mgr.level
);


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

SELECT id FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.code = budg.code
);


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

SELECT amount FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.type = sale.type
);


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

SELECT amount FROM shipments AS acct
WHERE salary > (
    SELECT AVG(amount) FROM orders AS rgn
    WHERE rgn.type = acct.type
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.code = acct.code
);


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

SELECT value FROM products AS mgr
WHERE value > (
    SELECT SUM(value) FROM employees AS empl
    WHERE empl.status = mgr.status
);


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

SELECT salary FROM categories AS srvc
WHERE value > (
    SELECT MIN(value) FROM warehouses AS prod
    WHERE prod.type = srvc.type
);


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

SELECT amount FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.type = prod.type
);


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

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


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

SELECT code FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = schd.status
);


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

SELECT name FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = whs.status
);


Prompt:
Schema:
  projects (alias: rgn)(name, value, salary, level)
  customers(name, level, status, type)
Task: Find name from projects where level appears in customers entries with matching level.
SQL:

SELECT name FROM projects AS rgn
WHERE level IN (
    SELECT level FROM customers AS schd
    WHERE schd.level = rgn.level
);


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

SELECT code FROM employees AS ord
WHERE level IN (
    SELECT level FROM projects AS dept
    WHERE dept.level = ord.level
);


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

SELECT value FROM orders AS inv
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.status = inv.status
);


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

SELECT value FROM customers AS inv
WHERE salary > (
    SELECT COUNT(value) FROM employees AS txn
    WHERE txn.status = inv.status
);


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

SELECT code FROM departments AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS mgr
    WHERE mgr.type = budg.type
);


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

SELECT amount FROM accounts AS acct
WHERE level IN (
    SELECT level FROM categories AS ord
    WHERE ord.code = acct.code
);


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

SELECT code FROM departments AS srvc
WHERE id IN (
    SELECT id FROM products AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT code FROM products AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM suppliers AS catg
    WHERE catg.level = srvc.level
);


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

SELECT code FROM departments AS lne
WHERE level IN (
    SELECT level FROM invoices AS mgr
    WHERE mgr.status = lne.status
);


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

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


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

SELECT amount FROM transactions AS dept
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT value FROM suppliers AS srvc
WHERE status IN (
    SELECT status FROM employees AS whs
    WHERE whs.type = srvc.type
);


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

SELECT salary FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.type = lne.type
);


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

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


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

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


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

SELECT amount FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.status = ordr.status
);


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

SELECT value FROM branches AS prod
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS emp
    WHERE emp.code = prod.code
);


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

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


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

SELECT id FROM tasks AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM customers AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT amount FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS txn
    WHERE txn.type = budg.type
);


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

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


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

SELECT name FROM regions AS emp
WHERE value > (
    SELECT SUM(salary) FROM categories AS catg
    WHERE catg.status = emp.status
);


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

SELECT value FROM categories AS inv
WHERE status IN (
    SELECT status FROM tasks AS sale
    WHERE sale.status = inv.status
);


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

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


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

SELECT name FROM employees AS sale
WHERE code IN (
    SELECT code FROM accounts AS prod
    WHERE prod.status = sale.status
);


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

SELECT name FROM transactions AS ord
WHERE value > (
    SELECT MIN(value) FROM products AS budg
    WHERE budg.type = ord.type
);


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

SELECT value FROM branches AS ord
WHERE id IN (
    SELECT id FROM shipments AS catg
    WHERE catg.status = ord.status
);


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

SELECT code FROM accounts AS ordr
WHERE salary > (
    SELECT SUM(value) FROM invoices AS catg
    WHERE catg.id = ordr.id
);


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

SELECT name FROM categories AS catg
WHERE code IN (
    SELECT code FROM customers AS sale
    WHERE sale.level = catg.level
);


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

SELECT id FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.level = ord.level
);


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

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


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

SELECT id FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.level = srvc.level
);


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

SELECT amount FROM warehouses AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.code = empl.code
);


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

SELECT code FROM transactions AS budg
WHERE level IN (
    SELECT level FROM products AS catg
    WHERE catg.code = budg.code
);


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

SELECT value FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.status = mgr.status
);


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

SELECT value FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS prod
    WHERE prod.type = dept.type
);


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

SELECT code FROM regions AS schd
WHERE id IN (
    SELECT id FROM customers AS catg
    WHERE catg.type = schd.type
);


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

SELECT amount FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT value FROM categories AS cust
WHERE salary > (
    SELECT MAX(salary) FROM projects AS dept
    WHERE dept.code = cust.code
);


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

SELECT salary FROM shipments AS txn
WHERE level IN (
    SELECT level FROM projects AS schd
    WHERE schd.code = txn.code
);


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

SELECT id FROM warehouses AS dept
WHERE value > (
    SELECT MIN(salary) FROM orders AS whs
    WHERE whs.level = dept.level
);


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

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


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

SELECT id FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.code = sale.code
);


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

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


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

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


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

SELECT id FROM departments AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.level = ord.level
);


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

SELECT name FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.id = srvc.id
);


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

SELECT value FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.code = schd.code
);


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

SELECT amount FROM categories AS ord
WHERE type IN (
    SELECT type FROM orders AS cust
    WHERE cust.id = ord.id
);


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

SELECT id FROM departments AS empl
WHERE id IN (
    SELECT id FROM products AS catg
    WHERE catg.level = empl.level
);


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

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


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

SELECT code FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.status = inv.status
);


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

SELECT code FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.type = srvc.type
);


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

SELECT value FROM invoices AS whs
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT amount FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.status = mgr.status
);


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

SELECT id FROM departments AS ord
WHERE value > (
    SELECT MAX(salary) FROM transactions AS empl
    WHERE empl.id = ord.id
);


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

SELECT name FROM suppliers AS catg
WHERE type IN (
    SELECT type FROM categories AS inv
    WHERE inv.level = catg.level
);


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

SELECT id FROM customers AS ordr
WHERE level IN (
    SELECT level FROM tasks AS srvc
    WHERE srvc.status = ordr.status
);


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

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


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

SELECT value FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.type = sale.type
);


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

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


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

SELECT code FROM shipments AS rgn
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT value FROM departments AS rgn
WHERE id IN (
    SELECT id FROM tasks AS shp
    WHERE shp.id = rgn.id
);


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

SELECT salary FROM products AS budg
WHERE code IN (
    SELECT code FROM tasks AS lne
    WHERE lne.level = budg.level
);


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

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


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

SELECT value FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.code = mgr.code
);


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

SELECT name FROM transactions AS txn
WHERE status IN (
    SELECT status FROM shipments AS budg
    WHERE budg.status = txn.status
);


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

SELECT name FROM categories AS ordr
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS acct
    WHERE acct.type = ordr.type
);


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

SELECT salary FROM regions AS whs
WHERE id IN (
    SELECT id FROM departments AS ordr
    WHERE ordr.status = whs.status
);


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

SELECT code FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.type = budg.type
);


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

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


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

SELECT value FROM orders AS lne
WHERE level IN (
    SELECT level FROM customers AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT amount FROM departments AS budg
WHERE salary > (
    SELECT MIN(amount) FROM employees AS dept
    WHERE dept.code = budg.code
);


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

SELECT salary FROM departments AS srvc
WHERE type IN (
    SELECT type FROM invoices AS dept
    WHERE dept.code = srvc.code
);


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

SELECT id FROM branches AS inv
WHERE salary > (
    SELECT AVG(salary) FROM products AS shp
    WHERE shp.id = inv.id
);


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

SELECT amount FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.level = txn.level
);


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

SELECT code FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT code FROM suppliers AS srvc
WHERE status IN (
    SELECT status FROM orders AS cust
    WHERE cust.type = srvc.type
);


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

SELECT salary FROM tasks AS schd
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS lne
    WHERE lne.type = schd.type
);


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

SELECT salary FROM employees AS shp
WHERE id IN (
    SELECT id FROM branches AS prod
    WHERE prod.type = shp.type
);


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

SELECT salary FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS budg
    WHERE budg.id = ordr.id
);


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

SELECT value FROM orders AS ordr
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.id = ordr.id
);


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

SELECT id FROM shipments AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.type = schd.type
);


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

SELECT id FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.status = budg.status
);


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

SELECT id FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.code = lne.code
);


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

SELECT code FROM invoices AS srvc
WHERE id IN (
    SELECT id FROM regions AS inv
    WHERE inv.id = srvc.id
);


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

SELECT salary FROM accounts AS mgr
WHERE value > (
    SELECT COUNT(amount) FROM suppliers AS whs
    WHERE whs.type = mgr.type
);


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

SELECT name FROM branches AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.status = prod.status
);


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

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


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

SELECT id FROM employees AS schd
WHERE value > (
    SELECT COUNT(value) FROM categories AS inv
    WHERE inv.status = schd.status
);


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

SELECT code FROM warehouses AS lne
WHERE salary > (
    SELECT COUNT(value) FROM branches AS ord
    WHERE ord.level = lne.level
);


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

SELECT name FROM tasks AS sale
WHERE amount > (
    SELECT SUM(value) FROM categories AS schd
    WHERE schd.status = sale.status
);


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

SELECT code FROM warehouses AS ord
WHERE value > (
    SELECT AVG(amount) FROM tasks AS mgr
    WHERE mgr.level = ord.level
);


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

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


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

SELECT name FROM regions AS acct
WHERE status IN (
    SELECT status FROM transactions AS srvc
    WHERE srvc.level = acct.level
);


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

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


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

SELECT id FROM projects AS empl
WHERE value > (
    SELECT MIN(value) FROM regions AS catg
    WHERE catg.code = empl.code
);


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

SELECT salary FROM suppliers AS ordr
WHERE code IN (
    SELECT code FROM regions AS prod
    WHERE prod.code = ordr.code
);


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

SELECT id FROM products AS inv
WHERE salary > (
    SELECT AVG(value) FROM departments AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT code FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.id = sale.id
);


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

SELECT code FROM tasks AS acct
WHERE value > (
    SELECT MAX(amount) FROM employees AS whs
    WHERE whs.type = acct.type
);


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

SELECT amount FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.type = txn.type
);


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

SELECT amount FROM accounts AS rgn
WHERE code IN (
    SELECT code FROM orders AS emp
    WHERE emp.type = rgn.type
);


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

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


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

SELECT name FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.level = rgn.level
);


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

SELECT code FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.id = schd.id
);


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

SELECT amount FROM suppliers AS schd
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS lne
    WHERE lne.type = schd.type
);


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

SELECT salary FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.level = mgr.level
);


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

SELECT value FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.level = prod.level
);


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

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


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

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


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

SELECT amount FROM warehouses AS prod
WHERE value > (
    SELECT SUM(salary) FROM departments AS acct
    WHERE acct.level = prod.level
);


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

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


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

SELECT id FROM customers AS dept
WHERE status IN (
    SELECT status FROM tasks AS inv
    WHERE inv.type = dept.type
);


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

SELECT salary FROM shipments AS dept
WHERE type IN (
    SELECT type FROM regions AS cust
    WHERE cust.type = dept.type
);


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

SELECT amount FROM warehouses AS mgr
WHERE level IN (
    SELECT level FROM departments AS catg
    WHERE catg.type = mgr.type
);


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

SELECT amount FROM categories AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.level = budg.level
);


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

SELECT amount FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.level = shp.level
);


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

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


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

SELECT salary FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.code = lne.code
);


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

SELECT salary FROM customers AS prod
WHERE id IN (
    SELECT id FROM categories AS empl
    WHERE empl.status = prod.status
);


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

SELECT id FROM suppliers AS emp
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS acct
    WHERE acct.level = emp.level
);


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

SELECT value FROM shipments AS schd
WHERE type IN (
    SELECT type FROM invoices AS txn
    WHERE txn.status = schd.status
);


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

SELECT salary FROM warehouses AS cust
WHERE salary > (
    SELECT SUM(salary) FROM shipments AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT salary FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.code = dept.code
);


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

SELECT code FROM regions AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS prod
    WHERE prod.status = acct.status
);


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

SELECT id FROM transactions AS shp
WHERE value > (
    SELECT AVG(value) FROM warehouses AS acct
    WHERE acct.level = shp.level
);


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

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


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

SELECT salary FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.level = empl.level
);


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

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


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

SELECT amount FROM projects AS ordr
WHERE salary > (
    SELECT COUNT(amount) FROM tasks AS dept
    WHERE dept.status = ordr.status
);