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

SELECT value FROM departments AS dept
WHERE type IN (
    SELECT type FROM employees AS lne
    WHERE lne.status = dept.status
);


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

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


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

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


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM items AS brc
    WHERE brc.level = cust.level
);


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

SELECT id FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.code = schd.code
);


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

SELECT amount FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT name FROM managers AS mgr
WHERE type IN (
    SELECT type FROM sales AS brc
    WHERE brc.id = mgr.id
);


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

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


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

SELECT value FROM transactions AS txn
WHERE id IN (
    SELECT id FROM sales AS lne
    WHERE lne.level = txn.level
);


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT AVG(amount) FROM customers AS empl
    WHERE empl.id = acct.id
);


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

SELECT name FROM managers AS mgr
WHERE level IN (
    SELECT level FROM branches AS schd
    WHERE schd.type = mgr.type
);


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

SELECT salary FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.code = shp.code
);


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

SELECT salary FROM requests AS ordr
WHERE status IN (
    SELECT status FROM orders AS tsk
    WHERE tsk.id = ordr.id
);


Prompt:
Schema:
  departments (alias: dept)(name, id, type, amount)
  accounts(value, name, id, date)
Task: Retrieve name from departments with amount above the SUM(amount) of accounts rows sharing the same status.
SQL:

SELECT name FROM departments AS dept
WHERE amount > (
    SELECT SUM(amount) FROM accounts AS tsk
    WHERE tsk.status = dept.status
);


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

SELECT id FROM shipments AS shp
WHERE code IN (
    SELECT code FROM schedules AS prj
    WHERE prj.status = shp.status
);


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

SELECT name FROM staff AS empl
WHERE status IN (
    SELECT status FROM shipments AS mgr
    WHERE mgr.code = empl.code
);


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

SELECT code FROM shipments AS shp
WHERE type IN (
    SELECT type FROM staff AS prj
    WHERE prj.level = shp.level
);


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

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


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

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


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

SELECT id FROM tasks AS tsk
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.type = tsk.type
);


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

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


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

SELECT id FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM schedules AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT amount FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.status = ord.status
);


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

SELECT value FROM transactions AS txn
WHERE level IN (
    SELECT level FROM items AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT value FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS sale
    WHERE sale.type = empl.type
);


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

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


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

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


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

SELECT salary FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS cust
    WHERE cust.level = emp.level
);


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT AVG(value) FROM customers AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT name FROM products AS prod
WHERE id IN (
    SELECT id FROM shipments AS cust
    WHERE cust.type = prod.type
);


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS brc
    WHERE brc.type = ordr.type
);


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

SELECT amount FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.type = brc.type
);


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

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


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

SELECT name FROM products AS prod
WHERE type IN (
    SELECT type FROM requests AS schd
    WHERE schd.status = prod.status
);


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

SELECT amount FROM shipments AS shp
WHERE id IN (
    SELECT id FROM categories AS acct
    WHERE acct.level = shp.level
);


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

SELECT name FROM invoices AS inv
WHERE status IN (
    SELECT status FROM projects AS acct
    WHERE acct.type = inv.type
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM transactions AS tsk
    WHERE tsk.level = lne.level
);


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

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


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

SELECT value FROM branches AS brc
WHERE value > (
    SELECT SUM(amount) FROM departments AS tsk
    WHERE tsk.code = brc.code
);


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

SELECT amount FROM tasks AS tsk
WHERE type IN (
    SELECT type FROM branches AS empl
    WHERE empl.status = tsk.status
);


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

SELECT code FROM invoices AS inv
WHERE value > (
    SELECT MAX(value) FROM sales AS catg
    WHERE catg.id = inv.id
);


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

SELECT code FROM tasks AS tsk
WHERE level IN (
    SELECT level FROM projects AS tsk
    WHERE tsk.status = tsk.status
);


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

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


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

SELECT salary FROM employees AS emp
WHERE salary > (
    SELECT AVG(value) FROM shipments AS lne
    WHERE lne.status = emp.status
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.type = txn.type
);


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

SELECT code FROM requests AS ordr
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS txn
    WHERE txn.status = ordr.status
);


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

SELECT id FROM accounts AS acct
WHERE salary > (
    SELECT SUM(value) FROM schedules AS rgn
    WHERE rgn.id = acct.id
);


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

SELECT code FROM regions AS rgn
WHERE status IN (
    SELECT status FROM accounts AS sale
    WHERE sale.type = rgn.type
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT salary FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = ord.level
);


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

SELECT id FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.type = rgn.type
);


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM categories AS ord
    WHERE ord.id = prj.id
);


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

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


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

SELECT id FROM employees AS emp
WHERE code IN (
    SELECT code FROM departments AS sale
    WHERE sale.status = emp.status
);


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

SELECT name FROM transactions AS txn
WHERE level IN (
    SELECT level FROM departments AS rgn
    WHERE rgn.status = txn.status
);


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

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


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

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


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.level = ordr.level
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.code = inv.code
);


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

SELECT value FROM items AS lne
WHERE amount > (
    SELECT MAX(amount) FROM categories AS prod
    WHERE prod.type = lne.type
);


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

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


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

SELECT code FROM customers AS cust
WHERE salary > (
    SELECT COUNT(salary) FROM regions AS txn
    WHERE txn.code = cust.code
);


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

SELECT amount FROM invoices AS inv
WHERE amount > (
    SELECT COUNT(value) FROM projects AS empl
    WHERE empl.status = inv.status
);


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

SELECT id FROM departments AS dept
WHERE status IN (
    SELECT status FROM employees AS prod
    WHERE prod.type = dept.type
);


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

SELECT amount FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM requests AS prj
    WHERE prj.status = prj.status
);


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

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


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM managers AS sale
    WHERE sale.id = prod.id
);


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

SELECT salary FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS txn
    WHERE txn.status = cust.status
);


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

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


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

SELECT amount FROM requests AS ordr
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.status = ordr.status
);


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

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


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

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


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

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


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

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


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

SELECT code FROM orders AS ord
WHERE level IN (
    SELECT level FROM managers AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT salary FROM sales AS sale
WHERE salary > (
    SELECT MAX(amount) FROM departments AS rgn
    WHERE rgn.level = sale.level
);


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

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


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

SELECT value FROM invoices AS inv
WHERE salary > (
    SELECT MAX(salary) FROM products AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT code FROM items AS lne
WHERE amount > (
    SELECT AVG(salary) FROM staff AS emp
    WHERE emp.type = lne.type
);


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

SELECT id FROM requests AS ordr
WHERE status IN (
    SELECT status FROM tasks AS schd
    WHERE schd.code = ordr.code
);


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

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


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

SELECT amount FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM managers AS rgn
    WHERE rgn.code = sale.code
);


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

SELECT code FROM departments AS dept
WHERE amount > (
    SELECT SUM(amount) FROM shipments AS prod
    WHERE prod.id = dept.id
);


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

SELECT amount FROM departments AS dept
WHERE status IN (
    SELECT status FROM invoices AS shp
    WHERE shp.level = dept.level
);


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

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


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

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


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

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


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

SELECT name FROM employees AS emp
WHERE code IN (
    SELECT code FROM managers AS rgn
    WHERE rgn.code = emp.code
);


Prompt:
Schema:
  tasks (alias: tsk)(level, amount, code, type)
  requests(level, amount, code, type)
Task: Find code from tasks where salary exceeds the total salary from requests for the same level.
SQL:

SELECT code FROM tasks AS tsk
WHERE salary > (
    SELECT SUM(salary) FROM requests AS sale
    WHERE sale.level = tsk.level
);


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

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


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

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


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

SELECT name FROM orders AS ord
WHERE code IN (
    SELECT code FROM employees AS dept
    WHERE dept.level = ord.level
);


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

SELECT id FROM regions AS rgn
WHERE amount > (
    SELECT MIN(amount) FROM invoices AS lne
    WHERE lne.type = rgn.type
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM managers AS inv
    WHERE inv.status = shp.status
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.level = ordr.level
);


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

SELECT amount FROM transactions AS txn
WHERE code IN (
    SELECT code FROM customers AS mgr
    WHERE mgr.status = txn.status
);


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

SELECT code FROM projects AS prj
WHERE code IN (
    SELECT code FROM managers AS tsk
    WHERE tsk.type = prj.type
);


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

SELECT amount FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.status = schd.status
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.code = prod.code
);


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

SELECT name FROM employees AS emp
WHERE salary > (
    SELECT MIN(salary) FROM transactions AS inv
    WHERE inv.code = emp.code
);


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

SELECT amount FROM managers AS mgr
WHERE id IN (
    SELECT id FROM regions AS ord
    WHERE ord.status = mgr.status
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.status = schd.status
);


Prompt:
Schema:
  accounts (alias: acct)(level, date, code, type)
  branches(date, name, type, salary)
Task: Find salary from accounts where amount exceeds the minimum amount from branches for the same code.
SQL:

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


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

SELECT name FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.id = sale.id
);


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

SELECT code FROM tasks AS tsk
WHERE value > (
    SELECT SUM(value) FROM schedules AS inv
    WHERE inv.type = tsk.type
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.type = ordr.type
);


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

SELECT id FROM branches AS brc
WHERE id IN (
    SELECT id FROM categories AS shp
    WHERE shp.level = brc.level
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT value FROM projects AS prj
WHERE code IN (
    SELECT code FROM categories AS mgr
    WHERE mgr.id = prj.id
);


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

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


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

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


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

SELECT code FROM items AS lne
WHERE type IN (
    SELECT type FROM customers AS txn
    WHERE txn.code = lne.code
);


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

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


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

SELECT name FROM invoices AS inv
WHERE salary > (
    SELECT AVG(value) FROM requests AS inv
    WHERE inv.code = inv.code
);


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

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


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

SELECT value FROM invoices AS inv
WHERE value > (
    SELECT SUM(salary) FROM schedules AS prj
    WHERE prj.type = inv.type
);


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

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


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

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


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

SELECT salary FROM customers AS cust
WHERE status IN (
    SELECT status FROM branches AS acct
    WHERE acct.level = cust.level
);


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

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


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

SELECT name FROM accounts AS acct
WHERE amount > (
    SELECT MIN(value) FROM regions AS empl
    WHERE empl.id = acct.id
);


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

SELECT id FROM projects AS prj
WHERE value > (
    SELECT COUNT(value) FROM invoices AS acct
    WHERE acct.type = prj.type
);


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

SELECT code FROM sales AS sale
WHERE value > (
    SELECT AVG(value) FROM customers AS txn
    WHERE txn.type = sale.type
);


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

SELECT name FROM categories AS catg
WHERE value > (
    SELECT COUNT(value) FROM schedules AS brc
    WHERE brc.code = catg.code
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.code = cust.code
);


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

SELECT value FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.id = prj.id
);


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

SELECT name FROM branches AS brc
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS sale
    WHERE sale.status = brc.status
);


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

SELECT code FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.id = mgr.id
);


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

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


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

SELECT code FROM products AS prod
WHERE code IN (
    SELECT code FROM branches AS emp
    WHERE emp.code = prod.code
);


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

SELECT code FROM employees AS emp
WHERE id IN (
    SELECT id FROM orders AS prj
    WHERE prj.code = emp.code
);


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

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


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

SELECT value FROM accounts AS acct
WHERE value > (
    SELECT MAX(amount) FROM products AS shp
    WHERE shp.code = acct.code
);


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

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


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

SELECT code FROM items AS lne
WHERE amount > (
    SELECT MIN(salary) FROM regions AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT id FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.status = shp.status
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS acct
    WHERE acct.id = rgn.id
);


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

SELECT amount FROM accounts AS acct
WHERE value > (
    SELECT MAX(value) FROM products AS prj
    WHERE prj.type = acct.type
);


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

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


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

SELECT salary FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.status = empl.status
);


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

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


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT salary FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.type = ordr.type
);


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

SELECT value FROM projects AS prj
WHERE level IN (
    SELECT level FROM managers AS sale
    WHERE sale.type = prj.type
);


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

SELECT salary FROM orders AS ord
WHERE status IN (
    SELECT status FROM departments AS acct
    WHERE acct.type = ord.type
);


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

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


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

SELECT value FROM sales AS sale
WHERE level IN (
    SELECT level FROM orders AS catg
    WHERE catg.type = sale.type
);


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

SELECT value FROM items AS lne
WHERE salary > (
    SELECT SUM(value) FROM invoices AS shp
    WHERE shp.status = lne.status
);


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

SELECT id FROM sales AS sale
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.type = sale.type
);


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

SELECT salary FROM categories AS catg
WHERE amount > (
    SELECT AVG(salary) FROM staff AS empl
    WHERE empl.code = catg.code
);


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

SELECT code FROM categories AS catg
WHERE value > (
    SELECT AVG(salary) FROM sales AS schd
    WHERE schd.status = catg.status
);


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

SELECT amount FROM invoices AS inv
WHERE type IN (
    SELECT type FROM staff AS txn
    WHERE txn.id = inv.id
);


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

SELECT salary FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.id = dept.id
);


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

SELECT name FROM regions AS rgn
WHERE amount > (
    SELECT MAX(salary) FROM categories AS shp
    WHERE shp.status = rgn.status
);


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

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


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM managers AS txn
    WHERE txn.level = lne.level
);


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

SELECT code FROM invoices AS inv
WHERE type IN (
    SELECT type FROM requests AS prj
    WHERE prj.status = inv.status
);


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

SELECT value FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM staff AS prj
    WHERE prj.id = rgn.id
);


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

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


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

SELECT value FROM employees AS emp
WHERE value > (
    SELECT MAX(value) FROM schedules AS rgn
    WHERE rgn.level = emp.level
);


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

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


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

SELECT value FROM items AS lne
WHERE type IN (
    SELECT type FROM branches AS shp
    WHERE shp.code = lne.code
);


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

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


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

SELECT amount FROM employees AS emp
WHERE amount > (
    SELECT AVG(salary) FROM managers AS lne
    WHERE lne.id = emp.id
);


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

SELECT name FROM tasks AS tsk
WHERE amount > (
    SELECT COUNT(value) FROM staff AS ord
    WHERE ord.type = tsk.type
);


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

SELECT amount FROM sales AS sale
WHERE level IN (
    SELECT level FROM categories AS prod
    WHERE prod.level = sale.level
);


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

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


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM requests AS inv
    WHERE inv.status = lne.status
);


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

SELECT code FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM invoices AS ord
    WHERE ord.level = tsk.level
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.code = inv.code
);


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

SELECT salary FROM orders AS ord
WHERE value > (
    SELECT MAX(amount) FROM customers AS cust
    WHERE cust.level = ord.level
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM staff AS brc
    WHERE brc.code = shp.code
);


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

SELECT name FROM branches AS brc
WHERE level IN (
    SELECT level FROM projects AS catg
    WHERE catg.type = brc.type
);


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

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


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

SELECT amount FROM schedules AS schd
WHERE amount > (
    SELECT MIN(amount) FROM branches AS lne
    WHERE lne.id = schd.id
);


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

SELECT name FROM regions AS rgn
WHERE type IN (
    SELECT type FROM schedules AS prj
    WHERE prj.level = rgn.level
);


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

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


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

SELECT amount FROM sales AS sale
WHERE id IN (
    SELECT id FROM departments AS ordr
    WHERE ordr.level = sale.level
);


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

SELECT amount FROM schedules AS schd
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.id = schd.id
);


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

SELECT amount FROM items AS lne
WHERE salary > (
    SELECT SUM(amount) FROM tasks AS emp
    WHERE emp.type = lne.type
);


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

SELECT salary FROM categories AS catg
WHERE value > (
    SELECT COUNT(salary) FROM shipments AS emp
    WHERE emp.code = catg.code
);


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

SELECT name FROM regions AS rgn
WHERE salary > (
    SELECT SUM(salary) FROM branches AS dept
    WHERE dept.code = rgn.code
);


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

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


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

SELECT code FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS brc
    WHERE brc.level = txn.level
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS tsk
    WHERE tsk.code = ordr.code
);


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

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


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

SELECT name FROM accounts AS acct
WHERE value > (
    SELECT COUNT(value) FROM transactions AS empl
    WHERE empl.id = acct.id
);


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

SELECT value FROM shipments AS shp
WHERE status IN (
    SELECT status FROM transactions AS acct
    WHERE acct.level = shp.level
);


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

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


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

SELECT id FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.type = lne.type
);


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

SELECT salary FROM branches AS brc
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.status = brc.status
);


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

SELECT name FROM accounts AS acct
WHERE type IN (
    SELECT type FROM tasks AS inv
    WHERE inv.code = acct.code
);


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

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT code FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.type = brc.type
);


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

SELECT amount FROM departments AS dept
WHERE id IN (
    SELECT id FROM invoices AS emp
    WHERE emp.level = dept.level
);


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

SELECT value FROM branches AS brc
WHERE code IN (
    SELECT code FROM invoices AS emp
    WHERE emp.type = brc.type
);


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

SELECT id FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM accounts AS tsk
    WHERE tsk.status = brc.status
);


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

SELECT amount FROM schedules AS schd
WHERE amount > (
    SELECT MAX(amount) FROM customers AS mgr
    WHERE mgr.status = schd.status
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE type IN (
    SELECT type FROM orders AS inv
    WHERE inv.level = mgr.level
);


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

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


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

SELECT code FROM transactions AS txn
WHERE level IN (
    SELECT level FROM staff AS shp
    WHERE shp.id = txn.id
);


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

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


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

SELECT code FROM staff AS empl
WHERE value > (
    SELECT COUNT(amount) FROM accounts AS empl
    WHERE empl.type = empl.type
);


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

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


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

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


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

SELECT value FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM sales AS tsk
    WHERE tsk.type = brc.type
);


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

SELECT salary FROM items AS lne
WHERE code IN (
    SELECT code FROM accounts AS ordr
    WHERE ordr.status = lne.status
);


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

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


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

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


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

SELECT amount FROM customers AS cust
WHERE value > (
    SELECT COUNT(amount) FROM accounts AS catg
    WHERE catg.status = cust.status
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM invoices AS schd
    WHERE schd.status = shp.status
);


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

SELECT amount FROM accounts AS acct
WHERE status IN (
    SELECT status FROM products AS sale
    WHERE sale.level = acct.level
);


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

SELECT id FROM shipments AS shp
WHERE salary > (
    SELECT SUM(value) FROM projects AS brc
    WHERE brc.type = shp.type
);


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

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


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

SELECT name FROM customers AS cust
WHERE amount > (
    SELECT MIN(value) FROM projects AS empl
    WHERE empl.level = cust.level
);


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

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


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

SELECT code FROM projects AS prj
WHERE status IN (
    SELECT status FROM requests AS inv
    WHERE inv.status = prj.status
);


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

SELECT id FROM sales AS sale
WHERE id IN (
    SELECT id FROM schedules AS brc
    WHERE brc.status = sale.status
);


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

SELECT name FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.level = shp.level
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM sales AS empl
    WHERE empl.level = ord.level
);


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

SELECT code FROM projects AS prj
WHERE amount > (
    SELECT SUM(salary) FROM employees AS txn
    WHERE txn.status = prj.status
);


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

SELECT id FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.status = cust.status
);


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

SELECT code FROM schedules AS schd
WHERE status IN (
    SELECT status FROM transactions AS dept
    WHERE dept.id = schd.id
);


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

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


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.code = txn.code
);


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

SELECT value FROM branches AS brc
WHERE code IN (
    SELECT code FROM shipments AS mgr
    WHERE mgr.status = brc.status
);


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

SELECT name FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM managers AS empl
    WHERE empl.id = lne.id
);


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

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


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

SELECT salary FROM projects AS prj
WHERE code IN (
    SELECT code FROM shipments AS acct
    WHERE acct.level = prj.level
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE salary > (
    SELECT MAX(amount) FROM departments AS acct
    WHERE acct.level = schd.level
);


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

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


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

SELECT id FROM invoices AS inv
WHERE amount > (
    SELECT SUM(value) FROM departments AS prj
    WHERE prj.id = inv.id
);


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

SELECT value FROM staff AS empl
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS tsk
    WHERE tsk.code = empl.code
);


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

SELECT amount FROM orders AS ord
WHERE level IN (
    SELECT level FROM sales AS catg
    WHERE catg.level = ord.level
);


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

SELECT code FROM categories AS catg
WHERE value > (
    SELECT MIN(salary) FROM managers AS schd
    WHERE schd.code = catg.code
);


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

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


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

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


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

SELECT amount FROM shipments AS shp
WHERE type IN (
    SELECT type FROM branches AS sale
    WHERE sale.id = shp.id
);


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

SELECT id FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM schedules AS inv
    WHERE inv.type = prod.type
);


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

SELECT value FROM customers AS cust
WHERE code IN (
    SELECT code FROM schedules AS dept
    WHERE dept.type = cust.type
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.level = emp.level
);


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

SELECT value FROM tasks AS tsk
WHERE status IN (
    SELECT status FROM departments AS ord
    WHERE ord.type = tsk.type
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.type = catg.type
);


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

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


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

SELECT code FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS brc
    WHERE brc.type = dept.type
);


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

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


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

SELECT value FROM schedules AS schd
WHERE amount > (
    SELECT MAX(value) FROM regions AS tsk
    WHERE tsk.id = schd.id
);


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

SELECT code FROM shipments AS shp
WHERE EXISTS (
    SELECT 1 FROM managers AS prj
    WHERE prj.type = shp.type
);


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

SELECT name FROM invoices AS inv
WHERE id IN (
    SELECT id FROM categories AS dept
    WHERE dept.level = inv.level
);


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

SELECT id FROM staff AS empl
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.status = empl.status
);


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

SELECT amount FROM accounts AS acct
WHERE value > (
    SELECT AVG(value) FROM regions AS empl
    WHERE empl.status = acct.status
);


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

SELECT salary FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM accounts AS tsk
    WHERE tsk.level = brc.level
);


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

SELECT value FROM sales AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM customers AS shp
    WHERE shp.status = sale.status
);


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

SELECT value FROM regions AS rgn
WHERE value > (
    SELECT COUNT(amount) FROM requests AS prj
    WHERE prj.status = rgn.status
);


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

SELECT code FROM items AS lne
WHERE type IN (
    SELECT type FROM branches AS sale
    WHERE sale.status = lne.status
);


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

SELECT salary FROM schedules AS schd
WHERE type IN (
    SELECT type FROM requests AS ord
    WHERE ord.level = schd.level
);


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

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


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

SELECT amount FROM sales AS sale
WHERE value > (
    SELECT SUM(salary) FROM departments AS acct
    WHERE acct.id = sale.id
);


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

SELECT code FROM accounts AS acct
WHERE type IN (
    SELECT type FROM managers AS cust
    WHERE cust.type = acct.type
);


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

SELECT code FROM shipments AS shp
WHERE salary > (
    SELECT SUM(amount) FROM branches AS empl
    WHERE empl.type = shp.type
);


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

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


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

SELECT code FROM departments AS dept
WHERE status IN (
    SELECT status FROM sales AS prod
    WHERE prod.code = dept.code
);


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

SELECT name FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.status = inv.status
);


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

SELECT code FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS dept
    WHERE dept.code = sale.code
);


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

SELECT amount FROM transactions AS txn
WHERE id IN (
    SELECT id FROM managers AS tsk
    WHERE tsk.id = txn.id
);


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

SELECT code FROM projects AS prj
WHERE EXISTS (
    SELECT 1 FROM shipments AS catg
    WHERE catg.code = prj.code
);


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

SELECT id FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.level = mgr.level
);


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

SELECT id FROM transactions AS txn
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS inv
    WHERE inv.code = txn.code
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.code = ordr.code
);


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

SELECT salary FROM schedules AS schd
WHERE value > (
    SELECT MIN(salary) FROM tasks AS shp
    WHERE shp.type = schd.type
);


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM sales AS mgr
    WHERE mgr.status = ordr.status
);


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

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


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

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


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

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


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

SELECT id FROM sales AS sale
WHERE value > (
    SELECT COUNT(value) FROM accounts AS dept
    WHERE dept.status = sale.status
);


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

SELECT value FROM customers AS cust
WHERE status IN (
    SELECT status FROM products AS cust
    WHERE cust.id = cust.id
);


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

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


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

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


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

SELECT salary FROM invoices AS inv
WHERE status IN (
    SELECT status FROM projects AS lne
    WHERE lne.type = inv.type
);


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

SELECT id FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM regions AS prj
    WHERE prj.code = brc.code
);


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM items AS schd
    WHERE schd.id = ord.id
);


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

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


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

SELECT id FROM departments AS dept
WHERE status IN (
    SELECT status FROM projects AS prod
    WHERE prod.code = dept.code
);


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

SELECT name FROM branches AS brc
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.status = brc.status
);


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

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


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

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


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

SELECT id FROM branches AS brc
WHERE code IN (
    SELECT code FROM orders AS acct
    WHERE acct.status = brc.status
);


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

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


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

SELECT name FROM customers AS cust
WHERE status IN (
    SELECT status FROM employees AS inv
    WHERE inv.status = cust.status
);


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

SELECT salary FROM regions AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.level = rgn.level
);


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

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


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

SELECT name FROM shipments AS shp
WHERE type IN (
    SELECT type FROM schedules AS prod
    WHERE prod.id = shp.id
);


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

SELECT id FROM categories AS catg
WHERE salary > (
    SELECT MIN(value) FROM regions AS cust
    WHERE cust.status = catg.status
);


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

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