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

SELECT amount FROM orders AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.level = srvc.level
);


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

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


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

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


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

SELECT amount FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS empl
    WHERE empl.id = cust.id
);


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

SELECT amount FROM orders AS emp
WHERE salary > (
    SELECT MAX(value) FROM suppliers AS catg
    WHERE catg.level = emp.level
);


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

SELECT value FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.code = cust.code
);


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

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


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

SELECT name FROM tasks AS prod
WHERE status IN (
    SELECT status FROM orders AS catg
    WHERE catg.level = prod.level
);


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

SELECT code FROM transactions AS txn
WHERE id IN (
    SELECT id FROM suppliers AS emp
    WHERE emp.id = txn.id
);


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

SELECT code FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.level = cust.level
);


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

SELECT amount FROM accounts AS ord
WHERE status IN (
    SELECT status FROM branches AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT salary FROM suppliers AS whs
WHERE amount > (
    SELECT MIN(amount) FROM products AS sale
    WHERE sale.status = whs.status
);


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

SELECT amount FROM products AS srvc
WHERE level IN (
    SELECT level FROM transactions AS schd
    WHERE schd.code = srvc.code
);


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

SELECT amount FROM orders AS srvc
WHERE type IN (
    SELECT type FROM customers AS shp
    WHERE shp.level = srvc.level
);


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

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


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

SELECT amount FROM departments AS dept
WHERE code IN (
    SELECT code FROM transactions AS prod
    WHERE prod.level = dept.level
);


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

SELECT value FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS inv
    WHERE inv.level = txn.level
);


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

SELECT code FROM regions AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.id = schd.id
);


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

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


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

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


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

SELECT id FROM tasks AS srvc
WHERE value > (
    SELECT AVG(amount) FROM warehouses AS empl
    WHERE empl.code = srvc.code
);


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

SELECT value FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.status = ordr.status
);


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

SELECT amount FROM employees AS shp
WHERE amount > (
    SELECT MIN(amount) FROM branches AS txn
    WHERE txn.code = shp.code
);


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

SELECT code FROM orders AS rgn
WHERE id IN (
    SELECT id FROM projects AS lne
    WHERE lne.type = rgn.type
);


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

SELECT code FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.id = dept.id
);


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

SELECT code FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.type = inv.type
);


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

SELECT value FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.status = schd.status
);


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

SELECT code FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM orders AS whs
    WHERE whs.id = srvc.id
);


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

SELECT value FROM employees AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM warehouses AS whs
    WHERE whs.status = txn.status
);


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

SELECT id FROM products AS empl
WHERE amount > (
    SELECT MIN(amount) FROM branches AS prod
    WHERE prod.type = empl.type
);


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

SELECT name FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.id = whs.id
);


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

SELECT name FROM tasks AS catg
WHERE code IN (
    SELECT code FROM categories AS dept
    WHERE dept.level = catg.level
);


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

SELECT amount FROM invoices AS whs
WHERE status IN (
    SELECT status FROM employees AS shp
    WHERE shp.id = whs.id
);


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

SELECT id FROM departments AS cust
WHERE value > (
    SELECT MIN(value) FROM orders AS rgn
    WHERE rgn.status = cust.status
);


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

SELECT code FROM orders AS shp
WHERE id IN (
    SELECT id FROM tasks AS ord
    WHERE ord.id = shp.id
);


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

SELECT name FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT id FROM invoices AS acct
WHERE value > (
    SELECT MAX(amount) FROM customers AS srvc
    WHERE srvc.type = acct.type
);


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

SELECT id FROM regions AS sale
WHERE amount > (
    SELECT MAX(salary) FROM customers AS lne
    WHERE lne.level = sale.level
);


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

SELECT salary FROM invoices AS ord
WHERE value > (
    SELECT AVG(value) FROM orders AS txn
    WHERE txn.code = ord.code
);


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

SELECT code FROM transactions AS budg
WHERE amount > (
    SELECT MIN(amount) FROM branches AS mgr
    WHERE mgr.status = budg.status
);


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

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


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

SELECT id FROM branches AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = catg.type
);


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

SELECT amount FROM employees AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.status = empl.status
);


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

SELECT salary FROM customers AS inv
WHERE value > (
    SELECT MIN(value) FROM shipments AS mgr
    WHERE mgr.code = inv.code
);


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

SELECT salary FROM products AS shp
WHERE type IN (
    SELECT type FROM branches AS sale
    WHERE sale.code = shp.code
);


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

SELECT amount FROM accounts AS whs
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS budg
    WHERE budg.type = whs.type
);


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

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


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

SELECT amount FROM accounts AS budg
WHERE code IN (
    SELECT code FROM customers AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT value FROM accounts AS emp
WHERE level IN (
    SELECT level FROM warehouses AS srvc
    WHERE srvc.id = emp.id
);


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

SELECT amount FROM regions AS lne
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.id = lne.id
);


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

SELECT name FROM invoices AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.id = ord.id
);


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

SELECT value FROM projects AS ordr
WHERE amount > (
    SELECT MAX(salary) FROM shipments AS schd
    WHERE schd.code = ordr.code
);


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

SELECT name FROM regions AS txn
WHERE amount > (
    SELECT MIN(amount) FROM categories AS prod
    WHERE prod.type = txn.type
);


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

SELECT name FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = schd.level
);


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

SELECT code FROM warehouses AS whs
WHERE salary > (
    SELECT MIN(salary) FROM suppliers AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT amount FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT salary FROM invoices AS catg
WHERE type IN (
    SELECT type FROM accounts AS schd
    WHERE schd.id = catg.id
);


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

SELECT name FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT name FROM warehouses AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS mgr
    WHERE mgr.code = lne.code
);


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

SELECT salary FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.status = lne.status
);


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

SELECT value FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.level = emp.level
);


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

SELECT amount FROM branches AS lne
WHERE type IN (
    SELECT type FROM customers AS catg
    WHERE catg.code = lne.code
);


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

SELECT code FROM customers AS srvc
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS mgr
    WHERE mgr.id = srvc.id
);


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

SELECT value FROM orders AS acct
WHERE value > (
    SELECT COUNT(amount) FROM regions AS cust
    WHERE cust.status = acct.status
);


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

SELECT value FROM tasks AS acct
WHERE amount > (
    SELECT MAX(amount) FROM regions AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT value FROM products AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.id = sale.id
);


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

SELECT amount FROM products AS budg
WHERE id IN (
    SELECT id FROM accounts AS acct
    WHERE acct.level = budg.level
);


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

SELECT name FROM customers AS dept
WHERE salary > (
    SELECT SUM(amount) FROM projects AS catg
    WHERE catg.level = dept.level
);


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

SELECT salary FROM invoices AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.status = schd.status
);


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

SELECT value FROM projects AS empl
WHERE type IN (
    SELECT type FROM accounts AS acct
    WHERE acct.type = empl.type
);


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

SELECT salary FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.id = acct.id
);


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

SELECT id FROM customers AS acct
WHERE code IN (
    SELECT code FROM branches AS inv
    WHERE inv.id = acct.id
);


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

SELECT code FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT amount FROM tasks AS acct
WHERE code IN (
    SELECT code FROM regions AS ordr
    WHERE ordr.code = acct.code
);


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

SELECT name FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.type = mgr.type
);


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

SELECT id FROM projects AS acct
WHERE value > (
    SELECT SUM(value) FROM departments AS emp
    WHERE emp.type = acct.type
);


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

SELECT id FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.code = srvc.code
);


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

SELECT value FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.status = inv.status
);


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

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


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

SELECT id FROM departments AS shp
WHERE salary > (
    SELECT COUNT(value) FROM products AS budg
    WHERE budg.status = shp.status
);


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

SELECT value FROM transactions AS catg
WHERE status IN (
    SELECT status FROM customers AS sale
    WHERE sale.level = catg.level
);


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

SELECT code FROM projects AS inv
WHERE amount > (
    SELECT MIN(salary) FROM regions AS lne
    WHERE lne.type = inv.type
);


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

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


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

SELECT salary FROM warehouses AS acct
WHERE value > (
    SELECT MAX(amount) FROM categories AS sale
    WHERE sale.type = acct.type
);


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

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


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

SELECT code FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS srvc
    WHERE srvc.id = ordr.id
);


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

SELECT amount FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.status = schd.status
);


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

SELECT name FROM products AS ord
WHERE id IN (
    SELECT id FROM warehouses AS emp
    WHERE emp.status = ord.status
);


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

SELECT name FROM categories AS rgn
WHERE id IN (
    SELECT id FROM transactions AS empl
    WHERE empl.status = rgn.status
);


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

SELECT salary FROM suppliers AS whs
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.id = whs.id
);


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

SELECT value FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.code = lne.code
);


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

SELECT value FROM suppliers AS sale
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.status = sale.status
);


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

SELECT id FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.id = txn.id
);


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

SELECT amount FROM warehouses AS prod
WHERE type IN (
    SELECT type FROM accounts AS shp
    WHERE shp.id = prod.id
);


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

SELECT amount FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.type = ord.type
);


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

SELECT name FROM employees AS acct
WHERE value > (
    SELECT COUNT(amount) FROM branches AS prod
    WHERE prod.code = acct.code
);


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

SELECT id FROM categories AS ord
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS inv
    WHERE inv.type = ord.type
);


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

SELECT amount FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT amount FROM transactions AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.code = mgr.code
);


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

SELECT code FROM customers AS schd
WHERE type IN (
    SELECT type FROM transactions AS prod
    WHERE prod.status = schd.status
);


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

SELECT name FROM invoices AS whs
WHERE type IN (
    SELECT type FROM employees AS txn
    WHERE txn.level = whs.level
);


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

SELECT name FROM regions AS ord
WHERE salary > (
    SELECT MAX(amount) FROM suppliers AS sale
    WHERE sale.id = ord.id
);


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

SELECT salary FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.level = shp.level
);


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

SELECT name FROM departments AS empl
WHERE amount > (
    SELECT SUM(value) FROM accounts AS prod
    WHERE prod.type = empl.type
);


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

SELECT salary FROM accounts AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS whs
    WHERE whs.code = mgr.code
);


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

SELECT amount FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.type = lne.type
);


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

SELECT value FROM tasks AS shp
WHERE code IN (
    SELECT code FROM warehouses AS catg
    WHERE catg.code = shp.code
);


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

SELECT value FROM categories AS lne
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.code = lne.code
);


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

SELECT salary FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.code = shp.code
);


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

SELECT name FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.code = empl.code
);


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

SELECT amount FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = ord.level
);


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

SELECT amount FROM products AS srvc
WHERE status IN (
    SELECT status FROM orders AS empl
    WHERE empl.type = srvc.type
);


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

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


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

SELECT amount FROM accounts AS lne
WHERE id IN (
    SELECT id FROM orders AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT value FROM orders AS rgn
WHERE status IN (
    SELECT status FROM projects AS sale
    WHERE sale.id = rgn.id
);


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

SELECT id FROM shipments AS budg
WHERE amount > (
    SELECT MAX(amount) FROM regions AS cust
    WHERE cust.type = budg.type
);


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

SELECT id FROM regions AS srvc
WHERE level IN (
    SELECT level FROM accounts AS inv
    WHERE inv.id = srvc.id
);


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

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


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

SELECT name FROM accounts AS inv
WHERE type IN (
    SELECT type FROM warehouses AS whs
    WHERE whs.type = inv.type
);


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

SELECT value FROM departments AS inv
WHERE value > (
    SELECT SUM(salary) FROM projects AS txn
    WHERE txn.level = inv.level
);


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

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


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

SELECT name FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.id = catg.id
);


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

SELECT salary FROM warehouses AS empl
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS cust
    WHERE cust.type = empl.type
);


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

SELECT amount FROM tasks AS mgr
WHERE level IN (
    SELECT level FROM categories AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT value FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.type = rgn.type
);


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

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


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

SELECT code FROM regions AS rgn
WHERE code IN (
    SELECT code FROM branches AS txn
    WHERE txn.code = rgn.code
);


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

SELECT amount FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.status = rgn.status
);


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

SELECT value FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.status = shp.status
);


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

SELECT code FROM transactions AS cust
WHERE salary > (
    SELECT SUM(amount) FROM customers AS mgr
    WHERE mgr.status = cust.status
);


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

SELECT salary FROM accounts AS sale
WHERE value > (
    SELECT AVG(salary) FROM tasks AS cust
    WHERE cust.type = sale.type
);


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

SELECT code FROM employees AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM suppliers AS whs
    WHERE whs.type = inv.type
);


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

SELECT value FROM customers AS whs
WHERE id IN (
    SELECT id FROM categories AS acct
    WHERE acct.level = whs.level
);


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

SELECT amount FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.type = cust.type
);


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

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


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

SELECT amount FROM warehouses AS dept
WHERE type IN (
    SELECT type FROM transactions AS prod
    WHERE prod.level = dept.level
);


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

SELECT name FROM projects AS schd
WHERE amount > (
    SELECT MAX(salary) FROM employees AS sale
    WHERE sale.code = schd.code
);


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

SELECT id FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.status = budg.status
);


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

SELECT salary FROM products AS dept
WHERE salary > (
    SELECT SUM(amount) FROM branches AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT code FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.status = cust.status
);


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

SELECT salary FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = cust.id
);


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

SELECT amount FROM branches AS sale
WHERE status IN (
    SELECT status FROM invoices AS dept
    WHERE dept.status = sale.status
);


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

SELECT value FROM categories AS empl
WHERE status IN (
    SELECT status FROM departments AS shp
    WHERE shp.code = empl.code
);


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

SELECT salary FROM employees AS ord
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS prod
    WHERE prod.type = ord.type
);


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

SELECT code FROM employees AS ord
WHERE value > (
    SELECT AVG(value) FROM categories AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT value FROM warehouses AS sale
WHERE status IN (
    SELECT status FROM tasks AS emp
    WHERE emp.code = sale.code
);


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

SELECT salary FROM transactions AS acct
WHERE id IN (
    SELECT id FROM tasks AS sale
    WHERE sale.status = acct.status
);


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

SELECT amount FROM warehouses AS shp
WHERE status IN (
    SELECT status FROM accounts AS mgr
    WHERE mgr.level = shp.level
);


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

SELECT amount FROM shipments AS cust
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS prod
    WHERE prod.id = cust.id
);


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

SELECT value FROM warehouses AS inv
WHERE code IN (
    SELECT code FROM employees AS catg
    WHERE catg.type = inv.type
);


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

SELECT amount FROM suppliers AS srvc
WHERE id IN (
    SELECT id FROM shipments AS prod
    WHERE prod.status = srvc.status
);


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

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


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

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


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

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


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

SELECT code FROM departments AS emp
WHERE code IN (
    SELECT code FROM shipments AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT name FROM transactions AS ordr
WHERE value > (
    SELECT SUM(amount) FROM shipments AS cust
    WHERE cust.id = ordr.id
);


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

SELECT amount FROM shipments AS empl
WHERE id IN (
    SELECT id FROM customers AS budg
    WHERE budg.id = empl.id
);


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

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


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

SELECT name FROM accounts AS rgn
WHERE value > (
    SELECT MIN(amount) FROM orders AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT value FROM shipments AS ordr
WHERE id IN (
    SELECT id FROM departments AS emp
    WHERE emp.status = ordr.status
);


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

SELECT salary FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.code = cust.code
);


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

SELECT code FROM accounts AS budg
WHERE level IN (
    SELECT level FROM orders AS inv
    WHERE inv.type = budg.type
);


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

SELECT amount FROM shipments AS shp
WHERE value > (
    SELECT MAX(salary) FROM regions AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT salary FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.type = empl.type
);


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

SELECT id FROM tasks AS lne
WHERE code IN (
    SELECT code FROM accounts AS cust
    WHERE cust.id = lne.id
);


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

SELECT id FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.type = acct.type
);


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

SELECT id FROM categories AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.type = whs.type
);


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

SELECT salary FROM orders AS emp
WHERE status IN (
    SELECT status FROM accounts AS lne
    WHERE lne.id = emp.id
);


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

SELECT value FROM categories AS acct
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.code = acct.code
);


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

SELECT value FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.level = ord.level
);


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

SELECT code FROM regions AS rgn
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS sale
    WHERE sale.code = rgn.code
);


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

SELECT value FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.id = whs.id
);


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

SELECT value FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.code = rgn.code
);


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

SELECT name FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS srvc
    WHERE srvc.id = acct.id
);


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

SELECT value FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT id FROM products AS inv
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS ord
    WHERE ord.type = inv.type
);


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

SELECT value FROM branches AS shp
WHERE level IN (
    SELECT level FROM tasks AS catg
    WHERE catg.id = shp.id
);


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

SELECT id FROM orders AS srvc
WHERE level IN (
    SELECT level FROM branches AS sale
    WHERE sale.level = srvc.level
);


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

SELECT value FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = budg.level
);


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

SELECT amount FROM invoices AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.type = shp.type
);


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

SELECT code FROM projects AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.level = catg.level
);


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

SELECT amount FROM tasks AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.id = mgr.id
);


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

SELECT value FROM invoices AS budg
WHERE code IN (
    SELECT code FROM regions AS schd
    WHERE schd.type = budg.type
);


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

SELECT value FROM branches AS budg
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS prod
    WHERE prod.type = budg.type
);


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

SELECT id FROM warehouses AS acct
WHERE salary > (
    SELECT AVG(salary) FROM orders AS catg
    WHERE catg.code = acct.code
);


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

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


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

SELECT value FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.status = dept.status
);


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

SELECT salary FROM branches AS prod
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.status = prod.status
);


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

SELECT amount FROM products AS sale
WHERE code IN (
    SELECT code FROM projects AS prod
    WHERE prod.status = sale.status
);


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

SELECT amount FROM shipments AS acct
WHERE salary > (
    SELECT MAX(amount) FROM accounts AS sale
    WHERE sale.level = acct.level
);


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

SELECT salary FROM shipments AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM branches AS txn
    WHERE txn.type = rgn.type
);


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

SELECT value FROM employees AS inv
WHERE id IN (
    SELECT id FROM suppliers AS txn
    WHERE txn.id = inv.id
);


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

SELECT value FROM products AS mgr
WHERE type IN (
    SELECT type FROM regions AS cust
    WHERE cust.id = mgr.id
);


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

SELECT salary FROM branches AS dept
WHERE salary > (
    SELECT MIN(value) FROM invoices AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT salary FROM warehouses AS sale
WHERE type IN (
    SELECT type FROM invoices AS ordr
    WHERE ordr.type = sale.type
);


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

SELECT code FROM customers AS empl
WHERE code IN (
    SELECT code FROM suppliers AS inv
    WHERE inv.status = empl.status
);


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

SELECT amount FROM products AS srvc
WHERE salary > (
    SELECT SUM(salary) FROM branches AS ord
    WHERE ord.type = srvc.type
);


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

SELECT value FROM products AS cust
WHERE level IN (
    SELECT level FROM tasks AS shp
    WHERE shp.type = cust.type
);


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

SELECT id FROM invoices AS inv
WHERE salary > (
    SELECT AVG(salary) FROM categories AS catg
    WHERE catg.id = inv.id
);


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

SELECT name FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.type = schd.type
);


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

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


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

SELECT id FROM warehouses AS budg
WHERE level IN (
    SELECT level FROM employees AS shp
    WHERE shp.id = budg.id
);


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

SELECT amount FROM suppliers AS shp
WHERE level IN (
    SELECT level FROM projects AS prod
    WHERE prod.status = shp.status
);


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

SELECT amount FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM suppliers AS dept
    WHERE dept.status = budg.status
);


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

SELECT salary FROM shipments AS budg
WHERE type IN (
    SELECT type FROM tasks AS inv
    WHERE inv.level = budg.level
);


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

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


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

SELECT id FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.type = prod.type
);


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

SELECT amount FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.type = inv.type
);


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

SELECT code FROM accounts AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT amount FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.id = srvc.id
);


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

SELECT salary FROM orders AS mgr
WHERE code IN (
    SELECT code FROM suppliers AS inv
    WHERE inv.level = mgr.level
);


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

SELECT id FROM orders AS shp
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS sale
    WHERE sale.level = shp.level
);


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

SELECT amount FROM tasks AS ordr
WHERE id IN (
    SELECT id FROM orders AS budg
    WHERE budg.type = ordr.type
);


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

SELECT value FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.type = acct.type
);


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

SELECT code FROM employees AS schd
WHERE level IN (
    SELECT level FROM warehouses AS whs
    WHERE whs.type = schd.type
);


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

SELECT salary FROM orders AS ord
WHERE level IN (
    SELECT level FROM transactions AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT name FROM customers AS empl
WHERE id IN (
    SELECT id FROM tasks AS acct
    WHERE acct.id = empl.id
);


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

SELECT amount FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.id = dept.id
);


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

SELECT amount FROM customers AS schd
WHERE status IN (
    SELECT status FROM departments AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT id FROM regions AS ord
WHERE value > (
    SELECT MAX(salary) FROM branches AS inv
    WHERE inv.code = ord.code
);


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

SELECT amount FROM orders AS inv
WHERE value > (
    SELECT MIN(value) FROM shipments AS srvc
    WHERE srvc.status = inv.status
);


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

SELECT id FROM tasks AS budg
WHERE level IN (
    SELECT level FROM departments AS emp
    WHERE emp.code = budg.code
);


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

SELECT id FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT value FROM customers AS srvc
WHERE value > (
    SELECT MIN(salary) FROM regions AS whs
    WHERE whs.id = srvc.id
);


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

SELECT id FROM transactions AS shp
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.status = shp.status
);


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

SELECT code FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.status = whs.status
);


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

SELECT salary FROM invoices AS ord
WHERE status IN (
    SELECT status FROM warehouses AS budg
    WHERE budg.status = ord.status
);


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

SELECT salary FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.id = catg.id
);


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

SELECT id FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.status = empl.status
);


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

SELECT amount FROM suppliers AS lne
WHERE id IN (
    SELECT id FROM branches AS rgn
    WHERE rgn.code = lne.code
);


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

SELECT value FROM customers AS whs
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.id = whs.id
);


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

SELECT amount FROM employees AS mgr
WHERE status IN (
    SELECT status FROM tasks AS schd
    WHERE schd.type = mgr.type
);


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

SELECT salary FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.id = rgn.id
);


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

SELECT name FROM branches AS acct
WHERE value > (
    SELECT AVG(salary) FROM shipments AS budg
    WHERE budg.code = acct.code
);


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

SELECT value FROM employees AS lne
WHERE code IN (
    SELECT code FROM invoices AS rgn
    WHERE rgn.code = lne.code
);


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

SELECT amount FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS whs
    WHERE whs.code = lne.code
);


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

SELECT salary FROM products AS txn
WHERE amount > (
    SELECT SUM(amount) FROM employees AS ord
    WHERE ord.type = txn.type
);


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

SELECT id FROM branches AS empl
WHERE salary > (
    SELECT AVG(salary) FROM suppliers AS acct
    WHERE acct.status = empl.status
);


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

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


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

SELECT code FROM suppliers AS empl
WHERE type IN (
    SELECT type FROM departments AS whs
    WHERE whs.code = empl.code
);


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

SELECT salary FROM products AS ord
WHERE type IN (
    SELECT type FROM projects AS inv
    WHERE inv.status = ord.status
);


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

SELECT name FROM orders AS rgn
WHERE status IN (
    SELECT status FROM shipments AS empl
    WHERE empl.code = rgn.code
);


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

SELECT value FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.status = lne.status
);


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

SELECT id FROM tasks AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.level = txn.level
);


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

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


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

SELECT salary FROM warehouses AS emp
WHERE status IN (
    SELECT status FROM transactions AS prod
    WHERE prod.type = emp.type
);


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

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


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

SELECT code FROM accounts AS empl
WHERE amount > (
    SELECT MAX(amount) FROM branches AS whs
    WHERE whs.code = empl.code
);


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

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT SUM(value) FROM regions AS rgn
    WHERE rgn.code = emp.code
);


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

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


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

SELECT amount FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.code = whs.code
);


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

SELECT value FROM orders AS acct
WHERE code IN (
    SELECT code FROM accounts AS txn
    WHERE txn.status = acct.status
);


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

SELECT name FROM products AS rgn
WHERE id IN (
    SELECT id FROM categories AS srvc
    WHERE srvc.type = rgn.type
);


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

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


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

SELECT name FROM employees AS empl
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS rgn
    WHERE rgn.code = empl.code
);


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

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


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

SELECT salary FROM accounts AS shp
WHERE level IN (
    SELECT level FROM customers AS emp
    WHERE emp.status = shp.status
);


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

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


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

SELECT salary FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.status = lne.status
);


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

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


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

SELECT value FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = sale.type
);


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

SELECT value FROM invoices AS srvc
WHERE type IN (
    SELECT type FROM tasks AS ordr
    WHERE ordr.status = srvc.status
);


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

SELECT salary FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.type = cust.type
);


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

SELECT salary FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.type = lne.type
);


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

SELECT name FROM shipments AS dept
WHERE salary > (
    SELECT MIN(value) FROM tasks AS ord
    WHERE ord.status = dept.status
);


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

SELECT id FROM accounts AS empl
WHERE code IN (
    SELECT code FROM tasks AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT name FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM transactions AS whs
    WHERE whs.level = acct.level
);


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

SELECT code FROM employees AS empl
WHERE amount > (
    SELECT SUM(salary) FROM orders AS lne
    WHERE lne.type = empl.type
);


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

SELECT code FROM regions AS txn
WHERE amount > (
    SELECT MAX(value) FROM customers AS emp
    WHERE emp.status = txn.status
);


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

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


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

SELECT name FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.status = sale.status
);


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

SELECT salary FROM products AS srvc
WHERE type IN (
    SELECT type FROM departments AS empl
    WHERE empl.status = srvc.status
);


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

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


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

SELECT value FROM departments AS schd
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS catg
    WHERE catg.level = schd.level
);


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

SELECT id FROM warehouses AS whs
WHERE status IN (
    SELECT status FROM customers AS emp
    WHERE emp.status = whs.status
);


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

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


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

SELECT value FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.id = shp.id
);


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

SELECT code FROM customers AS whs
WHERE amount > (
    SELECT SUM(salary) FROM categories AS lne
    WHERE lne.status = whs.status
);


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

SELECT name FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS catg
    WHERE catg.id = shp.id
);


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

SELECT value FROM shipments AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS sale
    WHERE sale.level = ord.level
);


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

SELECT value FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.id = inv.id
);


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

SELECT salary FROM suppliers AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS prod
    WHERE prod.status = mgr.status
);


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

SELECT salary FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.code = srvc.code
);


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

SELECT id FROM customers AS prod
WHERE type IN (
    SELECT type FROM warehouses AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT salary FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.code = prod.code
);


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

SELECT value FROM employees AS ord
WHERE id IN (
    SELECT id FROM orders AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT salary FROM orders AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.id = rgn.id
);


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

SELECT code FROM projects AS ord
WHERE id IN (
    SELECT id FROM accounts AS srvc
    WHERE srvc.id = ord.id
);


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

SELECT id FROM customers AS budg
WHERE value > (
    SELECT MIN(salary) FROM shipments AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT salary FROM employees AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.id = whs.id
);


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

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


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

SELECT value FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.type = lne.type
);


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

SELECT id FROM invoices AS catg
WHERE value > (
    SELECT COUNT(amount) FROM products AS lne
    WHERE lne.type = catg.type
);


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

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


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

SELECT id FROM tasks AS dept
WHERE level IN (
    SELECT level FROM branches AS shp
    WHERE shp.id = dept.id
);