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

SELECT value FROM sales AS sale
WHERE status IN (
    SELECT status FROM tasks AS prj
    WHERE prj.type = sale.type
);


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

SELECT code FROM sales AS sale
WHERE value > (
    SELECT SUM(salary) FROM orders AS cust
    WHERE cust.level = sale.level
);


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT MIN(amount) FROM schedules AS schd
    WHERE schd.type = prj.type
);


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

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


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

SELECT name FROM items AS lne
WHERE status IN (
    SELECT status FROM projects AS dept
    WHERE dept.level = lne.level
);


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

SELECT value FROM staff AS empl
WHERE amount > (
    SELECT AVG(salary) FROM requests AS acct
    WHERE acct.type = empl.type
);


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

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


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

SELECT code FROM invoices AS inv
WHERE value > (
    SELECT COUNT(value) FROM projects AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT salary FROM orders AS ord
WHERE code IN (
    SELECT code FROM items AS empl
    WHERE empl.status = ord.status
);


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

SELECT name FROM shipments AS shp
WHERE amount > (
    SELECT MIN(amount) FROM transactions AS empl
    WHERE empl.code = shp.code
);


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

SELECT amount FROM managers AS mgr
WHERE value > (
    SELECT MIN(amount) FROM items AS ord
    WHERE ord.level = mgr.level
);


Prompt:
Schema:
  tasks (alias: tsk)(date, salary, name, type)
  invoices(date, id, salary, status)
Task: Find value from tasks where amount exceeds the count of amount from invoices for the same type.
SQL:

SELECT value FROM tasks AS tsk
WHERE amount > (
    SELECT COUNT(amount) FROM invoices AS inv
    WHERE inv.type = tsk.type
);


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

SELECT value FROM customers AS cust
WHERE salary > (
    SELECT AVG(salary) FROM departments AS mgr
    WHERE mgr.code = cust.code
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT salary FROM sales AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM customers AS lne
    WHERE lne.level = sale.level
);


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

SELECT salary FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM regions AS dept
    WHERE dept.type = tsk.type
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM schedules AS emp
    WHERE emp.id = prj.id
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS prj
    WHERE prj.code = txn.code
);


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

SELECT value FROM shipments AS shp
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS prod
    WHERE prod.id = shp.id
);


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

SELECT name FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS mgr
    WHERE mgr.status = tsk.status
);


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

SELECT name FROM items AS lne
WHERE level IN (
    SELECT level FROM shipments AS schd
    WHERE schd.status = lne.status
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM sales AS schd
    WHERE schd.code = tsk.code
);


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

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


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

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


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

SELECT code FROM transactions AS txn
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS rgn
    WHERE rgn.code = txn.code
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.id = prod.id
);


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

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


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

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


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

SELECT code FROM products AS prod
WHERE level IN (
    SELECT level FROM invoices AS acct
    WHERE acct.type = prod.type
);


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.code = cust.code
);


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

SELECT code FROM transactions AS txn
WHERE value > (
    SELECT AVG(value) FROM requests AS catg
    WHERE catg.code = txn.code
);


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

SELECT code FROM employees AS emp
WHERE amount > (
    SELECT MAX(value) FROM categories AS lne
    WHERE lne.level = emp.level
);


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

SELECT name FROM shipments AS shp
WHERE amount > (
    SELECT MAX(value) FROM tasks AS cust
    WHERE cust.code = shp.code
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM items AS dept
    WHERE dept.id = catg.id
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM sales AS emp
    WHERE emp.code = acct.code
);


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

SELECT code FROM items AS lne
WHERE level IN (
    SELECT level FROM invoices AS tsk
    WHERE tsk.id = lne.id
);


Prompt:
Schema:
  employees (alias: emp)(type, id, status, value)
  shipments(amount, id, salary, code)
Task: Find value from employees where value exceeds the count of amount from shipments for the same type.
SQL:

SELECT value FROM employees AS emp
WHERE value > (
    SELECT COUNT(amount) FROM shipments AS dept
    WHERE dept.type = emp.type
);


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

SELECT salary FROM tasks AS tsk
WHERE amount > (
    SELECT MAX(salary) FROM branches AS prod
    WHERE prod.level = tsk.level
);


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

SELECT amount FROM transactions AS txn
WHERE status IN (
    SELECT status FROM categories AS ordr
    WHERE ordr.id = txn.id
);


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

SELECT amount FROM customers AS cust
WHERE id IN (
    SELECT id FROM categories AS schd
    WHERE schd.code = cust.code
);


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

SELECT value FROM employees AS emp
WHERE salary > (
    SELECT COUNT(value) FROM managers AS ord
    WHERE ord.type = emp.type
);


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

SELECT value FROM departments AS dept
WHERE status IN (
    SELECT status FROM schedules AS acct
    WHERE acct.id = dept.id
);


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT name FROM managers AS mgr
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.level = mgr.level
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.code = brc.code
);


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

SELECT id FROM staff AS empl
WHERE level IN (
    SELECT level FROM departments AS ord
    WHERE ord.type = empl.type
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.status = prj.status
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM sales AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT salary FROM requests AS ordr
WHERE code IN (
    SELECT code FROM shipments AS sale
    WHERE sale.status = ordr.status
);


Prompt:
Schema:
  orders (alias: ord)(id, value, status, amount)
  sales(salary, value, status, code)
Task: Find amount from orders where value exceeds the maximum value from sales for the same status.
SQL:

SELECT amount FROM orders AS ord
WHERE value > (
    SELECT MAX(value) FROM sales AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT id FROM transactions AS txn
WHERE value > (
    SELECT COUNT(value) FROM invoices AS prj
    WHERE prj.level = txn.level
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS ord
    WHERE ord.id = emp.id
);


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

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


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM schedules AS dept
    WHERE dept.status = prj.status
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.id = schd.id
);


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

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


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.code = inv.code
);


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

SELECT name FROM regions AS rgn
WHERE type IN (
    SELECT type FROM transactions AS mgr
    WHERE mgr.code = rgn.code
);


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

SELECT salary FROM managers AS mgr
WHERE value > (
    SELECT AVG(salary) FROM employees AS dept
    WHERE dept.code = mgr.code
);


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

SELECT name FROM products AS prod
WHERE salary > (
    SELECT COUNT(value) FROM sales AS ord
    WHERE ord.id = prod.id
);


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

SELECT name FROM customers AS cust
WHERE status IN (
    SELECT status FROM departments AS rgn
    WHERE rgn.status = cust.status
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE status IN (
    SELECT status FROM invoices AS brc
    WHERE brc.code = mgr.code
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.code = tsk.code
);


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.type = emp.type
);


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

SELECT value FROM staff AS empl
WHERE type IN (
    SELECT type FROM products AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM managers AS txn
    WHERE txn.type = dept.type
);


Prompt:
Schema:
  branches (alias: brc)(value, date, name, id)
  departments(value, date, code, type)
Task: Find name from branches where salary exceeds the minimum salary from departments for the same level.
SQL:

SELECT name FROM branches AS brc
WHERE salary > (
    SELECT MIN(salary) FROM departments AS sale
    WHERE sale.level = brc.level
);


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.code = sale.code
);


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT amount FROM requests AS ordr
WHERE amount > (
    SELECT MIN(amount) FROM orders AS acct
    WHERE acct.level = ordr.level
);


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

SELECT salary FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(salary) FROM items AS inv
    WHERE inv.type = tsk.type
);


Prompt:
Schema:
  regions (alias: rgn)(value, id, date, level)
  projects(amount, value, date, salary)
Task: Find value from regions where value exceeds the total amount from projects for the same id.
SQL:

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT SUM(amount) FROM projects AS sale
    WHERE sale.id = rgn.id
);


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

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


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.code = prj.code
);


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

SELECT id FROM orders AS ord
WHERE value > (
    SELECT MIN(value) FROM categories AS empl
    WHERE empl.level = ord.level
);


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

SELECT value FROM regions AS rgn
WHERE level IN (
    SELECT level FROM sales AS shp
    WHERE shp.code = rgn.code
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.type = lne.type
);


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

SELECT value FROM schedules AS schd
WHERE id IN (
    SELECT id FROM sales AS catg
    WHERE catg.id = schd.id
);


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

SELECT amount FROM managers AS mgr
WHERE type IN (
    SELECT type FROM customers AS emp
    WHERE emp.status = mgr.status
);


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

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


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

SELECT value FROM requests AS ordr
WHERE salary > (
    SELECT AVG(value) FROM regions AS ordr
    WHERE ordr.type = ordr.type
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.code = acct.code
);


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

SELECT name FROM managers AS mgr
WHERE type IN (
    SELECT type FROM employees AS txn
    WHERE txn.status = mgr.status
);


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

SELECT value FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.code = tsk.code
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM sales AS catg
    WHERE catg.status = prod.status
);


Prompt:
Schema:
  orders (alias: ord)(date, level, salary, type)
  sales(name, level, id, date)
Task: Find name from orders where salary exceeds the count of amount from sales for the same type.
SQL:

SELECT name FROM orders AS ord
WHERE salary > (
    SELECT COUNT(amount) FROM sales AS prj
    WHERE prj.type = ord.type
);


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

SELECT code FROM employees AS emp
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS rgn
    WHERE rgn.type = emp.type
);


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.status = rgn.status
);


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

SELECT value FROM departments AS dept
WHERE code IN (
    SELECT code FROM branches AS sale
    WHERE sale.id = dept.id
);


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

SELECT id FROM branches AS brc
WHERE amount > (
    SELECT MAX(value) FROM requests AS prod
    WHERE prod.status = brc.status
);


Prompt:
Schema:
  tasks (alias: tsk)(date, salary, id, level)
  transactions(id, status, level, salary)
Task: Find salary from tasks where salary exceeds the minimum amount from transactions for the same type.
SQL:

SELECT salary FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(amount) FROM transactions AS prod
    WHERE prod.type = tsk.type
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.status = brc.status
);


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT salary FROM requests AS ordr
WHERE value > (
    SELECT SUM(salary) FROM accounts AS shp
    WHERE shp.status = ordr.status
);


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

SELECT code FROM items AS lne
WHERE value > (
    SELECT SUM(amount) FROM categories AS prj
    WHERE prj.level = lne.level
);


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

SELECT salary FROM categories AS catg
WHERE level IN (
    SELECT level FROM accounts AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT code FROM regions AS rgn
WHERE level IN (
    SELECT level FROM staff AS cust
    WHERE cust.type = rgn.type
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM requests AS inv
    WHERE inv.code = cust.code
);


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

SELECT code FROM departments AS dept
WHERE value > (
    SELECT MAX(value) FROM tasks AS brc
    WHERE brc.id = dept.id
);


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

SELECT amount FROM transactions AS txn
WHERE status IN (
    SELECT status FROM regions AS sale
    WHERE sale.id = txn.id
);


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

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


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

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


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

SELECT value FROM managers AS mgr
WHERE type IN (
    SELECT type FROM invoices AS schd
    WHERE schd.id = mgr.id
);


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

SELECT code FROM customers AS cust
WHERE level IN (
    SELECT level FROM departments AS inv
    WHERE inv.id = cust.id
);


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

SELECT amount FROM categories AS catg
WHERE value > (
    SELECT MAX(amount) FROM customers AS prj
    WHERE prj.level = catg.level
);


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

SELECT salary FROM accounts AS acct
WHERE status IN (
    SELECT status FROM departments AS sale
    WHERE sale.status = acct.status
);


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

SELECT code FROM invoices AS inv
WHERE type IN (
    SELECT type FROM accounts AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT id FROM tasks AS tsk
WHERE salary > (
    SELECT SUM(amount) FROM customers AS schd
    WHERE schd.type = tsk.type
);


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

SELECT name FROM employees AS emp
WHERE status IN (
    SELECT status FROM staff AS ord
    WHERE ord.type = emp.type
);


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

SELECT value FROM regions AS rgn
WHERE amount > (
    SELECT MAX(amount) FROM staff AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT salary FROM invoices AS inv
WHERE value > (
    SELECT MAX(value) FROM departments AS schd
    WHERE schd.type = inv.type
);


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

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


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.status = dept.status
);


Prompt:
Schema:
  projects (alias: prj)(amount, value, type, level)
  regions(code, value, status, id)
Task: Find amount from projects where salary exceeds the count of salary from regions for the same code.
SQL:

SELECT amount FROM projects AS prj
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS lne
    WHERE lne.code = prj.code
);


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

SELECT code FROM regions AS rgn
WHERE status IN (
    SELECT status FROM schedules AS lne
    WHERE lne.type = rgn.type
);


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

SELECT value FROM employees AS emp
WHERE amount > (
    SELECT MAX(value) FROM invoices AS prj
    WHERE prj.id = emp.id
);


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

SELECT code FROM invoices AS inv
WHERE value > (
    SELECT AVG(value) FROM accounts AS brc
    WHERE brc.type = inv.type
);


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

SELECT id FROM orders AS ord
WHERE code IN (
    SELECT code FROM categories AS catg
    WHERE catg.status = ord.status
);


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

SELECT salary FROM products AS prod
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS dept
    WHERE dept.level = prod.level
);


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM schedules AS lne
    WHERE lne.status = sale.status
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM requests AS schd
    WHERE schd.type = catg.type
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.level = prod.level
);


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

SELECT code FROM invoices AS inv
WHERE level IN (
    SELECT level FROM orders AS txn
    WHERE txn.type = inv.type
);


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

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


Prompt:
Schema:
  invoices (alias: inv)(date, code, type, amount)
  schedules(status, code, amount, value)
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:
  shipments (alias: shp)(type, salary, level, date)
  invoices(level, id, salary, status)
Task: Find id from shipments where a matching record exists in invoices with the same level.
SQL:

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


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT SUM(amount) FROM departments AS dept
    WHERE dept.id = cust.id
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM tasks AS inv
    WHERE inv.level = dept.level
);


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

SELECT amount FROM projects AS prj
WHERE id IN (
    SELECT id FROM categories AS prj
    WHERE prj.id = prj.id
);


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

SELECT amount FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM managers AS cust
    WHERE cust.id = tsk.id
);


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM products AS prj
    WHERE prj.level = prj.level
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM items AS brc
    WHERE brc.status = txn.status
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS cust
    WHERE cust.type = rgn.type
);


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

SELECT salary FROM managers AS mgr
WHERE id IN (
    SELECT id FROM branches AS schd
    WHERE schd.id = mgr.id
);


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

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.level = shp.level
);


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

SELECT code FROM regions AS rgn
WHERE amount > (
    SELECT MIN(value) FROM transactions AS sale
    WHERE sale.level = rgn.level
);


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

SELECT amount FROM departments AS dept
WHERE code IN (
    SELECT code FROM schedules AS prod
    WHERE prod.type = dept.type
);


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

SELECT code FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM sales AS tsk
    WHERE tsk.type = cust.type
);


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

SELECT name FROM regions AS rgn
WHERE id IN (
    SELECT id FROM departments AS tsk
    WHERE tsk.code = rgn.code
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM managers AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.status = lne.status
);


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

SELECT name FROM products AS prod
WHERE code IN (
    SELECT code FROM employees AS ordr
    WHERE ordr.status = prod.status
);


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

SELECT amount FROM staff AS empl
WHERE salary > (
    SELECT COUNT(salary) FROM sales AS dept
    WHERE dept.level = empl.level
);


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

SELECT name FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.status = acct.status
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.type = dept.type
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM staff AS acct
    WHERE acct.level = rgn.level
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS tsk
    WHERE tsk.level = schd.level
);


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

SELECT value FROM transactions AS txn
WHERE amount > (
    SELECT COUNT(value) FROM departments AS ord
    WHERE ord.id = txn.id
);


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

SELECT code FROM orders AS ord
WHERE level IN (
    SELECT level FROM customers AS acct
    WHERE acct.code = ord.code
);


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

SELECT amount FROM requests AS ordr
WHERE value > (
    SELECT MIN(value) FROM orders AS lne
    WHERE lne.id = ordr.id
);


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

SELECT id FROM employees AS emp
WHERE code IN (
    SELECT code FROM requests AS schd
    WHERE schd.level = emp.level
);


Prompt:
Schema:
  departments (alias: dept)(id, level, name, status)
  transactions(code, id, amount, date)
Task: Find id from departments where value exceeds the count of amount from transactions for the same id.
SQL:

SELECT id FROM departments AS dept
WHERE value > (
    SELECT COUNT(amount) FROM transactions AS prj
    WHERE prj.id = dept.id
);


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

SELECT name FROM employees AS emp
WHERE type IN (
    SELECT type FROM branches AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT id FROM shipments AS shp
WHERE status IN (
    SELECT status FROM managers AS dept
    WHERE dept.status = shp.status
);


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

SELECT amount FROM projects AS prj
WHERE salary > (
    SELECT COUNT(value) FROM managers AS sale
    WHERE sale.code = prj.code
);


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

SELECT name FROM requests AS ordr
WHERE amount > (
    SELECT MAX(value) FROM schedules AS shp
    WHERE shp.status = ordr.status
);


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

SELECT salary FROM branches AS brc
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS prj
    WHERE prj.code = brc.code
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.code = schd.code
);


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

SELECT name FROM regions AS rgn
WHERE value > (
    SELECT AVG(value) FROM staff AS cust
    WHERE cust.code = rgn.code
);


Prompt:
Schema:
  items (alias: lne)(code, level, type, status)
  projects(name, status, type, id)
Task: Find code from items where salary exceeds the total salary from projects for the same code.
SQL:

SELECT code FROM items AS lne
WHERE salary > (
    SELECT SUM(salary) FROM projects AS shp
    WHERE shp.code = lne.code
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.level = shp.level
);


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

SELECT amount FROM requests AS ordr
WHERE level IN (
    SELECT level FROM transactions AS cust
    WHERE cust.level = ordr.level
);


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

SELECT amount FROM invoices AS inv
WHERE value > (
    SELECT MAX(amount) FROM requests AS emp
    WHERE emp.id = inv.id
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.code = catg.code
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.type = ord.type
);


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

SELECT code FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM branches AS tsk
    WHERE tsk.type = prj.type
);


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

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


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

SELECT code FROM items AS lne
WHERE id IN (
    SELECT id FROM departments AS ordr
    WHERE ordr.id = lne.id
);


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

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


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

SELECT salary FROM departments AS dept
WHERE level IN (
    SELECT level FROM transactions AS inv
    WHERE inv.status = dept.status
);


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

SELECT code FROM categories AS catg
WHERE type IN (
    SELECT type FROM customers AS prod
    WHERE prod.level = catg.level
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM orders AS prj
    WHERE prj.code = tsk.code
);


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

SELECT name FROM managers AS mgr
WHERE type IN (
    SELECT type FROM tasks AS lne
    WHERE lne.code = mgr.code
);


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

SELECT value FROM requests AS ordr
WHERE amount > (
    SELECT MIN(value) FROM schedules AS dept
    WHERE dept.level = ordr.level
);


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

SELECT id FROM orders AS ord
WHERE id IN (
    SELECT id FROM transactions AS dept
    WHERE dept.status = ord.status
);


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

SELECT value FROM categories AS catg
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT salary FROM accounts AS acct
WHERE amount > (
    SELECT SUM(amount) FROM schedules AS brc
    WHERE brc.type = acct.type
);


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

SELECT value FROM sales AS sale
WHERE code IN (
    SELECT code FROM regions AS brc
    WHERE brc.code = sale.code
);


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

SELECT id FROM requests AS ordr
WHERE salary > (
    SELECT MAX(amount) FROM items AS schd
    WHERE schd.id = ordr.id
);


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM items AS dept
    WHERE dept.status = sale.status
);


Prompt:
Schema:
  orders (alias: ord)(code, amount, name, id)
  schedules(amount, status, value, id)
Task: Find id from orders where code appears in schedules entries with matching id.
SQL:

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


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

SELECT salary FROM transactions AS txn
WHERE type IN (
    SELECT type FROM staff AS txn
    WHERE txn.code = txn.code
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.type = dept.type
);


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

SELECT salary FROM sales AS sale
WHERE status IN (
    SELECT status FROM schedules AS prj
    WHERE prj.code = sale.code
);


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

SELECT salary FROM categories AS catg
WHERE value > (
    SELECT MAX(value) FROM projects AS prod
    WHERE prod.status = catg.status
);


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

SELECT value FROM orders AS ord
WHERE id IN (
    SELECT id FROM items AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT name FROM tasks AS tsk
WHERE amount > (
    SELECT MAX(salary) FROM accounts AS prj
    WHERE prj.code = tsk.code
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM items AS acct
    WHERE acct.id = brc.id
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM sales AS mgr
    WHERE mgr.id = txn.id
);


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

SELECT salary FROM categories AS catg
WHERE id IN (
    SELECT id FROM tasks AS mgr
    WHERE mgr.level = catg.level
);


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM invoices AS prj
    WHERE prj.type = ord.type
);


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

SELECT amount FROM invoices AS inv
WHERE amount > (
    SELECT MAX(amount) FROM shipments AS prj
    WHERE prj.id = inv.id
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.status = ordr.status
);


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

SELECT name FROM products AS prod
WHERE status IN (
    SELECT status FROM staff AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM staff AS prj
    WHERE prj.id = lne.id
);


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

SELECT value FROM transactions AS txn
WHERE type IN (
    SELECT type FROM categories AS mgr
    WHERE mgr.level = txn.level
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE amount > (
    SELECT COUNT(value) FROM transactions AS prj
    WHERE prj.level = tsk.level
);


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

SELECT amount FROM invoices AS inv
WHERE code IN (
    SELECT code FROM schedules AS emp
    WHERE emp.status = inv.status
);


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

SELECT salary FROM requests AS ordr
WHERE type IN (
    SELECT type FROM regions AS ordr
    WHERE ordr.code = ordr.code
);


Prompt:
Schema:
  branches (alias: brc)(amount, level, date, status)
  items(value, name, status, type)
Task: Find id from branches where value exceeds the minimum value from items for the same id.
SQL:

SELECT id FROM branches AS brc
WHERE value > (
    SELECT MIN(value) FROM items AS inv
    WHERE inv.id = brc.id
);


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

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


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

SELECT id FROM branches AS brc
WHERE level IN (
    SELECT level FROM regions AS schd
    WHERE schd.level = brc.level
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.type = rgn.type
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.type = prod.type
);


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

SELECT salary FROM employees AS emp
WHERE status IN (
    SELECT status FROM products AS inv
    WHERE inv.id = emp.id
);


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

SELECT salary FROM projects AS prj
WHERE salary > (
    SELECT COUNT(value) FROM shipments AS prj
    WHERE prj.type = prj.type
);


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

SELECT code FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM sales AS txn
    WHERE txn.status = prj.status
);


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

SELECT name FROM shipments AS shp
WHERE status IN (
    SELECT status FROM invoices AS cust
    WHERE cust.status = shp.status
);


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

SELECT value FROM requests AS ordr
WHERE value > (
    SELECT SUM(amount) FROM staff AS mgr
    WHERE mgr.status = ordr.status
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.type = txn.type
);


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

SELECT amount FROM projects AS prj
WHERE status IN (
    SELECT status FROM products AS prj
    WHERE prj.status = prj.status
);


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

SELECT amount FROM schedules AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM categories AS ord
    WHERE ord.type = schd.type
);


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

SELECT salary FROM employees AS emp
WHERE value > (
    SELECT MIN(value) FROM products AS sale
    WHERE sale.type = emp.type
);


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

SELECT id FROM projects AS prj
WHERE amount > (
    SELECT COUNT(value) FROM regions AS schd
    WHERE schd.code = prj.code
);


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

SELECT name FROM sales AS sale
WHERE amount > (
    SELECT AVG(salary) FROM tasks AS dept
    WHERE dept.type = sale.type
);


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

SELECT code FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM managers AS ordr
    WHERE ordr.level = ordr.level
);


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

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


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

SELECT id FROM invoices AS inv
WHERE value > (
    SELECT MIN(amount) FROM sales AS empl
    WHERE empl.level = inv.level
);


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

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


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

SELECT code FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.id = ordr.id
);


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

SELECT code FROM schedules AS schd
WHERE salary > (
    SELECT MIN(value) FROM categories AS rgn
    WHERE rgn.type = schd.type
);


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

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


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

SELECT name FROM branches AS brc
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS prj
    WHERE prj.level = brc.level
);


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

SELECT id FROM transactions AS txn
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.code = txn.code
);


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

SELECT amount FROM items AS lne
WHERE id IN (
    SELECT id FROM employees AS prj
    WHERE prj.type = lne.type
);


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

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


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM items AS cust
    WHERE cust.level = dept.level
);


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

SELECT value FROM schedules AS schd
WHERE salary > (
    SELECT SUM(value) FROM departments AS ord
    WHERE ord.status = schd.status
);


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

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


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

SELECT value FROM staff AS empl
WHERE salary > (
    SELECT COUNT(value) FROM orders AS schd
    WHERE schd.type = empl.type
);


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

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


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

SELECT amount FROM invoices AS inv
WHERE level IN (
    SELECT level FROM projects AS acct
    WHERE acct.type = inv.type
);


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

SELECT value FROM managers AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS dept
    WHERE dept.id = mgr.id
);


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

SELECT id FROM customers AS cust
WHERE level IN (
    SELECT level FROM projects AS brc
    WHERE brc.id = cust.id
);


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

SELECT id FROM transactions AS txn
WHERE amount > (
    SELECT SUM(value) FROM schedules AS prj
    WHERE prj.type = txn.type
);


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

SELECT amount FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.level = mgr.level
);


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

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


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

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


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

SELECT id FROM accounts AS acct
WHERE level IN (
    SELECT level FROM shipments AS schd
    WHERE schd.level = acct.level
);


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

SELECT name FROM orders AS ord
WHERE type IN (
    SELECT type FROM customers AS txn
    WHERE txn.code = ord.code
);


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

SELECT value FROM employees AS emp
WHERE status IN (
    SELECT status FROM departments AS empl
    WHERE empl.code = emp.code
);


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

SELECT name FROM orders AS ord
WHERE amount > (
    SELECT MAX(amount) FROM employees AS catg
    WHERE catg.status = ord.status
);


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

SELECT id FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS prod
    WHERE prod.status = lne.status
);


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

SELECT salary FROM invoices AS inv
WHERE code IN (
    SELECT code FROM managers AS acct
    WHERE acct.status = inv.status
);


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

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


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

SELECT code FROM invoices AS inv
WHERE status IN (
    SELECT status FROM schedules AS empl
    WHERE empl.type = inv.type
);


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

SELECT name FROM employees AS emp
WHERE level IN (
    SELECT level FROM schedules AS prod
    WHERE prod.status = emp.status
);


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

SELECT id FROM managers AS mgr
WHERE level IN (
    SELECT level FROM invoices AS ord
    WHERE ord.type = mgr.type
);


Prompt:
Schema:
  branches (alias: brc)(value, level, status, name)
  categories(status, amount, date, type)
Task: Retrieve name from branches with amount above the MAX(value) of categories rows sharing the same status.
SQL:

SELECT name FROM branches AS brc
WHERE amount > (
    SELECT MAX(value) FROM categories AS sale
    WHERE sale.status = brc.status
);


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

SELECT amount FROM sales AS sale
WHERE salary > (
    SELECT MAX(amount) FROM orders AS acct
    WHERE acct.status = sale.status
);


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

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


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

SELECT name FROM shipments AS shp
WHERE id IN (
    SELECT id FROM invoices AS catg
    WHERE catg.level = shp.level
);


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

SELECT code FROM requests AS ordr
WHERE status IN (
    SELECT status FROM staff AS empl
    WHERE empl.id = ordr.id
);


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

SELECT salary FROM managers AS mgr
WHERE salary > (
    SELECT SUM(salary) FROM employees AS prod
    WHERE prod.code = mgr.code
);


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

SELECT id FROM products AS prod
WHERE code IN (
    SELECT code FROM shipments AS catg
    WHERE catg.id = prod.id
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS emp
    WHERE emp.type = dept.type
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.level = lne.level
);


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

SELECT amount FROM projects AS prj
WHERE type IN (
    SELECT type FROM sales AS rgn
    WHERE rgn.status = prj.status
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.status = txn.status
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM schedules AS txn
    WHERE txn.id = rgn.id
);


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

SELECT name FROM staff AS empl
WHERE level IN (
    SELECT level FROM schedules AS cust
    WHERE cust.type = empl.type
);


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM staff AS rgn
    WHERE rgn.level = rgn.level
);


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

SELECT salary FROM schedules AS schd
WHERE code IN (
    SELECT code FROM transactions AS prod
    WHERE prod.level = schd.level
);


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

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


Prompt:
Schema:
  tasks (alias: tsk)(amount, date, name, type)
  accounts(type, date, level, status)
Task: Find id from tasks where salary exceeds the count of salary from accounts for the same id.
SQL:

SELECT id FROM tasks AS tsk
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS rgn
    WHERE rgn.id = tsk.id
);


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

SELECT salary FROM regions AS rgn
WHERE type IN (
    SELECT type FROM orders AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM staff AS catg
    WHERE catg.code = txn.code
);


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

SELECT id FROM accounts AS acct
WHERE status IN (
    SELECT status FROM branches AS txn
    WHERE txn.id = acct.id
);


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

SELECT salary FROM tasks AS tsk
WHERE value > (
    SELECT COUNT(value) FROM orders AS prj
    WHERE prj.status = tsk.status
);


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

SELECT value FROM managers AS mgr
WHERE status IN (
    SELECT status FROM employees AS cust
    WHERE cust.id = mgr.id
);


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

SELECT value FROM managers AS mgr
WHERE value > (
    SELECT AVG(value) FROM tasks AS inv
    WHERE inv.status = mgr.status
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.id = txn.id
);


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

SELECT code FROM products AS prod
WHERE level IN (
    SELECT level FROM projects AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT code FROM sales AS sale
WHERE code IN (
    SELECT code FROM customers AS ordr
    WHERE ordr.type = sale.type
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT code FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM shipments AS tsk
    WHERE tsk.id = tsk.id
);


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM staff AS brc
    WHERE brc.code = ordr.code
);


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

SELECT name FROM transactions AS txn
WHERE value > (
    SELECT AVG(value) FROM items AS catg
    WHERE catg.level = txn.level
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.id = txn.id
);


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

SELECT amount FROM tasks AS tsk
WHERE value > (
    SELECT MAX(amount) FROM employees AS cust
    WHERE cust.type = tsk.type
);


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

SELECT id FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.code = lne.code
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS inv
    WHERE inv.status = lne.status
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.code = rgn.code
);


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

SELECT code FROM shipments AS shp
WHERE amount > (
    SELECT MAX(value) FROM regions AS schd
    WHERE schd.type = shp.type
);


Prompt:
Schema:
  managers (alias: mgr)(amount, status, type, salary)
  regions(status, code, salary, name)
Task: Retrieve id from managers with salary above the AVG(amount) of regions rows sharing the same code.
SQL:

SELECT id FROM managers AS mgr
WHERE salary > (
    SELECT AVG(amount) FROM regions AS dept
    WHERE dept.code = mgr.code
);


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

SELECT amount FROM products AS prod
WHERE salary > (
    SELECT SUM(amount) FROM managers AS acct
    WHERE acct.type = prod.type
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM sales AS txn
    WHERE txn.code = rgn.code
);


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

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


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.level = ord.level
);


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.type = emp.type
);


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

SELECT name FROM branches AS brc
WHERE value > (
    SELECT SUM(amount) FROM staff AS lne
    WHERE lne.level = brc.level
);


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

SELECT id FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM staff AS brc
    WHERE brc.level = brc.level
);


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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM staff AS brc
    WHERE brc.code = rgn.code
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.status = dept.status
);