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

SELECT code FROM orders AS ord
WHERE amount > (
    SELECT AVG(amount) FROM invoices AS inv
    WHERE inv.id = ord.id
);


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

SELECT name FROM schedules AS schd
WHERE value > (
    SELECT COUNT(value) FROM staff AS empl
    WHERE empl.status = schd.status
);


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

SELECT name FROM staff AS empl
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS acct
    WHERE acct.code = empl.code
);


Prompt:
Schema:
  transactions (alias: txn)(type, status, salary, code)
  schedules(code, id, type, value)
Task: Find id from transactions where amount exceeds the maximum salary from schedules for the same status.
SQL:

SELECT id FROM transactions AS txn
WHERE amount > (
    SELECT MAX(salary) FROM schedules AS schd
    WHERE schd.status = txn.status
);


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.status = mgr.status
);


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

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


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.level = prod.level
);


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

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


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

SELECT name FROM tasks AS tsk
WHERE amount > (
    SELECT SUM(amount) FROM categories AS catg
    WHERE catg.type = tsk.type
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.type = schd.type
);


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

SELECT value FROM employees AS emp
WHERE salary > (
    SELECT SUM(salary) FROM invoices AS inv
    WHERE inv.id = emp.id
);


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

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


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

SELECT value FROM schedules AS schd
WHERE salary > (
    SELECT SUM(amount) FROM employees AS emp
    WHERE emp.id = schd.id
);


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

SELECT id FROM managers AS mgr
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.status = mgr.status
);


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

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


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

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


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

SELECT name FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM branches AS brc
    WHERE brc.id = tsk.id
);


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

SELECT id FROM shipments AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM invoices AS inv
    WHERE inv.status = shp.status
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.code = schd.code
);


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

SELECT amount FROM tasks AS tsk
WHERE salary > (
    SELECT MIN(salary) FROM sales AS sale
    WHERE sale.id = tsk.id
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.level = catg.level
);


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

SELECT code FROM branches AS brc
WHERE value > (
    SELECT SUM(amount) FROM schedules AS schd
    WHERE schd.status = brc.status
);


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

SELECT value FROM products AS prod
WHERE salary > (
    SELECT AVG(salary) FROM items AS lne
    WHERE lne.level = prod.level
);


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS emp
    WHERE emp.code = prj.code
);


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

SELECT id FROM categories AS catg
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.status = catg.status
);


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

SELECT id FROM customers AS cust
WHERE level IN (
    SELECT level FROM categories AS catg
    WHERE catg.status = cust.status
);


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

SELECT salary FROM products AS prod
WHERE amount > (
    SELECT AVG(value) FROM orders AS ord
    WHERE ord.code = prod.code
);


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

SELECT code FROM staff AS empl
WHERE salary > (
    SELECT MIN(salary) FROM branches AS brc
    WHERE brc.code = empl.code
);


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

SELECT salary FROM tasks AS tsk
WHERE amount > (
    SELECT AVG(value) FROM employees AS emp
    WHERE emp.status = tsk.status
);


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

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


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = lne.code
);


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

SELECT name FROM orders AS ord
WHERE salary > (
    SELECT SUM(salary) FROM staff AS empl
    WHERE empl.code = ord.code
);


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT MAX(salary) FROM sales AS sale
    WHERE sale.id = rgn.id
);


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.level = schd.level
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.code = rgn.code
);


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

SELECT code FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.status = tsk.status
);


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

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


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

SELECT code FROM accounts AS acct
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.level = acct.level
);


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

SELECT name FROM accounts AS acct
WHERE salary > (
    SELECT MAX(salary) FROM schedules AS schd
    WHERE schd.status = acct.status
);


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

SELECT name FROM projects AS prj
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.type = prj.type
);


Prompt:
Schema:
  orders (alias: ord)(name, amount, code, salary)
  managers(level, amount, code, id)
Task: Find code from orders where amount exceeds the minimum amount from managers for the same status.
SQL:

SELECT code FROM orders AS ord
WHERE amount > (
    SELECT MIN(amount) FROM managers AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT salary FROM tasks AS tsk
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.id = tsk.id
);


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.code = ordr.code
);


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

SELECT name FROM branches AS brc
WHERE salary > (
    SELECT SUM(value) FROM invoices AS inv
    WHERE inv.type = brc.type
);


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

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


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

SELECT name FROM managers AS mgr
WHERE amount > (
    SELECT MAX(amount) FROM employees AS emp
    WHERE emp.level = mgr.level
);


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

SELECT amount FROM branches AS brc
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.code = brc.code
);


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

SELECT code FROM orders AS ord
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS cust
    WHERE cust.level = ord.level
);


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

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


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

SELECT salary FROM customers AS cust
WHERE id IN (
    SELECT id FROM regions AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = acct.level
);


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

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


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

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


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

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


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

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


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

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


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

SELECT salary FROM shipments AS shp
WHERE value > (
    SELECT SUM(value) FROM customers AS cust
    WHERE cust.status = shp.status
);


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

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


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT AVG(salary) FROM categories AS catg
    WHERE catg.level = prj.level
);


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

SELECT id FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.id = txn.id
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.level = tsk.level
);


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

SELECT code FROM managers AS mgr
WHERE level IN (
    SELECT level FROM staff AS empl
    WHERE empl.type = mgr.type
);


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

SELECT amount FROM employees AS emp
WHERE code IN (
    SELECT code FROM accounts AS acct
    WHERE acct.code = emp.code
);


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

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


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

SELECT name FROM regions AS rgn
WHERE type IN (
    SELECT type FROM sales AS sale
    WHERE sale.status = rgn.status
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.type = tsk.type
);


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

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.status = mgr.status
);


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

SELECT amount FROM sales AS sale
WHERE salary > (
    SELECT MIN(salary) FROM categories AS catg
    WHERE catg.id = sale.id
);


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

SELECT amount FROM regions AS rgn
WHERE amount > (
    SELECT SUM(salary) FROM invoices AS inv
    WHERE inv.status = rgn.status
);


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

SELECT salary FROM orders AS ord
WHERE amount > (
    SELECT MIN(salary) FROM projects AS prj
    WHERE prj.code = ord.code
);


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

SELECT code FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.code = ordr.code
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.type = txn.type
);


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

SELECT salary FROM employees AS emp
WHERE id IN (
    SELECT id FROM sales AS sale
    WHERE sale.level = emp.level
);


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

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


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

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


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.code = mgr.code
);


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

SELECT salary FROM departments AS dept
WHERE status IN (
    SELECT status FROM tasks AS tsk
    WHERE tsk.type = dept.type
);


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

SELECT amount FROM branches AS brc
WHERE type IN (
    SELECT type FROM projects AS prj
    WHERE prj.status = brc.status
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT salary FROM staff AS empl
WHERE salary > (
    SELECT AVG(salary) FROM requests AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.status = schd.status
);


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

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


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

SELECT amount FROM employees AS emp
WHERE value > (
    SELECT AVG(amount) FROM managers AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.status = emp.status
);


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = prj.code
);


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

SELECT id FROM branches AS brc
WHERE salary > (
    SELECT MIN(salary) FROM tasks AS tsk
    WHERE tsk.code = brc.code
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.status = rgn.status
);


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

SELECT code FROM branches AS brc
WHERE amount > (
    SELECT AVG(amount) FROM employees AS emp
    WHERE emp.code = brc.code
);


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

SELECT id FROM staff AS empl
WHERE id IN (
    SELECT id FROM items AS lne
    WHERE lne.type = empl.type
);


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

SELECT code FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = empl.type
);


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

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


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

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


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

SELECT name FROM categories AS catg
WHERE amount > (
    SELECT AVG(value) FROM schedules AS schd
    WHERE schd.type = catg.type
);


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

SELECT name FROM customers AS cust
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS inv
    WHERE inv.code = cust.code
);


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

SELECT code FROM products AS prod
WHERE salary > (
    SELECT MIN(value) FROM managers AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT value FROM projects AS prj
WHERE code IN (
    SELECT code FROM customers AS cust
    WHERE cust.type = prj.type
);


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

SELECT id FROM products AS prod
WHERE amount > (
    SELECT MIN(amount) FROM schedules AS schd
    WHERE schd.level = prod.level
);


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

SELECT value FROM branches AS brc
WHERE value > (
    SELECT MAX(amount) FROM shipments AS shp
    WHERE shp.id = brc.id
);


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

SELECT code FROM products AS prod
WHERE value > (
    SELECT MIN(salary) FROM branches AS brc
    WHERE brc.type = prod.type
);


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

SELECT name FROM branches AS brc
WHERE salary > (
    SELECT SUM(value) FROM managers AS mgr
    WHERE mgr.status = brc.status
);


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

SELECT code FROM managers AS mgr
WHERE id IN (
    SELECT id FROM departments AS dept
    WHERE dept.type = mgr.type
);


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

SELECT name FROM managers AS mgr
WHERE value > (
    SELECT AVG(salary) FROM sales AS sale
    WHERE sale.code = mgr.code
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = lne.status
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = emp.id
);


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

SELECT id FROM categories AS catg
WHERE amount > (
    SELECT MAX(amount) FROM staff AS empl
    WHERE empl.level = catg.level
);


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.id = mgr.id
);


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

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


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

SELECT id FROM accounts AS acct
WHERE value > (
    SELECT SUM(amount) FROM staff AS empl
    WHERE empl.level = acct.level
);


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

SELECT value FROM products AS prod
WHERE status IN (
    SELECT status FROM managers AS mgr
    WHERE mgr.type = prod.type
);


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

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


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.code = sale.code
);


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

SELECT value FROM departments AS dept
WHERE status IN (
    SELECT status FROM branches AS brc
    WHERE brc.code = dept.code
);


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

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


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.code = txn.code
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.type = emp.type
);


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

SELECT amount FROM customers AS cust
WHERE salary > (
    SELECT MIN(amount) FROM orders AS ord
    WHERE ord.status = cust.status
);


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

SELECT code FROM departments AS dept
WHERE amount > (
    SELECT COUNT(value) FROM staff AS empl
    WHERE empl.id = dept.id
);


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

SELECT name FROM accounts AS acct
WHERE amount > (
    SELECT COUNT(value) FROM categories AS catg
    WHERE catg.level = acct.level
);


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

SELECT id FROM shipments AS shp
WHERE salary > (
    SELECT COUNT(value) FROM products AS prod
    WHERE prod.code = shp.code
);


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

SELECT name FROM invoices AS inv
WHERE value > (
    SELECT SUM(amount) FROM schedules AS schd
    WHERE schd.type = inv.type
);


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

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


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.id = txn.id
);


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

SELECT name FROM schedules AS schd
WHERE amount > (
    SELECT MIN(amount) FROM items AS lne
    WHERE lne.code = schd.code
);


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

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


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

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


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

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


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

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


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

SELECT code FROM managers AS mgr
WHERE value > (
    SELECT MIN(salary) FROM orders AS ord
    WHERE ord.status = mgr.status
);


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

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


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

SELECT salary FROM branches AS brc
WHERE type IN (
    SELECT type FROM staff AS empl
    WHERE empl.level = brc.level
);


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

SELECT name FROM employees AS emp
WHERE level IN (
    SELECT level FROM staff AS empl
    WHERE empl.code = emp.code
);


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

SELECT name FROM projects AS prj
WHERE value > (
    SELECT MIN(salary) FROM products AS prod
    WHERE prod.status = prj.status
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = lne.id
);


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

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


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

SELECT value FROM projects AS prj
WHERE amount > (
    SELECT MIN(salary) FROM sales AS sale
    WHERE sale.level = prj.level
);


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

SELECT salary FROM products AS prod
WHERE id IN (
    SELECT id FROM staff AS empl
    WHERE empl.level = prod.level
);


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

SELECT salary FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM projects AS prj
    WHERE prj.level = tsk.level
);


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

SELECT amount FROM invoices AS inv
WHERE amount > (
    SELECT MAX(amount) FROM items AS lne
    WHERE lne.id = inv.id
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.id = prod.id
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.level = sale.level
);


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

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


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

SELECT code FROM tasks AS tsk
WHERE value > (
    SELECT AVG(value) FROM projects AS prj
    WHERE prj.status = tsk.status
);


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

SELECT value FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM branches AS brc
    WHERE brc.level = tsk.level
);


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

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


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

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


Prompt:
Schema:
  requests (alias: ordr)(amount, name, salary, status)
  customers(date, status, id, amount)
Task: Find name from requests where salary exceeds the count of amount from customers for the same id.
SQL:

SELECT name FROM requests AS ordr
WHERE salary > (
    SELECT COUNT(amount) FROM customers AS cust
    WHERE cust.id = ordr.id
);


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

SELECT code FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.type = acct.type
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = empl.type
);


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

SELECT name FROM branches AS brc
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.status = brc.status
);


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

SELECT id FROM schedules AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM projects AS prj
    WHERE prj.level = schd.level
);


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

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


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

SELECT code FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.status = rgn.status
);


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

SELECT value FROM sales AS sale
WHERE amount > (
    SELECT SUM(value) FROM invoices AS inv
    WHERE inv.type = sale.type
);


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

SELECT id FROM managers AS mgr
WHERE code IN (
    SELECT code FROM requests AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.type = lne.type
);


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

SELECT name FROM departments AS dept
WHERE value > (
    SELECT AVG(value) FROM orders AS ord
    WHERE ord.status = dept.status
);


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

SELECT name FROM employees AS emp
WHERE status IN (
    SELECT status FROM branches AS brc
    WHERE brc.type = emp.type
);


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

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


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

SELECT salary FROM orders AS ord
WHERE id IN (
    SELECT id FROM items AS lne
    WHERE lne.type = ord.type
);


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

SELECT amount FROM managers AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM products AS prod
    WHERE prod.level = mgr.level
);


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

SELECT name FROM shipments AS shp
WHERE salary > (
    SELECT AVG(value) FROM managers AS mgr
    WHERE mgr.code = shp.code
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.code = inv.code
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.status = schd.status
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE amount > (
    SELECT AVG(value) FROM branches AS brc
    WHERE brc.level = mgr.level
);


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

SELECT salary FROM departments AS dept
WHERE code IN (
    SELECT code FROM projects AS prj
    WHERE prj.code = dept.code
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.level = prod.level
);


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

SELECT salary FROM regions AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM employees AS emp
    WHERE emp.id = rgn.id
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.status = prod.status
);


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.status = tsk.status
);


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

SELECT salary FROM shipments AS shp
WHERE amount > (
    SELECT SUM(salary) FROM schedules AS schd
    WHERE schd.level = shp.level
);


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

SELECT amount FROM shipments AS shp
WHERE code IN (
    SELECT code FROM items AS lne
    WHERE lne.level = shp.level
);


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

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


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = acct.status
);


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

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


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

SELECT value FROM departments AS dept
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.code = emp.code
);


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

SELECT value FROM regions AS rgn
WHERE type IN (
    SELECT type FROM schedules AS schd
    WHERE schd.id = rgn.id
);


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

SELECT amount FROM managers AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM orders AS ord
    WHERE ord.status = mgr.status
);


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

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


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

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


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

SELECT amount FROM departments AS dept
WHERE code IN (
    SELECT code FROM branches AS brc
    WHERE brc.type = dept.type
);


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

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


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.status = shp.status
);


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

SELECT value FROM branches AS brc
WHERE status IN (
    SELECT status FROM orders AS ord
    WHERE ord.level = brc.level
);


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

SELECT code FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = mgr.id
);


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

SELECT name FROM sales AS sale
WHERE type IN (
    SELECT type FROM accounts AS acct
    WHERE acct.level = sale.level
);


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

SELECT code FROM branches AS brc
WHERE salary > (
    SELECT SUM(amount) FROM managers AS mgr
    WHERE mgr.type = brc.type
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = txn.status
);


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

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


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

SELECT amount FROM projects AS prj
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.id = prj.id
);


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

SELECT salary FROM invoices AS inv
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.status = inv.status
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = emp.status
);


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

SELECT code FROM managers AS mgr
WHERE amount > (
    SELECT AVG(salary) FROM requests AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT id FROM staff AS empl
WHERE type IN (
    SELECT type FROM tasks AS tsk
    WHERE tsk.type = empl.type
);


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.status = sale.status
);


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

SELECT id FROM branches AS brc
WHERE value > (
    SELECT COUNT(value) FROM staff AS empl
    WHERE empl.id = brc.id
);


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

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


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

SELECT value FROM departments AS dept
WHERE type IN (
    SELECT type FROM tasks AS tsk
    WHERE tsk.id = dept.id
);


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.status = sale.status
);


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

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


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

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


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

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


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

SELECT id FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.level = inv.level
);


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

SELECT value FROM shipments AS shp
WHERE value > (
    SELECT MAX(value) FROM orders AS ord
    WHERE ord.level = shp.level
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.code = lne.code
);


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

SELECT code FROM products AS prod
WHERE level IN (
    SELECT level FROM tasks AS tsk
    WHERE tsk.type = prod.type
);


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

SELECT value FROM schedules AS schd
WHERE code IN (
    SELECT code FROM projects AS prj
    WHERE prj.level = schd.level
);


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

SELECT id FROM items AS lne
WHERE salary > (
    SELECT MIN(value) FROM regions AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT salary FROM employees AS emp
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.id = emp.id
);


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

SELECT amount FROM customers AS cust
WHERE value > (
    SELECT MIN(salary) FROM transactions AS txn
    WHERE txn.type = cust.type
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.type = prod.type
);


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

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


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

SELECT amount FROM staff AS empl
WHERE status IN (
    SELECT status FROM orders AS ord
    WHERE ord.type = empl.type
);


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

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


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

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


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.id = ordr.id
);


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

SELECT salary FROM projects AS prj
WHERE code IN (
    SELECT code FROM schedules AS schd
    WHERE schd.level = prj.level
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.type = acct.type
);


Prompt:
Schema:
  items (alias: lne)(status, salary, level, value)
  requests(salary, value, id, name)
Task: Find id from items where salary exceeds the count of value from requests for the same status.
SQL:

SELECT id FROM items AS lne
WHERE salary > (
    SELECT COUNT(value) FROM requests AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT salary FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.type = prj.type
);


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

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


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = cust.id
);


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

SELECT name FROM transactions AS txn
WHERE type IN (
    SELECT type FROM managers AS mgr
    WHERE mgr.id = txn.id
);


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

SELECT id FROM managers AS mgr
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.level = mgr.level
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = txn.id
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS tsk
    WHERE tsk.status = cust.status
);


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

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


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

SELECT amount FROM shipments AS shp
WHERE type IN (
    SELECT type FROM transactions AS txn
    WHERE txn.code = shp.code
);


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

SELECT value FROM items AS lne
WHERE type IN (
    SELECT type FROM requests AS ordr
    WHERE ordr.type = lne.type
);


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

SELECT code FROM orders AS ord
WHERE salary > (
    SELECT MIN(amount) FROM accounts AS acct
    WHERE acct.type = ord.type
);


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

SELECT id FROM shipments AS shp
WHERE level IN (
    SELECT level FROM tasks AS tsk
    WHERE tsk.type = shp.type
);


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

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


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

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


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

SELECT code FROM requests AS ordr
WHERE salary > (
    SELECT MIN(value) FROM accounts AS acct
    WHERE acct.id = ordr.id
);


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

SELECT salary FROM requests AS ordr
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.id = ordr.id
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.status = ord.status
);


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

SELECT value FROM employees AS emp
WHERE type IN (
    SELECT type FROM products AS prod
    WHERE prod.id = emp.id
);


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

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


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.id = acct.id
);


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

SELECT value FROM employees AS emp
WHERE type IN (
    SELECT type FROM schedules AS schd
    WHERE schd.id = emp.id
);


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

SELECT value FROM orders AS ord
WHERE amount > (
    SELECT SUM(value) FROM employees AS emp
    WHERE emp.type = ord.type
);


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

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


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

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


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

SELECT name FROM managers AS mgr
WHERE salary > (
    SELECT MIN(salary) FROM employees AS emp
    WHERE emp.type = mgr.type
);


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

SELECT amount FROM invoices AS inv
WHERE type IN (
    SELECT type FROM requests AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT amount FROM orders AS ord
WHERE type IN (
    SELECT type FROM items AS lne
    WHERE lne.id = ord.id
);


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

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


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.id = catg.id
);


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

SELECT name FROM invoices AS inv
WHERE amount > (
    SELECT SUM(salary) FROM items AS lne
    WHERE lne.code = inv.code
);


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS prj
    WHERE prj.code = emp.code
);


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

SELECT amount FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = dept.status
);


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

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


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

SELECT salary FROM departments AS dept
WHERE type IN (
    SELECT type FROM tasks AS tsk
    WHERE tsk.status = dept.status
);


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

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


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

SELECT code FROM tasks AS tsk
WHERE value > (
    SELECT AVG(salary) FROM invoices AS inv
    WHERE inv.type = tsk.type
);


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

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


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

SELECT value FROM projects AS prj
WHERE amount > (
    SELECT MAX(amount) FROM schedules AS schd
    WHERE schd.level = prj.level
);


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

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


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

SELECT code FROM schedules AS schd
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.id = schd.id
);


Prompt:
Schema:
  accounts (alias: acct)(value, salary, id, status)
  sales(value, name, status, type)
Task: Find value from accounts where value exceeds the minimum salary from sales for the same status.
SQL:

SELECT value FROM accounts AS acct
WHERE value > (
    SELECT MIN(salary) FROM sales AS sale
    WHERE sale.status = acct.status
);


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

SELECT amount FROM staff AS empl
WHERE amount > (
    SELECT MAX(value) FROM products AS prod
    WHERE prod.code = empl.code
);


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

SELECT salary FROM products AS prod
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.type = prod.type
);


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

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


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

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


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

SELECT code FROM staff AS empl
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS brc
    WHERE brc.code = empl.code
);


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

SELECT code FROM regions AS rgn
WHERE salary > (
    SELECT COUNT(value) FROM departments AS dept
    WHERE dept.status = rgn.status
);


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

SELECT salary FROM requests AS ordr
WHERE type IN (
    SELECT type FROM items AS lne
    WHERE lne.type = ordr.type
);


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.id = schd.id
);


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.type = ord.type
);


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

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


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

SELECT value FROM schedules AS schd
WHERE amount > (
    SELECT AVG(value) FROM branches AS brc
    WHERE brc.level = schd.level
);


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

SELECT id FROM shipments AS shp
WHERE value > (
    SELECT SUM(amount) FROM invoices AS inv
    WHERE inv.type = shp.type
);


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

SELECT code FROM customers AS cust
WHERE amount > (
    SELECT SUM(amount) FROM items AS lne
    WHERE lne.code = cust.code
);


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

SELECT value FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM regions AS rgn
    WHERE rgn.type = tsk.type
);


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

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


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

SELECT code FROM managers AS mgr
WHERE status IN (
    SELECT status FROM staff AS empl
    WHERE empl.level = mgr.level
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.type = tsk.type
);


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

SELECT amount FROM branches AS brc
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS txn
    WHERE txn.status = brc.status
);


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

SELECT id FROM managers AS mgr
WHERE id IN (
    SELECT id FROM customers AS cust
    WHERE cust.level = mgr.level
);


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

SELECT code FROM schedules AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS shp
    WHERE shp.status = schd.status
);


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

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


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.status = cust.status
);


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

SELECT value FROM orders AS ord
WHERE value > (
    SELECT SUM(salary) FROM transactions AS txn
    WHERE txn.status = ord.status
);


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

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


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

SELECT amount FROM departments AS dept
WHERE code IN (
    SELECT code FROM projects AS prj
    WHERE prj.code = dept.code
);


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

SELECT amount FROM customers AS cust
WHERE status IN (
    SELECT status FROM requests AS ordr
    WHERE ordr.status = cust.status
);


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

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


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

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


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.type = mgr.type
);


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

SELECT name FROM staff AS empl
WHERE type IN (
    SELECT type FROM shipments AS shp
    WHERE shp.id = empl.id
);


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

SELECT code FROM accounts AS acct
WHERE salary > (
    SELECT MIN(salary) FROM shipments AS shp
    WHERE shp.id = acct.id
);


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

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


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

SELECT salary FROM requests AS ordr
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.level = ordr.level
);


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

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


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.id = catg.id
);


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

SELECT salary FROM customers AS cust
WHERE value > (
    SELECT AVG(amount) FROM employees AS emp
    WHERE emp.status = cust.status
);