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

SELECT code FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM managers AS catg
    WHERE catg.code = brc.code
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.level = brc.level
);


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM regions AS brc
    WHERE brc.id = mgr.id
);


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM customers AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT name FROM schedules AS schd
WHERE id IN (
    SELECT id FROM departments AS brc
    WHERE brc.status = schd.status
);


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

SELECT amount FROM projects AS prj
WHERE level IN (
    SELECT level FROM products AS empl
    WHERE empl.id = prj.id
);


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

SELECT name FROM regions AS rgn
WHERE code IN (
    SELECT code FROM accounts AS empl
    WHERE empl.type = rgn.type
);


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

SELECT amount FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.type = catg.type
);


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

SELECT id FROM items AS lne
WHERE amount > (
    SELECT SUM(amount) FROM regions AS schd
    WHERE schd.status = lne.status
);


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.type = schd.type
);


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

SELECT amount FROM regions AS rgn
WHERE salary > (
    SELECT COUNT(value) FROM sales AS prod
    WHERE prod.status = rgn.status
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM requests AS emp
    WHERE emp.id = shp.id
);


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

SELECT code FROM employees AS emp
WHERE value > (
    SELECT MIN(amount) FROM regions AS txn
    WHERE txn.id = emp.id
);


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

SELECT amount FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.status = empl.status
);


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

SELECT value FROM projects AS prj
WHERE level IN (
    SELECT level FROM employees AS sale
    WHERE sale.id = prj.id
);


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

SELECT value FROM projects AS prj
WHERE type IN (
    SELECT type FROM tasks AS mgr
    WHERE mgr.id = prj.id
);


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

SELECT amount FROM sales AS sale
WHERE type IN (
    SELECT type FROM employees AS schd
    WHERE schd.code = sale.code
);


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

SELECT salary FROM sales AS sale
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT value FROM projects AS prj
WHERE status IN (
    SELECT status FROM sales AS inv
    WHERE inv.level = prj.level
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.code = mgr.code
);


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

SELECT code FROM categories AS catg
WHERE status IN (
    SELECT status FROM regions AS lne
    WHERE lne.level = catg.level
);


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

SELECT name FROM items AS lne
WHERE id IN (
    SELECT id FROM employees AS lne
    WHERE lne.status = lne.status
);


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

SELECT id FROM sales AS sale
WHERE id IN (
    SELECT id FROM requests AS emp
    WHERE emp.id = sale.id
);


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

SELECT name FROM branches AS brc
WHERE level IN (
    SELECT level FROM shipments AS lne
    WHERE lne.level = brc.level
);


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

SELECT code FROM staff AS empl
WHERE level IN (
    SELECT level FROM shipments AS mgr
    WHERE mgr.id = empl.id
);


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

SELECT value FROM products AS prod
WHERE value > (
    SELECT SUM(amount) FROM transactions AS shp
    WHERE shp.code = prod.code
);


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

SELECT code FROM items AS lne
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS lne
    WHERE lne.type = lne.type
);


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

SELECT value FROM sales AS sale
WHERE code IN (
    SELECT code FROM accounts AS ord
    WHERE ord.level = sale.level
);


Prompt:
Schema:
  schedules (alias: schd)(level, value, date, amount)
  products(status, level, code, type)
Task: Find id from schedules where amount exceeds the total salary from products for the same code.
SQL:

SELECT id FROM schedules AS schd
WHERE amount > (
    SELECT SUM(salary) FROM products AS brc
    WHERE brc.code = schd.code
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.level = prod.level
);


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

SELECT amount FROM shipments AS shp
WHERE type IN (
    SELECT type FROM customers AS prod
    WHERE prod.level = shp.level
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM departments AS prj
    WHERE prj.id = brc.id
);


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = sale.level
);


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.code = brc.code
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM requests AS acct
    WHERE acct.type = rgn.type
);


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS tsk
    WHERE tsk.status = schd.status
);


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

SELECT id FROM transactions AS txn
WHERE code IN (
    SELECT code FROM regions AS dept
    WHERE dept.id = txn.id
);


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

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT SUM(value) FROM requests AS txn
    WHERE txn.status = lne.status
);


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

SELECT code FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.status = mgr.status
);


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

SELECT name FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.code = empl.code
);


Prompt:
Schema:
  requests (alias: ordr)(status, amount, level, type)
  invoices(type, name, status, amount)
Task: Find name from requests where value exceeds the total salary from invoices for the same status.
SQL:

SELECT name FROM requests AS ordr
WHERE value > (
    SELECT SUM(salary) FROM invoices AS catg
    WHERE catg.status = ordr.status
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM sales AS ordr
    WHERE ordr.status = prj.status
);


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

SELECT code FROM shipments AS shp
WHERE id IN (
    SELECT id FROM orders AS brc
    WHERE brc.id = shp.id
);


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM managers AS emp
    WHERE emp.code = schd.code
);


Prompt:
Schema:
  requests (alias: ordr)(type, level, value, code)
  projects(level, value, name, type)
Task: Find name from requests where value exceeds the minimum value from projects for the same type.
SQL:

SELECT name FROM requests AS ordr
WHERE value > (
    SELECT MIN(value) FROM projects AS brc
    WHERE brc.type = ordr.type
);


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

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


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

SELECT name FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM sales AS dept
    WHERE dept.id = tsk.id
);


Prompt:
Schema:
  schedules (alias: schd)(id, amount, status, code)
  invoices(status, salary, value, level)
Task: Find id from schedules where value exceeds the count of salary from invoices for the same level.
SQL:

SELECT id FROM schedules AS schd
WHERE value > (
    SELECT COUNT(salary) FROM invoices AS emp
    WHERE emp.level = schd.level
);


Prompt:
Schema:
  regions (alias: rgn)(amount, salary, code, id)
  customers(value, amount, id, level)
Task: Find code from regions where value exceeds the minimum salary from customers for the same type.
SQL:

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT MIN(salary) FROM customers AS shp
    WHERE shp.type = rgn.type
);


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

SELECT amount FROM accounts AS acct
WHERE type IN (
    SELECT type FROM employees AS empl
    WHERE empl.status = acct.status
);


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

SELECT value FROM customers AS cust
WHERE code IN (
    SELECT code FROM departments AS lne
    WHERE lne.code = cust.code
);


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

SELECT name FROM staff AS empl
WHERE level IN (
    SELECT level FROM schedules AS schd
    WHERE schd.code = empl.code
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM staff AS tsk
    WHERE tsk.type = sale.type
);


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

SELECT id FROM items AS lne
WHERE type IN (
    SELECT type FROM tasks AS inv
    WHERE inv.id = lne.id
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM sales AS brc
    WHERE brc.code = txn.code
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS tsk
    WHERE tsk.id = empl.id
);


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

SELECT amount FROM sales AS sale
WHERE salary > (
    SELECT AVG(value) FROM regions AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS tsk
    WHERE tsk.status = ordr.status
);


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

SELECT code FROM invoices AS inv
WHERE level IN (
    SELECT level FROM orders AS lne
    WHERE lne.id = inv.id
);


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

SELECT id FROM invoices AS inv
WHERE type IN (
    SELECT type FROM shipments AS ord
    WHERE ord.status = inv.status
);


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

SELECT name FROM staff AS empl
WHERE amount > (
    SELECT MIN(salary) FROM orders AS brc
    WHERE brc.type = empl.type
);


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

SELECT id FROM orders AS ord
WHERE salary > (
    SELECT COUNT(value) FROM projects AS dept
    WHERE dept.status = ord.status
);


Prompt:
Schema:
  branches (alias: brc)(amount, id, type, name)
  tasks(name, level, value, type)
Task: Find salary from branches where salary exceeds the count of amount from tasks for the same id.
SQL:

SELECT salary FROM branches AS brc
WHERE salary > (
    SELECT COUNT(amount) FROM tasks AS cust
    WHERE cust.id = brc.id
);


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

SELECT id FROM requests AS ordr
WHERE amount > (
    SELECT MIN(salary) FROM tasks AS mgr
    WHERE mgr.code = ordr.code
);


Prompt:
Schema:
  sales (alias: sale)(name, date, type, status)
  invoices(type, date, status, amount)
Task: Retrieve code from sales with value above the MAX(amount) of invoices rows sharing the same type.
SQL:

SELECT code FROM sales AS sale
WHERE value > (
    SELECT MAX(amount) FROM invoices AS prod
    WHERE prod.type = sale.type
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT code FROM employees AS emp
WHERE id IN (
    SELECT id FROM products AS cust
    WHERE cust.type = emp.type
);


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

SELECT id FROM projects AS prj
WHERE amount > (
    SELECT MAX(value) FROM sales AS empl
    WHERE empl.level = prj.level
);


Prompt:
Schema:
  staff (alias: empl)(salary, id, code, amount)
  accounts(date, amount, value, type)
Task: Find id from staff where salary exceeds the count of amount from accounts for the same code.
SQL:

SELECT id FROM staff AS empl
WHERE salary > (
    SELECT COUNT(amount) FROM accounts AS ord
    WHERE ord.code = empl.code
);


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

SELECT code FROM departments AS dept
WHERE code IN (
    SELECT code FROM orders AS txn
    WHERE txn.status = dept.status
);


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

SELECT code FROM branches AS brc
WHERE salary > (
    SELECT AVG(value) FROM employees AS lne
    WHERE lne.type = brc.type
);


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

SELECT salary FROM accounts AS acct
WHERE id IN (
    SELECT id FROM requests AS sale
    WHERE sale.code = acct.code
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.type = ordr.type
);


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

SELECT name FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.level = mgr.level
);


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM sales AS brc
    WHERE brc.id = txn.id
);


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

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


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.id = inv.id
);


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

SELECT code FROM employees AS emp
WHERE amount > (
    SELECT MAX(value) FROM departments AS inv
    WHERE inv.type = emp.type
);


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

SELECT amount FROM categories AS catg
WHERE id IN (
    SELECT id FROM items AS lne
    WHERE lne.code = catg.code
);


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

SELECT value FROM categories AS catg
WHERE value > (
    SELECT SUM(value) FROM invoices AS dept
    WHERE dept.type = catg.type
);


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

SELECT id FROM orders AS ord
WHERE status IN (
    SELECT status FROM invoices AS lne
    WHERE lne.level = ord.level
);


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

SELECT code FROM items AS lne
WHERE level IN (
    SELECT level FROM branches AS inv
    WHERE inv.level = lne.level
);


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

SELECT salary FROM categories AS catg
WHERE salary > (
    SELECT SUM(salary) FROM branches AS schd
    WHERE schd.type = catg.type
);


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

SELECT value FROM branches AS brc
WHERE status IN (
    SELECT status FROM regions AS emp
    WHERE emp.level = brc.level
);


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

SELECT amount FROM sales AS sale
WHERE salary > (
    SELECT COUNT(value) FROM regions AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT value FROM staff AS empl
WHERE amount > (
    SELECT MIN(value) FROM schedules AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT code FROM regions AS rgn
WHERE code IN (
    SELECT code FROM transactions AS dept
    WHERE dept.status = rgn.status
);


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

SELECT name FROM employees AS emp
WHERE value > (
    SELECT MAX(value) FROM regions AS dept
    WHERE dept.code = emp.code
);


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

SELECT code FROM sales AS sale
WHERE salary > (
    SELECT COUNT(value) FROM schedules AS inv
    WHERE inv.level = sale.level
);


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

SELECT name FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.level = tsk.level
);


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

SELECT code FROM orders AS ord
WHERE value > (
    SELECT MAX(salary) FROM branches AS cust
    WHERE cust.type = ord.type
);


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

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


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.id = ordr.id
);


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

SELECT value FROM projects AS prj
WHERE level IN (
    SELECT level FROM customers AS catg
    WHERE catg.type = prj.type
);


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

SELECT salary FROM accounts AS acct
WHERE salary > (
    SELECT MIN(amount) FROM projects AS catg
    WHERE catg.type = acct.type
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM items AS schd
    WHERE schd.level = ord.level
);


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

SELECT value FROM requests AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM orders AS rgn
    WHERE rgn.level = ordr.level
);


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

SELECT salary FROM regions AS rgn
WHERE level IN (
    SELECT level FROM items AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.type = acct.type
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM schedules AS dept
    WHERE dept.status = dept.status
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.level = emp.level
);


Prompt:
Schema:
  schedules (alias: schd)(salary, value, amount, id)
  sales(id, value, salary, date)
Task: Find amount from schedules where a matching record exists in sales with the same id.
SQL:

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM sales AS mgr
    WHERE mgr.id = schd.id
);


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

SELECT value FROM categories AS catg
WHERE status IN (
    SELECT status FROM products AS dept
    WHERE dept.type = catg.type
);


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.level = ordr.level
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = txn.type
);


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

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


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

SELECT amount FROM categories AS catg
WHERE amount > (
    SELECT SUM(amount) FROM regions AS shp
    WHERE shp.code = catg.code
);


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

SELECT value FROM branches AS brc
WHERE type IN (
    SELECT type FROM staff AS ordr
    WHERE ordr.type = brc.type
);


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM staff AS dept
    WHERE dept.id = inv.id
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS prj
    WHERE prj.type = acct.type
);


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

SELECT name FROM sales AS sale
WHERE status IN (
    SELECT status FROM managers AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM staff AS sale
    WHERE sale.type = rgn.type
);


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

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


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

SELECT id FROM shipments AS shp
WHERE code IN (
    SELECT code FROM sales AS shp
    WHERE shp.id = shp.id
);


Prompt:
Schema:
  branches (alias: brc)(salary, date, type, status)
  requests(id, date, salary, level)
Task: Find salary from branches where amount exceeds the total amount from requests for the same id.
SQL:

SELECT salary FROM branches AS brc
WHERE amount > (
    SELECT SUM(amount) FROM requests AS catg
    WHERE catg.id = brc.id
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM sales AS txn
    WHERE txn.code = schd.code
);


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

SELECT id FROM projects AS prj
WHERE amount > (
    SELECT MAX(salary) FROM employees AS tsk
    WHERE tsk.type = prj.type
);


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

SELECT amount FROM accounts AS acct
WHERE amount > (
    SELECT MAX(salary) FROM requests AS prod
    WHERE prod.code = acct.code
);


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

SELECT amount FROM transactions AS txn
WHERE salary > (
    SELECT SUM(value) FROM requests AS acct
    WHERE acct.type = txn.type
);


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

SELECT code FROM shipments AS shp
WHERE id IN (
    SELECT id FROM items AS txn
    WHERE txn.type = shp.type
);


Prompt:
Schema:
  staff (alias: empl)(value, salary, code, name)
  invoices(salary, type, status, amount)
Task: Find name from staff where amount exceeds the total value from invoices for the same status.
SQL:

SELECT name FROM staff AS empl
WHERE amount > (
    SELECT SUM(value) FROM invoices AS rgn
    WHERE rgn.status = empl.status
);


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

SELECT name FROM tasks AS tsk
WHERE value > (
    SELECT MIN(amount) FROM regions AS catg
    WHERE catg.status = tsk.status
);


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

SELECT salary FROM regions AS rgn
WHERE level IN (
    SELECT level FROM products AS shp
    WHERE shp.status = rgn.status
);


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

SELECT id FROM managers AS mgr
WHERE value > (
    SELECT MIN(value) FROM employees AS inv
    WHERE inv.status = mgr.status
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.code = prj.code
);


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

SELECT salary FROM transactions AS txn
WHERE salary > (
    SELECT SUM(value) FROM managers AS catg
    WHERE catg.id = txn.id
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM products AS rgn
    WHERE rgn.type = rgn.type
);


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

SELECT code FROM staff AS empl
WHERE level IN (
    SELECT level FROM departments AS inv
    WHERE inv.code = empl.code
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM schedules AS cust
    WHERE cust.level = lne.level
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.level = inv.level
);


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT SUM(salary) FROM projects AS txn
    WHERE txn.id = cust.id
);


Prompt:
Schema:
  products (alias: prod)(level, value, name, status)
  requests(amount, date, salary, code)
Task: Find amount from products where salary exceeds the count of salary from requests for the same type.
SQL:

SELECT amount FROM products AS prod
WHERE salary > (
    SELECT COUNT(salary) FROM requests AS brc
    WHERE brc.type = prod.type
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.status = prj.status
);


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

SELECT id FROM accounts AS acct
WHERE level IN (
    SELECT level FROM schedules AS prod
    WHERE prod.status = acct.status
);


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

SELECT salary FROM projects AS prj
WHERE id IN (
    SELECT id FROM tasks AS sale
    WHERE sale.code = prj.code
);


Prompt:
Schema:
  staff (alias: empl)(level, id, type, code)
  accounts(code, salary, type, name)
Task: Find id from staff where amount exceeds the minimum value from accounts for the same type.
SQL:

SELECT id FROM staff AS empl
WHERE amount > (
    SELECT MIN(value) FROM accounts AS prj
    WHERE prj.type = empl.type
);


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

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


Prompt:
Schema:
  tasks (alias: tsk)(name, level, status, value)
  products(name, date, value, id)
Task: Find id from tasks where value exceeds the total value from products for the same code.
SQL:

SELECT id FROM tasks AS tsk
WHERE value > (
    SELECT SUM(value) FROM products AS txn
    WHERE txn.code = tsk.code
);


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM transactions AS prj
    WHERE prj.type = prj.type
);


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

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


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

SELECT salary FROM branches AS brc
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.level = brc.level
);


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

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


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

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


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

SELECT name FROM customers AS cust
WHERE level IN (
    SELECT level FROM sales AS lne
    WHERE lne.code = cust.code
);


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

SELECT value FROM sales AS sale
WHERE value > (
    SELECT COUNT(salary) FROM departments AS sale
    WHERE sale.type = sale.type
);


Prompt:
Schema:
  staff (alias: empl)(level, code, value, type)
  employees(name, salary, code, level)
Task: Find id from staff where salary exceeds the maximum amount from employees for the same code.
SQL:

SELECT id FROM staff AS empl
WHERE salary > (
    SELECT MAX(amount) FROM employees AS mgr
    WHERE mgr.code = empl.code
);


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

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


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

SELECT id FROM accounts AS acct
WHERE amount > (
    SELECT AVG(amount) FROM schedules AS ord
    WHERE ord.status = acct.status
);


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

SELECT amount FROM projects AS prj
WHERE salary > (
    SELECT SUM(salary) FROM orders AS prod
    WHERE prod.level = prj.level
);


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

SELECT salary FROM managers AS mgr
WHERE salary > (
    SELECT SUM(amount) FROM projects AS tsk
    WHERE tsk.level = mgr.level
);


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

SELECT value FROM sales AS sale
WHERE id IN (
    SELECT id FROM shipments AS emp
    WHERE emp.type = sale.type
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM staff AS lne
    WHERE lne.id = ordr.id
);


Prompt:
Schema:
  schedules (alias: schd)(date, name, id, amount)
  items(name, level, status, amount)
Task: Find salary from schedules where amount exceeds the count of value from items for the same code.
SQL:

SELECT salary FROM schedules AS schd
WHERE amount > (
    SELECT COUNT(value) FROM items AS prj
    WHERE prj.code = schd.code
);


Prompt:
Schema:
  tasks (alias: tsk)(type, level, value, status)
  accounts(date, level, type, value)
Task: Find value from tasks where amount exceeds the maximum amount from accounts for the same level.
SQL:

SELECT value FROM tasks AS tsk
WHERE amount > (
    SELECT MAX(amount) FROM accounts AS dept
    WHERE dept.level = tsk.level
);


Prompt:
Schema:
  invoices (alias: inv)(amount, salary, type, code)
  staff(type, salary, id, code)
Task: Find amount from invoices where amount exceeds the total amount from staff for the same type.
SQL:

SELECT amount FROM invoices AS inv
WHERE amount > (
    SELECT SUM(amount) FROM staff AS empl
    WHERE empl.type = inv.type
);


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

SELECT code FROM products AS prod
WHERE value > (
    SELECT SUM(amount) FROM projects AS acct
    WHERE acct.id = prod.id
);


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

SELECT id FROM invoices AS inv
WHERE salary > (
    SELECT SUM(amount) FROM products AS sale
    WHERE sale.type = inv.type
);


Prompt:
Schema:
  sales (alias: sale)(level, name, status, code)
  employees(name, date, amount, id)
Task: Find name from sales where salary exceeds the maximum salary from employees for the same code.
SQL:

SELECT name FROM sales AS sale
WHERE salary > (
    SELECT MAX(salary) FROM employees AS catg
    WHERE catg.code = sale.code
);


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

SELECT amount FROM tasks AS tsk
WHERE salary > (
    SELECT MAX(salary) FROM products AS schd
    WHERE schd.status = tsk.status
);


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.type = prj.type
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM sales AS inv
    WHERE inv.id = dept.id
);


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

SELECT salary FROM items AS lne
WHERE amount > (
    SELECT COUNT(value) FROM staff AS prj
    WHERE prj.status = lne.status
);


Prompt:
Schema:
  products (alias: prod)(date, value, code, status)
  sales(code, level, status, name)
Task: Find value from products where value exceeds the total value from sales for the same level.
SQL:

SELECT value FROM products AS prod
WHERE value > (
    SELECT SUM(value) FROM sales AS dept
    WHERE dept.level = prod.level
);


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

SELECT name FROM schedules AS schd
WHERE status IN (
    SELECT status FROM customers AS txn
    WHERE txn.code = schd.code
);


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

SELECT salary FROM staff AS empl
WHERE id IN (
    SELECT id FROM invoices AS prj
    WHERE prj.code = empl.code
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.level = prj.level
);


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

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


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM schedules AS cust
    WHERE cust.id = txn.id
);


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

SELECT value FROM invoices AS inv
WHERE status IN (
    SELECT status FROM transactions AS tsk
    WHERE tsk.status = inv.status
);


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

SELECT id FROM sales AS sale
WHERE code IN (
    SELECT code FROM customers AS empl
    WHERE empl.level = sale.level
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM schedules AS catg
    WHERE catg.status = mgr.status
);


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.level = ordr.level
);


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

SELECT name FROM managers AS mgr
WHERE status IN (
    SELECT status FROM items AS acct
    WHERE acct.type = mgr.type
);


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

SELECT value FROM schedules AS schd
WHERE id IN (
    SELECT id FROM requests AS ord
    WHERE ord.id = schd.id
);


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

SELECT id FROM customers AS cust
WHERE code IN (
    SELECT code FROM items AS empl
    WHERE empl.id = cust.id
);


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

SELECT amount FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.id = tsk.id
);


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

SELECT name FROM products AS prod
WHERE id IN (
    SELECT id FROM orders AS ord
    WHERE ord.type = prod.type
);


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

SELECT value FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.status = ord.status
);


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

SELECT salary FROM departments AS dept
WHERE code IN (
    SELECT code FROM accounts AS empl
    WHERE empl.code = dept.code
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.type = inv.type
);


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

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS brc
    WHERE brc.id = schd.id
);


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

SELECT name FROM invoices AS inv
WHERE type IN (
    SELECT type FROM customers AS sale
    WHERE sale.code = inv.code
);


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

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = shp.status
);


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

SELECT salary FROM requests AS ordr
WHERE value > (
    SELECT AVG(salary) FROM customers AS ord
    WHERE ord.level = ordr.level
);


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

SELECT value FROM staff AS empl
WHERE salary > (
    SELECT AVG(salary) FROM projects AS catg
    WHERE catg.type = empl.type
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM staff AS txn
    WHERE txn.level = txn.level
);


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

SELECT id FROM managers AS mgr
WHERE value > (
    SELECT AVG(salary) FROM customers AS catg
    WHERE catg.status = mgr.status
);


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

SELECT amount FROM invoices AS inv
WHERE value > (
    SELECT MIN(amount) FROM categories AS prod
    WHERE prod.code = inv.code
);


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

SELECT salary FROM customers AS cust
WHERE status IN (
    SELECT status FROM requests AS lne
    WHERE lne.type = cust.type
);


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

SELECT salary FROM employees AS emp
WHERE status IN (
    SELECT status FROM managers AS emp
    WHERE emp.code = emp.code
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.id = prj.id
);


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

SELECT salary FROM staff AS empl
WHERE amount > (
    SELECT SUM(value) FROM accounts AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT salary FROM branches AS brc
WHERE status IN (
    SELECT status FROM orders AS mgr
    WHERE mgr.code = brc.code
);


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

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT MAX(value) FROM staff AS mgr
    WHERE mgr.type = shp.type
);


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

SELECT salary FROM schedules AS schd
WHERE type IN (
    SELECT type FROM branches AS prod
    WHERE prod.id = schd.id
);


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

SELECT value FROM categories AS catg
WHERE type IN (
    SELECT type FROM departments AS tsk
    WHERE tsk.status = catg.status
);


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

SELECT amount FROM employees AS emp
WHERE status IN (
    SELECT status FROM projects AS cust
    WHERE cust.type = emp.type
);


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM employees AS brc
    WHERE brc.id = ord.id
);


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

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


Prompt:
Schema:
  managers (alias: mgr)(name, salary, type, amount)
  categories(type, salary, amount, code)
Task: Find value from managers where value exceeds the total salary from categories for the same code.
SQL:

SELECT value FROM managers AS mgr
WHERE value > (
    SELECT SUM(salary) FROM categories AS prj
    WHERE prj.code = mgr.code
);


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

SELECT id FROM branches AS brc
WHERE type IN (
    SELECT type FROM employees AS sale
    WHERE sale.id = brc.id
);


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

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


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.code = prod.code
);


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

SELECT value FROM products AS prod
WHERE status IN (
    SELECT status FROM items AS cust
    WHERE cust.type = prod.type
);


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT MAX(salary) FROM tasks AS shp
    WHERE shp.type = prod.type
);


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

SELECT salary FROM accounts AS acct
WHERE amount > (
    SELECT SUM(value) FROM managers AS sale
    WHERE sale.status = acct.status
);


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT name FROM invoices AS inv
WHERE type IN (
    SELECT type FROM managers AS sale
    WHERE sale.status = inv.status
);


Prompt:
Schema:
  products (alias: prod)(id, name, status, salary)
  transactions(level, amount, id, code)
Task: Find amount from products where salary exceeds the count of salary from transactions for the same id.
SQL:

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


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

SELECT name FROM requests AS ordr
WHERE value > (
    SELECT SUM(salary) FROM customers AS cust
    WHERE cust.type = ordr.type
);


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

SELECT id FROM orders AS ord
WHERE value > (
    SELECT AVG(salary) FROM accounts AS tsk
    WHERE tsk.id = ord.id
);


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

SELECT id FROM sales AS sale
WHERE amount > (
    SELECT AVG(value) FROM schedules AS catg
    WHERE catg.code = sale.code
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM requests AS prod
    WHERE prod.code = sale.code
);


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT AVG(value) FROM transactions AS prj
    WHERE prj.status = prod.status
);


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

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT AVG(salary) FROM items AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT code FROM transactions AS txn
WHERE id IN (
    SELECT id FROM departments AS ord
    WHERE ord.level = txn.level
);


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

SELECT id FROM staff AS empl
WHERE id IN (
    SELECT id FROM categories AS empl
    WHERE empl.status = empl.status
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.id = tsk.id
);


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

SELECT code FROM departments AS dept
WHERE code IN (
    SELECT code FROM requests AS dept
    WHERE dept.type = dept.type
);


Prompt:
Schema:
  requests (alias: ordr)(id, salary, level, status)
  sales(salary, level, name, value)
Task: Retrieve value from requests with value above the MAX(salary) of sales rows sharing the same type.
SQL:

SELECT value FROM requests AS ordr
WHERE value > (
    SELECT MAX(salary) FROM sales AS lne
    WHERE lne.type = ordr.type
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS brc
    WHERE brc.type = shp.type
);


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

SELECT amount FROM transactions AS txn
WHERE amount > (
    SELECT MIN(value) FROM employees AS inv
    WHERE inv.type = txn.type
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM requests AS catg
    WHERE catg.code = sale.code
);


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

SELECT code FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM departments AS schd
    WHERE schd.id = tsk.id
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS dept
    WHERE dept.type = rgn.type
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.status = schd.status
);


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

SELECT salary FROM regions AS rgn
WHERE id IN (
    SELECT id FROM tasks AS brc
    WHERE brc.status = rgn.status
);


Prompt:
Schema:
  staff (alias: empl)(code, value, amount, id)
  tasks(amount, code, name, level)
Task: Find code from staff where salary exceeds the minimum salary from tasks for the same status.
SQL:

SELECT code FROM staff AS empl
WHERE salary > (
    SELECT MIN(salary) FROM tasks AS lne
    WHERE lne.status = empl.status
);


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT MAX(salary) FROM categories AS emp
    WHERE emp.type = prod.type
);


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

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


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

SELECT id FROM staff AS empl
WHERE status IN (
    SELECT status FROM sales AS catg
    WHERE catg.status = empl.status
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.code = acct.code
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.type = empl.type
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.level = tsk.level
);


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

SELECT salary FROM shipments AS shp
WHERE level IN (
    SELECT level FROM branches AS sale
    WHERE sale.id = shp.id
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM managers AS prod
    WHERE prod.status = brc.status
);


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

SELECT code FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM categories AS brc
    WHERE brc.level = tsk.level
);


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

SELECT id FROM sales AS sale
WHERE type IN (
    SELECT type FROM invoices AS empl
    WHERE empl.id = sale.id
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM items AS prj
    WHERE prj.code = shp.code
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.id = empl.id
);


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

SELECT id FROM branches AS brc
WHERE amount > (
    SELECT MIN(value) FROM customers AS sale
    WHERE sale.status = brc.status
);


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.code = txn.code
);


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

SELECT value FROM shipments AS shp
WHERE salary > (
    SELECT AVG(salary) FROM products AS ord
    WHERE ord.status = shp.status
);


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

SELECT amount FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM transactions AS cust
    WHERE cust.level = tsk.level
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM sales AS acct
    WHERE acct.id = emp.id
);


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

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


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

SELECT name FROM shipments AS shp
WHERE value > (
    SELECT MIN(salary) FROM accounts AS dept
    WHERE dept.code = shp.code
);


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

SELECT value FROM requests AS ordr
WHERE level IN (
    SELECT level FROM items AS dept
    WHERE dept.status = ordr.status
);


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

SELECT value FROM customers AS cust
WHERE amount > (
    SELECT AVG(amount) FROM branches AS prj
    WHERE prj.id = cust.id
);


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

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


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

SELECT id FROM schedules AS schd
WHERE status IN (
    SELECT status FROM branches AS catg
    WHERE catg.level = schd.level
);


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

SELECT code FROM departments AS dept
WHERE status IN (
    SELECT status FROM branches AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.code = emp.code
);


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

SELECT salary FROM customers AS cust
WHERE salary > (
    SELECT AVG(amount) FROM managers AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT value FROM managers AS mgr
WHERE type IN (
    SELECT type FROM transactions AS ordr
    WHERE ordr.status = mgr.status
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.level = emp.level
);


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

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM requests AS brc
    WHERE brc.status = mgr.status
);


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

SELECT code FROM products AS prod
WHERE value > (
    SELECT AVG(salary) FROM sales AS sale
    WHERE sale.type = prod.type
);


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

SELECT id FROM categories AS catg
WHERE amount > (
    SELECT MAX(value) FROM accounts AS sale
    WHERE sale.code = catg.code
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM requests AS shp
    WHERE shp.type = brc.type
);


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM projects AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT amount FROM customers AS cust
WHERE level IN (
    SELECT level FROM requests AS schd
    WHERE schd.id = cust.id
);


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

SELECT id FROM schedules AS schd
WHERE level IN (
    SELECT level FROM requests AS prj
    WHERE prj.id = schd.id
);


Prompt:
Schema:
  regions (alias: rgn)(type, status, date, name)
  tasks(value, date, name, salary)
Task: Find code from regions where value exceeds the total value from tasks for the same type.
SQL:

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT SUM(value) FROM tasks AS prj
    WHERE prj.type = rgn.type
);


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

SELECT code FROM employees AS emp
WHERE value > (
    SELECT SUM(salary) FROM products AS dept
    WHERE dept.type = emp.type
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.level = rgn.level
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM items AS mgr
    WHERE mgr.status = emp.status
);


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

SELECT name FROM requests AS ordr
WHERE type IN (
    SELECT type FROM schedules AS rgn
    WHERE rgn.id = ordr.id
);


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

SELECT value FROM requests AS ordr
WHERE value > (
    SELECT MAX(value) FROM employees AS emp
    WHERE emp.type = ordr.type
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS brc
    WHERE brc.type = cust.type
);


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

SELECT salary FROM items AS lne
WHERE level IN (
    SELECT level FROM invoices AS shp
    WHERE shp.status = lne.status
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.code = lne.code
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM staff AS mgr
    WHERE mgr.level = txn.level
);


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

SELECT name FROM customers AS cust
WHERE type IN (
    SELECT type FROM regions AS sale
    WHERE sale.id = cust.id
);


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

SELECT id FROM employees AS emp
WHERE value > (
    SELECT MIN(amount) FROM departments AS ord
    WHERE ord.code = emp.code
);


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

SELECT amount FROM categories AS catg
WHERE status IN (
    SELECT status FROM schedules AS dept
    WHERE dept.id = catg.id
);


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

SELECT id FROM projects AS prj
WHERE level IN (
    SELECT level FROM employees AS tsk
    WHERE tsk.type = prj.type
);


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

SELECT amount FROM invoices AS inv
WHERE value > (
    SELECT MIN(salary) FROM customers AS schd
    WHERE schd.level = inv.level
);


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

SELECT id FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = lne.code
);


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

SELECT name FROM staff AS empl
WHERE type IN (
    SELECT type FROM items AS dept
    WHERE dept.code = empl.code
);


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

SELECT id FROM staff AS empl
WHERE salary > (
    SELECT MIN(value) FROM shipments AS prj
    WHERE prj.type = empl.type
);


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

SELECT value FROM shipments AS shp
WHERE code IN (
    SELECT code FROM staff AS emp
    WHERE emp.code = shp.code
);


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

SELECT name FROM requests AS ordr
WHERE level IN (
    SELECT level FROM items AS catg
    WHERE catg.status = ordr.status
);


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

SELECT name FROM branches AS brc
WHERE type IN (
    SELECT type FROM shipments AS rgn
    WHERE rgn.id = brc.id
);


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

SELECT code FROM categories AS catg
WHERE status IN (
    SELECT status FROM employees AS empl
    WHERE empl.level = catg.level
);


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

SELECT value FROM accounts AS acct
WHERE type IN (
    SELECT type FROM staff AS dept
    WHERE dept.status = acct.status
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.type = inv.type
);


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

SELECT amount FROM items AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS txn
    WHERE txn.id = lne.id
);


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

SELECT name FROM transactions AS txn
WHERE type IN (
    SELECT type FROM orders AS rgn
    WHERE rgn.level = txn.level
);


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM schedules AS dept
    WHERE dept.id = inv.id
);


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

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


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.status = cust.status
);


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

SELECT name FROM managers AS mgr
WHERE type IN (
    SELECT type FROM requests AS catg
    WHERE catg.status = mgr.status
);


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

SELECT id FROM products AS prod
WHERE amount > (
    SELECT AVG(amount) FROM managers AS ord
    WHERE ord.level = prod.level
);


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = schd.id
);