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

SELECT name FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.code = rgn.code
);


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

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


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

SELECT code FROM projects AS prj
WHERE amount > (
    SELECT SUM(value) FROM transactions AS cust
    WHERE cust.id = prj.id
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS mgr
    WHERE mgr.level = dept.level
);


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

SELECT salary FROM schedules AS schd
WHERE id IN (
    SELECT id FROM staff AS sale
    WHERE sale.code = schd.code
);


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

SELECT value FROM products AS prod
WHERE amount > (
    SELECT AVG(salary) FROM employees AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT value FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM staff AS acct
    WHERE acct.type = shp.type
);


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

SELECT amount FROM projects AS prj
WHERE id IN (
    SELECT id FROM schedules AS catg
    WHERE catg.type = prj.type
);


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

SELECT salary FROM staff AS empl
WHERE code IN (
    SELECT code FROM requests AS catg
    WHERE catg.level = empl.level
);


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

SELECT name FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.id = prj.id
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS empl
    WHERE empl.type = ordr.type
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.id = shp.id
);


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

SELECT salary FROM customers AS cust
WHERE value > (
    SELECT AVG(amount) FROM tasks AS brc
    WHERE brc.code = cust.code
);


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

SELECT amount FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.level = txn.level
);


Prompt:
Schema:
  employees (alias: emp)(type, date, id, name)
  tasks(level, code, name, id)
Task: Find code from employees where value exceeds the count of value from tasks for the same level.
SQL:

SELECT code FROM employees AS emp
WHERE value > (
    SELECT COUNT(value) FROM tasks AS brc
    WHERE brc.level = emp.level
);


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

SELECT value FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.code = schd.code
);


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

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


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

SELECT name FROM departments AS dept
WHERE id IN (
    SELECT id FROM accounts AS inv
    WHERE inv.code = dept.code
);


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

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


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

SELECT salary FROM invoices AS inv
WHERE amount > (
    SELECT AVG(salary) FROM projects AS acct
    WHERE acct.status = inv.status
);


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

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


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

SELECT name FROM categories AS catg
WHERE status IN (
    SELECT status FROM invoices AS rgn
    WHERE rgn.id = catg.id
);


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

SELECT value FROM invoices AS inv
WHERE id IN (
    SELECT id FROM categories AS empl
    WHERE empl.status = inv.status
);


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

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


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

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


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

SELECT code FROM products AS prod
WHERE level IN (
    SELECT level FROM items AS ord
    WHERE ord.status = prod.status
);


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

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


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM sales AS inv
    WHERE inv.type = emp.type
);


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

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


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

SELECT salary FROM departments AS dept
WHERE value > (
    SELECT AVG(value) FROM schedules AS lne
    WHERE lne.type = dept.type
);


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

SELECT amount FROM products AS prod
WHERE salary > (
    SELECT MAX(salary) FROM employees AS prj
    WHERE prj.type = prod.type
);


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

SELECT id FROM sales AS sale
WHERE level IN (
    SELECT level FROM items AS brc
    WHERE brc.type = sale.type
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = emp.status
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.level = cust.level
);


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

SELECT value FROM items AS lne
WHERE value > (
    SELECT SUM(salary) FROM departments AS empl
    WHERE empl.code = lne.code
);


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

SELECT value FROM branches AS brc
WHERE status IN (
    SELECT status FROM categories AS rgn
    WHERE rgn.status = brc.status
);


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

SELECT salary FROM requests AS ordr
WHERE id IN (
    SELECT id FROM customers AS prj
    WHERE prj.type = ordr.type
);


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

SELECT value FROM branches AS brc
WHERE code IN (
    SELECT code FROM accounts AS empl
    WHERE empl.status = brc.status
);


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

SELECT id FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM requests AS sale
    WHERE sale.level = prj.level
);


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

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


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS prj
    WHERE prj.type = inv.type
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.type = prod.type
);


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

SELECT value FROM items AS lne
WHERE amount > (
    SELECT SUM(value) FROM managers AS ordr
    WHERE ordr.type = lne.type
);


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

SELECT amount FROM employees AS emp
WHERE id IN (
    SELECT id FROM invoices AS empl
    WHERE empl.status = emp.status
);


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

SELECT value FROM regions AS rgn
WHERE id IN (
    SELECT id FROM projects AS catg
    WHERE catg.type = rgn.type
);


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

SELECT salary FROM staff AS empl
WHERE salary > (
    SELECT MIN(value) FROM items AS lne
    WHERE lne.id = empl.id
);


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

SELECT id FROM branches AS brc
WHERE value > (
    SELECT AVG(value) FROM managers AS dept
    WHERE dept.level = brc.level
);


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

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


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

SELECT salary FROM customers AS cust
WHERE id IN (
    SELECT id FROM requests AS empl
    WHERE empl.type = cust.type
);


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

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.code = mgr.code
);


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

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT COUNT(amount) FROM products AS txn
    WHERE txn.level = rgn.level
);


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

SELECT code FROM projects AS prj
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS sale
    WHERE sale.code = prj.code
);


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

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


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

SELECT amount FROM schedules AS schd
WHERE type IN (
    SELECT type FROM items AS dept
    WHERE dept.code = schd.code
);


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

SELECT salary FROM schedules AS schd
WHERE id IN (
    SELECT id FROM projects AS catg
    WHERE catg.level = schd.level
);


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

SELECT amount FROM tasks AS tsk
WHERE amount > (
    SELECT COUNT(salary) FROM branches AS catg
    WHERE catg.code = tsk.code
);


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

SELECT code FROM shipments AS shp
WHERE level IN (
    SELECT level FROM tasks AS cust
    WHERE cust.id = shp.id
);


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

SELECT code FROM categories AS catg
WHERE value > (
    SELECT MAX(value) FROM schedules AS shp
    WHERE shp.type = catg.type
);


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS prj
    WHERE prj.level = sale.level
);


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

SELECT salary FROM schedules AS schd
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS sale
    WHERE sale.status = schd.status
);


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

SELECT value FROM invoices AS inv
WHERE status IN (
    SELECT status FROM tasks AS shp
    WHERE shp.code = inv.code
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM requests AS sale
    WHERE sale.status = cust.status
);


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

SELECT value FROM items AS lne
WHERE amount > (
    SELECT MAX(salary) FROM branches AS empl
    WHERE empl.status = lne.status
);


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

SELECT code FROM items AS lne
WHERE type IN (
    SELECT type FROM accounts AS prj
    WHERE prj.status = lne.status
);


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

SELECT name FROM employees AS emp
WHERE id IN (
    SELECT id FROM products AS acct
    WHERE acct.code = emp.code
);


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS tsk
    WHERE tsk.level = ord.level
);


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

SELECT id FROM shipments AS shp
WHERE level IN (
    SELECT level FROM regions AS inv
    WHERE inv.id = shp.id
);


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

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


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

SELECT name FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM schedules AS txn
    WHERE txn.id = tsk.id
);


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

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


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.code = dept.code
);


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS emp
    WHERE emp.status = sale.status
);


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

SELECT id FROM shipments AS shp
WHERE level IN (
    SELECT level FROM accounts AS cust
    WHERE cust.id = shp.id
);


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

SELECT amount FROM products AS prod
WHERE id IN (
    SELECT id FROM accounts AS catg
    WHERE catg.status = prod.status
);


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

SELECT amount FROM sales AS sale
WHERE value > (
    SELECT MAX(salary) FROM staff AS txn
    WHERE txn.id = sale.id
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM branches AS prj
    WHERE prj.type = sale.type
);


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

SELECT code FROM branches AS brc
WHERE value > (
    SELECT AVG(value) FROM staff AS schd
    WHERE schd.type = brc.type
);


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

SELECT salary FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT amount FROM products AS prod
WHERE amount > (
    SELECT MAX(value) FROM projects AS cust
    WHERE cust.level = prod.level
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.code = shp.code
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.id = rgn.id
);


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

SELECT amount FROM staff AS empl
WHERE code IN (
    SELECT code FROM branches AS cust
    WHERE cust.code = empl.code
);


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM sales AS empl
    WHERE empl.code = emp.code
);


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

SELECT code FROM regions AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM categories AS sale
    WHERE sale.code = rgn.code
);


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

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


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

SELECT value FROM schedules AS schd
WHERE level IN (
    SELECT level FROM requests AS shp
    WHERE shp.type = schd.type
);


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

SELECT id FROM regions AS rgn
WHERE status IN (
    SELECT status FROM sales AS ord
    WHERE ord.level = rgn.level
);


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

SELECT amount FROM transactions AS txn
WHERE value > (
    SELECT AVG(salary) FROM departments AS emp
    WHERE emp.type = txn.type
);


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

SELECT salary FROM categories AS catg
WHERE amount > (
    SELECT AVG(salary) FROM managers AS tsk
    WHERE tsk.status = catg.status
);


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

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


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

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


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

SELECT amount FROM categories AS catg
WHERE level IN (
    SELECT level FROM requests AS dept
    WHERE dept.status = catg.status
);


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

SELECT amount FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.id = tsk.id
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.level = prod.level
);


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

SELECT id FROM customers AS cust
WHERE salary > (
    SELECT MAX(value) FROM accounts AS inv
    WHERE inv.level = cust.level
);


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

SELECT amount FROM categories AS catg
WHERE amount > (
    SELECT COUNT(value) FROM projects AS lne
    WHERE lne.id = catg.id
);


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

SELECT code FROM categories AS catg
WHERE salary > (
    SELECT COUNT(amount) FROM branches AS empl
    WHERE empl.level = catg.level
);


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

SELECT code FROM orders AS ord
WHERE id IN (
    SELECT id FROM managers AS txn
    WHERE txn.status = ord.status
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.status = tsk.status
);


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

SELECT value FROM schedules AS schd
WHERE value > (
    SELECT MIN(amount) FROM products AS shp
    WHERE shp.status = schd.status
);


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT MAX(amount) FROM sales AS inv
    WHERE inv.level = acct.level
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS tsk
    WHERE tsk.id = dept.id
);


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

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


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

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


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

SELECT amount FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM sales AS mgr
    WHERE mgr.code = tsk.code
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS prod
    WHERE prod.status = cust.status
);


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

SELECT name FROM regions AS rgn
WHERE type IN (
    SELECT type FROM orders AS cust
    WHERE cust.type = rgn.type
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.id = dept.id
);


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

SELECT value FROM transactions AS txn
WHERE salary > (
    SELECT AVG(salary) FROM projects AS sale
    WHERE sale.status = txn.status
);


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

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


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

SELECT value FROM managers AS mgr
WHERE level IN (
    SELECT level FROM categories AS tsk
    WHERE tsk.level = mgr.level
);


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

SELECT name FROM managers AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS acct
    WHERE acct.status = mgr.status
);


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

SELECT amount FROM projects AS prj
WHERE status IN (
    SELECT status FROM shipments AS sale
    WHERE sale.level = prj.level
);


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

SELECT name FROM products AS prod
WHERE amount > (
    SELECT MAX(amount) FROM items AS lne
    WHERE lne.code = prod.code
);


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

SELECT name FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS brc
    WHERE brc.type = dept.type
);


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

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


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

SELECT salary FROM staff AS empl
WHERE salary > (
    SELECT MIN(value) FROM items AS dept
    WHERE dept.code = empl.code
);


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

SELECT salary FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.type = tsk.type
);


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

SELECT salary FROM sales AS sale
WHERE value > (
    SELECT AVG(salary) FROM projects AS ord
    WHERE ord.status = sale.status
);


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

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


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

SELECT name FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM requests AS emp
    WHERE emp.status = tsk.status
);


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

SELECT code FROM transactions AS txn
WHERE salary > (
    SELECT SUM(salary) FROM schedules AS tsk
    WHERE tsk.code = txn.code
);


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

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


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

SELECT amount FROM staff AS empl
WHERE amount > (
    SELECT SUM(value) FROM products AS rgn
    WHERE rgn.type = empl.type
);


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

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


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

SELECT salary FROM departments AS dept
WHERE id IN (
    SELECT id FROM transactions AS brc
    WHERE brc.type = dept.type
);


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

SELECT salary FROM projects AS prj
WHERE amount > (
    SELECT SUM(amount) FROM requests AS lne
    WHERE lne.type = prj.type
);


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

SELECT id FROM staff AS empl
WHERE amount > (
    SELECT AVG(value) FROM customers AS mgr
    WHERE mgr.level = empl.level
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM items AS catg
    WHERE catg.status = cust.status
);


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.level = brc.level
);


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

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


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

SELECT name FROM items AS lne
WHERE amount > (
    SELECT SUM(salary) FROM sales AS brc
    WHERE brc.type = lne.type
);


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

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


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

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


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

SELECT id FROM managers AS mgr
WHERE id IN (
    SELECT id FROM orders AS prj
    WHERE prj.code = mgr.code
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.code = dept.code
);


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

SELECT salary FROM branches AS brc
WHERE amount > (
    SELECT AVG(value) FROM staff AS ord
    WHERE ord.code = brc.code
);


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

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


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

SELECT code FROM projects AS prj
WHERE value > (
    SELECT AVG(salary) FROM orders AS emp
    WHERE emp.type = prj.type
);


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

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


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

SELECT value FROM shipments AS shp
WHERE amount > (
    SELECT MIN(amount) FROM products AS prj
    WHERE prj.id = shp.id
);


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

SELECT salary FROM tasks AS tsk
WHERE code IN (
    SELECT code FROM customers AS ordr
    WHERE ordr.id = tsk.id
);


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

SELECT name FROM requests AS ordr
WHERE amount > (
    SELECT AVG(amount) FROM shipments AS cust
    WHERE cust.id = ordr.id
);


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

SELECT salary FROM branches AS brc
WHERE salary > (
    SELECT AVG(value) FROM accounts AS txn
    WHERE txn.id = brc.id
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.level = catg.level
);


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

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


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.status = txn.status
);


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

SELECT name FROM products AS prod
WHERE level IN (
    SELECT level FROM employees AS tsk
    WHERE tsk.status = prod.status
);


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

SELECT name FROM employees AS emp
WHERE code IN (
    SELECT code FROM projects AS mgr
    WHERE mgr.id = emp.id
);


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

SELECT salary FROM schedules AS schd
WHERE id IN (
    SELECT id FROM accounts AS tsk
    WHERE tsk.code = schd.code
);


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

SELECT name FROM tasks AS tsk
WHERE value > (
    SELECT SUM(amount) FROM categories AS inv
    WHERE inv.id = tsk.id
);


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

SELECT name FROM projects AS prj
WHERE type IN (
    SELECT type FROM categories AS schd
    WHERE schd.level = prj.level
);


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

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


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

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


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

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


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.id = dept.id
);


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

SELECT id FROM branches AS brc
WHERE status IN (
    SELECT status FROM departments AS empl
    WHERE empl.id = brc.id
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = inv.level
);


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

SELECT amount FROM branches AS brc
WHERE id IN (
    SELECT id FROM categories AS ord
    WHERE ord.status = brc.status
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS brc
    WHERE brc.code = sale.code
);


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

SELECT name FROM schedules AS schd
WHERE id IN (
    SELECT id FROM invoices AS prj
    WHERE prj.code = schd.code
);


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

SELECT id FROM items AS lne
WHERE salary > (
    SELECT MAX(salary) FROM staff AS ord
    WHERE ord.id = lne.id
);


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

SELECT salary FROM products AS prod
WHERE type IN (
    SELECT type FROM projects AS catg
    WHERE catg.level = prod.level
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.id = shp.id
);


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

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


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS tsk
    WHERE tsk.status = catg.status
);


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

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


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS ord
    WHERE ord.id = acct.id
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.level = txn.level
);


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

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


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

SELECT code FROM managers AS mgr
WHERE type IN (
    SELECT type FROM requests AS txn
    WHERE txn.status = mgr.status
);


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

SELECT name FROM sales AS sale
WHERE status IN (
    SELECT status FROM branches AS rgn
    WHERE rgn.level = sale.level
);


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

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


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.status = ordr.status
);


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

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


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

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


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

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


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

SELECT salary FROM transactions AS txn
WHERE type IN (
    SELECT type FROM invoices AS prod
    WHERE prod.type = txn.type
);


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

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


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

SELECT id FROM products AS prod
WHERE salary > (
    SELECT SUM(value) FROM departments AS dept
    WHERE dept.code = prod.code
);


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

SELECT salary FROM items AS lne
WHERE status IN (
    SELECT status FROM regions AS brc
    WHERE brc.status = lne.status
);


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

SELECT salary FROM managers AS mgr
WHERE code IN (
    SELECT code FROM invoices AS prod
    WHERE prod.type = mgr.type
);


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

SELECT id FROM regions AS rgn
WHERE level IN (
    SELECT level FROM managers AS catg
    WHERE catg.id = rgn.id
);


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

SELECT code FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM orders AS ordr
    WHERE ordr.type = tsk.type
);


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

SELECT salary FROM branches AS brc
WHERE status IN (
    SELECT status FROM requests AS acct
    WHERE acct.status = brc.status
);


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

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


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

SELECT code FROM requests AS ordr
WHERE status IN (
    SELECT status FROM schedules AS prod
    WHERE prod.type = ordr.type
);


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

SELECT amount FROM branches AS brc
WHERE salary > (
    SELECT COUNT(amount) FROM departments AS prj
    WHERE prj.type = brc.type
);


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

SELECT salary FROM invoices AS inv
WHERE level IN (
    SELECT level FROM products AS inv
    WHERE inv.code = inv.code
);


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

SELECT salary FROM categories AS catg
WHERE level IN (
    SELECT level FROM shipments AS prod
    WHERE prod.level = catg.level
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM schedules AS brc
    WHERE brc.id = cust.id
);


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

SELECT code FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM staff AS prj
    WHERE prj.status = ordr.status
);


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

SELECT name FROM categories AS catg
WHERE status IN (
    SELECT status FROM orders AS mgr
    WHERE mgr.level = catg.level
);


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

SELECT value FROM staff AS empl
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT amount FROM requests AS ordr
WHERE level IN (
    SELECT level FROM orders AS mgr
    WHERE mgr.level = ordr.level
);


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

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


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

SELECT value FROM managers AS mgr
WHERE level IN (
    SELECT level FROM branches AS mgr
    WHERE mgr.level = mgr.level
);


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

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


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

SELECT code FROM customers AS cust
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS dept
    WHERE dept.code = cust.code
);


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

SELECT name FROM invoices AS inv
WHERE value > (
    SELECT MIN(value) FROM items AS acct
    WHERE acct.status = inv.status
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.status = prod.status
);


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

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


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

SELECT code FROM projects AS prj
WHERE status IN (
    SELECT status FROM tasks AS lne
    WHERE lne.code = prj.code
);


Prompt:
Schema:
  departments (alias: dept)(level, value, code, type)
  accounts(type, amount, salary, value)
Task: Find amount from departments where salary exceeds the total value from accounts for the same type.
SQL:

SELECT amount FROM departments AS dept
WHERE salary > (
    SELECT SUM(value) FROM accounts AS lne
    WHERE lne.type = dept.type
);


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

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


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT COUNT(value) FROM departments AS cust
    WHERE cust.type = shp.type
);


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

SELECT id FROM tasks AS tsk
WHERE salary > (
    SELECT SUM(amount) FROM requests AS shp
    WHERE shp.id = tsk.id
);


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

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


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

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


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT SUM(amount) FROM projects AS dept
    WHERE dept.code = catg.code
);


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

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


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

SELECT id FROM items AS lne
WHERE salary > (
    SELECT MIN(value) FROM staff AS schd
    WHERE schd.code = lne.code
);


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

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


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

SELECT amount FROM tasks AS tsk
WHERE value > (
    SELECT AVG(value) FROM orders AS sale
    WHERE sale.code = tsk.code
);


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

SELECT value FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM orders AS rgn
    WHERE rgn.type = tsk.type
);


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

SELECT value FROM transactions AS txn
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.code = txn.code
);


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

SELECT value FROM departments AS dept
WHERE id IN (
    SELECT id FROM projects AS cust
    WHERE cust.type = dept.type
);


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

SELECT code FROM employees AS emp
WHERE value > (
    SELECT MIN(salary) FROM regions AS ordr
    WHERE ordr.level = emp.level
);


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

SELECT name FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS ord
    WHERE ord.code = mgr.code
);


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

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


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM categories AS prj
    WHERE prj.status = tsk.status
);


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT MIN(salary) FROM projects AS lne
    WHERE lne.code = cust.code
);


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

SELECT id FROM departments AS dept
WHERE id IN (
    SELECT id FROM transactions AS prj
    WHERE prj.level = dept.level
);


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

SELECT code FROM customers AS cust
WHERE amount > (
    SELECT MAX(value) FROM managers AS lne
    WHERE lne.status = cust.status
);


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

SELECT name FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM shipments AS prj
    WHERE prj.level = tsk.level
);


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

SELECT value FROM requests AS ordr
WHERE status IN (
    SELECT status FROM projects AS prod
    WHERE prod.status = ordr.status
);


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

SELECT name FROM sales AS sale
WHERE id IN (
    SELECT id FROM tasks AS schd
    WHERE schd.id = sale.id
);


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

SELECT id FROM managers AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM items AS ordr
    WHERE ordr.code = mgr.code
);


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

SELECT amount FROM employees AS emp
WHERE amount > (
    SELECT COUNT(value) FROM regions AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT value FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM staff AS acct
    WHERE acct.level = acct.level
);


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

SELECT amount FROM orders AS ord
WHERE type IN (
    SELECT type FROM invoices AS mgr
    WHERE mgr.code = ord.code
);


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

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


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

SELECT value FROM orders AS ord
WHERE value > (
    SELECT MAX(value) FROM staff AS prod
    WHERE prod.status = ord.status
);


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

SELECT value FROM tasks AS tsk
WHERE amount > (
    SELECT MIN(salary) FROM accounts AS schd
    WHERE schd.status = tsk.status
);


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

SELECT value FROM requests AS ordr
WHERE code IN (
    SELECT code FROM projects AS empl
    WHERE empl.level = ordr.level
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM sales AS lne
    WHERE lne.id = brc.id
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS tsk
    WHERE tsk.type = rgn.type
);


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

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


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

SELECT id FROM managers AS mgr
WHERE type IN (
    SELECT type FROM sales AS lne
    WHERE lne.level = mgr.level
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM staff AS schd
    WHERE schd.code = lne.code
);


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

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


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

SELECT value FROM transactions AS txn
WHERE code IN (
    SELECT code FROM projects AS ordr
    WHERE ordr.code = txn.code
);


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

SELECT id FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM managers AS catg
    WHERE catg.type = emp.type
);


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT AVG(amount) FROM accounts AS rgn
    WHERE rgn.level = rgn.level
);


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

SELECT name FROM staff AS empl
WHERE status IN (
    SELECT status FROM regions AS emp
    WHERE emp.id = empl.id
);


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

SELECT amount FROM invoices AS inv
WHERE value > (
    SELECT SUM(salary) FROM schedules AS tsk
    WHERE tsk.code = inv.code
);


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM requests AS cust
    WHERE cust.id = sale.id
);


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

SELECT amount FROM categories AS catg
WHERE type IN (
    SELECT type FROM employees AS catg
    WHERE catg.id = catg.id
);


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

SELECT code FROM staff AS empl
WHERE salary > (
    SELECT SUM(value) FROM employees AS prj
    WHERE prj.code = empl.code
);


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

SELECT amount FROM shipments AS shp
WHERE amount > (
    SELECT MAX(value) FROM items AS inv
    WHERE inv.level = shp.level
);


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

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


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

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


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

SELECT name FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS tsk
    WHERE tsk.id = catg.id
);


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

SELECT salary FROM employees AS emp
WHERE level IN (
    SELECT level FROM staff AS shp
    WHERE shp.code = emp.code
);


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

SELECT name FROM departments AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM managers AS tsk
    WHERE tsk.id = dept.id
);


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

SELECT amount FROM shipments AS shp
WHERE status IN (
    SELECT status FROM managers AS mgr
    WHERE mgr.level = shp.level
);


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

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


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

SELECT amount FROM departments AS dept
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS prj
    WHERE prj.type = dept.type
);


Prompt:
Schema:
  items (alias: lne)(name, type, status, amount)
  orders(date, salary, status, type)
Task: Find name from items where amount exceeds the total salary from orders for the same status.
SQL:

SELECT name FROM items AS lne
WHERE amount > (
    SELECT SUM(salary) FROM orders AS empl
    WHERE empl.status = lne.status
);


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

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


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

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


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

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


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

SELECT code FROM shipments AS shp
WHERE level IN (
    SELECT level FROM staff AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM staff AS dept
    WHERE dept.level = cust.level
);


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

SELECT code FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM managers AS ordr
    WHERE ordr.status = catg.status
);


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

SELECT code FROM regions AS rgn
WHERE id IN (
    SELECT id FROM staff AS prj
    WHERE prj.code = rgn.code
);


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

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


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT MAX(amount) FROM regions AS prod
    WHERE prod.level = acct.level
);


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

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


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

SELECT id FROM requests AS ordr
WHERE level IN (
    SELECT level FROM staff AS catg
    WHERE catg.status = ordr.status
);


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

SELECT amount FROM shipments AS shp
WHERE salary > (
    SELECT MIN(value) FROM projects AS acct
    WHERE acct.id = shp.id
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.status = brc.status
);


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM sales AS empl
    WHERE empl.status = dept.status
);


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

SELECT amount FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.level = rgn.level
);


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

SELECT code FROM accounts AS acct
WHERE id IN (
    SELECT id FROM requests AS lne
    WHERE lne.level = acct.level
);


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

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


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

SELECT code FROM items AS lne
WHERE status IN (
    SELECT status FROM requests AS prod
    WHERE prod.id = lne.id
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM schedules AS shp
    WHERE shp.code = prod.code
);


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT value FROM branches AS brc
WHERE code IN (
    SELECT code FROM employees AS lne
    WHERE lne.level = brc.level
);


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

SELECT amount FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM sales AS prod
    WHERE prod.code = shp.code
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.status = empl.status
);


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

SELECT code FROM customers AS cust
WHERE value > (
    SELECT MAX(amount) FROM invoices AS sale
    WHERE sale.status = cust.status
);


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

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


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

SELECT name FROM categories AS catg
WHERE level IN (
    SELECT level FROM sales AS rgn
    WHERE rgn.status = catg.status
);


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

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


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

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


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

SELECT id FROM categories AS catg
WHERE type IN (
    SELECT type FROM regions AS shp
    WHERE shp.code = catg.code
);


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

SELECT name FROM projects AS prj
WHERE salary > (
    SELECT COUNT(salary) FROM schedules AS shp
    WHERE shp.id = prj.id
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM schedules AS prod
    WHERE prod.code = emp.code
);


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

SELECT salary FROM orders AS ord
WHERE id IN (
    SELECT id FROM requests AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT code FROM projects AS prj
WHERE salary > (
    SELECT COUNT(value) FROM staff AS mgr
    WHERE mgr.status = prj.status
);


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

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


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

SELECT salary FROM staff AS empl
WHERE type IN (
    SELECT type FROM customers AS dept
    WHERE dept.type = empl.type
);


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

SELECT code FROM managers AS mgr
WHERE salary > (
    SELECT AVG(salary) FROM projects AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT value FROM categories AS catg
WHERE level IN (
    SELECT level FROM managers AS ord
    WHERE ord.level = catg.level
);


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

SELECT salary FROM categories AS catg
WHERE salary > (
    SELECT SUM(salary) FROM branches AS cust
    WHERE cust.id = catg.id
);