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

SELECT amount FROM employees AS emp
WHERE amount > (
    SELECT MAX(value) FROM budgets AS budg
    WHERE budg.level = emp.level
);


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

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


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

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


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

SELECT amount FROM categories AS catg
WHERE salary > (
    SELECT SUM(amount) FROM regions AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT salary FROM regions AS rgn
WHERE level IN (
    SELECT level FROM budgets AS budg
    WHERE budg.level = rgn.level
);


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

SELECT name FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT amount FROM shipments AS shp
WHERE type IN (
    SELECT type FROM employees AS emp
    WHERE emp.status = shp.status
);


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.code = ordr.code
);


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

SELECT value FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.id = txn.id
);


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

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


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

SELECT code FROM budgets AS budg
WHERE value > (
    SELECT MAX(salary) FROM employees AS emp
    WHERE emp.level = budg.level
);


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

SELECT id FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.status = catg.status
);


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

SELECT amount FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = emp.level
);


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

SELECT name FROM products AS prod
WHERE salary > (
    SELECT MAX(salary) FROM transactions AS txn
    WHERE txn.level = prod.level
);


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

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


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

SELECT value FROM managers AS mgr
WHERE value > (
    SELECT MAX(amount) FROM items AS lne
    WHERE lne.code = mgr.code
);


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

SELECT value FROM items AS lne
WHERE status IN (
    SELECT status FROM sales AS sale
    WHERE sale.status = lne.status
);


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

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


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

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


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.id = schd.id
);


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

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


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

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


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

SELECT name FROM shipments AS shp
WHERE type IN (
    SELECT type FROM services AS srvc
    WHERE srvc.status = shp.status
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.id = sale.id
);


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

SELECT code FROM categories AS catg
WHERE amount > (
    SELECT AVG(amount) FROM departments AS dept
    WHERE dept.level = catg.level
);


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

SELECT amount FROM categories AS catg
WHERE amount > (
    SELECT AVG(value) FROM services AS srvc
    WHERE srvc.status = catg.status
);


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

SELECT id FROM invoices AS inv
WHERE status IN (
    SELECT status FROM services AS srvc
    WHERE srvc.code = inv.code
);


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

SELECT name FROM categories AS catg
WHERE value > (
    SELECT COUNT(value) FROM regions AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT id FROM transactions AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM customers AS cust
    WHERE cust.status = txn.status
);


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

SELECT name FROM shipments AS shp
WHERE level IN (
    SELECT level FROM invoices AS inv
    WHERE inv.type = shp.type
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.level = lne.level
);


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

SELECT code FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.id = lne.id
);


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

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


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

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


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

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


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

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


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.status = ordr.status
);


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

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


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

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


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

SELECT amount FROM customers AS cust
WHERE code IN (
    SELECT code FROM invoices AS inv
    WHERE inv.level = cust.level
);


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

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


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = emp.level
);


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

SELECT amount FROM shipments AS shp
WHERE type IN (
    SELECT type FROM services AS srvc
    WHERE srvc.type = shp.type
);


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

SELECT amount FROM services AS srvc
WHERE type IN (
    SELECT type FROM requests AS ordr
    WHERE ordr.id = srvc.id
);


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

SELECT name FROM invoices AS inv
WHERE level IN (
    SELECT level FROM budgets AS budg
    WHERE budg.id = inv.id
);


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

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


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

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


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

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


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

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


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

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


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

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


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

SELECT code FROM departments AS dept
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.id = dept.id
);


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

SELECT amount FROM invoices AS inv
WHERE status IN (
    SELECT status FROM sales AS sale
    WHERE sale.code = inv.code
);


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.id = prod.id
);


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.code = ord.code
);


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

SELECT name FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.status = prod.status
);


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

SELECT salary FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.level = catg.level
);


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

SELECT code FROM accounts AS acct
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.type = acct.type
);


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

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


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

SELECT name FROM schedules AS schd
WHERE code IN (
    SELECT code FROM shipments AS shp
    WHERE shp.id = schd.id
);


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

SELECT name FROM requests AS ordr
WHERE type IN (
    SELECT type FROM services AS srvc
    WHERE srvc.status = ordr.status
);


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

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


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

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


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

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


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

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


Prompt:
Schema:
  budgets (alias: budg)(value, date, name, amount)
  categories(amount, name, id, salary)
Task: Find name from budgets where amount exceeds the average salary from categories for the same type.
SQL:

SELECT name FROM budgets AS budg
WHERE amount > (
    SELECT SUM(salary) FROM categories AS catg
    WHERE catg.type = budg.type
);


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

SELECT salary FROM items AS lne
WHERE value > (
    SELECT MIN(value) FROM transactions AS txn
    WHERE txn.level = lne.level
);


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

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


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

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


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

SELECT amount FROM regions AS rgn
WHERE level IN (
    SELECT level FROM invoices AS inv
    WHERE inv.status = rgn.status
);


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

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


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

SELECT salary FROM schedules AS schd
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.type = schd.type
);


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

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


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

SELECT value FROM transactions AS txn
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.code = txn.code
);


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

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


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

SELECT code FROM departments AS dept
WHERE amount > (
    SELECT SUM(value) FROM warehouses AS whs
    WHERE whs.status = dept.status
);


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

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


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

SELECT code FROM customers AS cust
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.level = cust.level
);


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

SELECT id FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.id = srvc.id
);


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

SELECT name FROM staff AS empl
WHERE value > (
    SELECT COUNT(amount) FROM items AS lne
    WHERE lne.type = empl.type
);


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

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


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

SELECT code FROM customers AS cust
WHERE salary > (
    SELECT SUM(salary) FROM requests AS ordr
    WHERE ordr.id = cust.id
);


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

SELECT value FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.status = lne.status
);


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

SELECT name FROM staff AS empl
WHERE code IN (
    SELECT code FROM accounts AS acct
    WHERE acct.id = empl.id
);


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

SELECT value FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT value FROM products AS prod
WHERE code IN (
    SELECT code FROM categories AS catg
    WHERE catg.status = prod.status
);


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

SELECT id FROM schedules AS schd
WHERE id IN (
    SELECT id FROM departments AS dept
    WHERE dept.level = schd.level
);


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

SELECT amount FROM sales AS sale
WHERE value > (
    SELECT COUNT(amount) FROM schedules AS schd
    WHERE schd.type = sale.type
);


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

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


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

SELECT value FROM products AS prod
WHERE amount > (
    SELECT COUNT(value) FROM budgets AS budg
    WHERE budg.code = prod.code
);


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

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


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.type = ord.type
);


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

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


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

SELECT id FROM products AS prod
WHERE amount > (
    SELECT MIN(value) FROM budgets AS budg
    WHERE budg.code = prod.code
);


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

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


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

SELECT id FROM schedules AS schd
WHERE code IN (
    SELECT code FROM budgets AS budg
    WHERE budg.level = schd.level
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.status = ord.status
);


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

SELECT name FROM services AS srvc
WHERE type IN (
    SELECT type FROM managers AS mgr
    WHERE mgr.type = srvc.type
);


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

SELECT amount FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = acct.level
);


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

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


Prompt:
Schema:
  warehouses (alias: whs)(code, status, value, name)
  staff(status, value, date, code)
Task: Retrieve salary from warehouses with amount above the MIN(amount) of staff rows sharing the same status.
SQL:

SELECT salary FROM warehouses AS whs
WHERE amount > (
    SELECT MIN(amount) FROM staff AS empl
    WHERE empl.status = whs.status
);


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

SELECT amount FROM budgets AS budg
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.status = budg.status
);


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

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


Prompt:
Schema:
  warehouses (alias: whs)(name, level, salary, value)
  products(id, value, level, salary)
Task: Find salary from warehouses where value exceeds the average value from products for the same type.
SQL:

SELECT salary FROM warehouses AS whs
WHERE value > (
    SELECT SUM(value) FROM products AS prod
    WHERE prod.type = whs.type
);


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

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


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

SELECT amount FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.type = srvc.type
);


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

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


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

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


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

SELECT value FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.code = whs.code
);


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

SELECT id FROM regions AS rgn
WHERE value > (
    SELECT MAX(salary) FROM shipments AS shp
    WHERE shp.code = rgn.code
);


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

SELECT value FROM invoices AS inv
WHERE id IN (
    SELECT id FROM schedules AS schd
    WHERE schd.status = inv.status
);


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

SELECT name FROM staff AS empl
WHERE level IN (
    SELECT level FROM regions AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT code FROM items AS lne
WHERE value > (
    SELECT MAX(amount) FROM orders AS ord
    WHERE ord.type = lne.type
);


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

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


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

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


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

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


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

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


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

SELECT name FROM transactions AS txn
WHERE status IN (
    SELECT status FROM orders AS ord
    WHERE ord.type = txn.type
);


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

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


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

SELECT id FROM categories AS catg
WHERE level IN (
    SELECT level FROM departments AS dept
    WHERE dept.level = catg.level
);


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

SELECT id FROM schedules AS schd
WHERE amount > (
    SELECT AVG(salary) FROM categories AS catg
    WHERE catg.status = schd.status
);


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

SELECT id FROM departments AS dept
WHERE salary > (
    SELECT MIN(amount) FROM staff AS empl
    WHERE empl.type = dept.type
);


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

SELECT value FROM warehouses AS whs
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.level = whs.level
);


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

SELECT name FROM warehouses AS whs
WHERE salary > (
    SELECT SUM(salary) FROM accounts AS acct
    WHERE acct.code = whs.code
);


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

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


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

SELECT value FROM departments AS dept
WHERE id IN (
    SELECT id FROM categories AS catg
    WHERE catg.code = dept.code
);


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

SELECT value FROM orders AS ord
WHERE value > (
    SELECT MAX(salary) FROM budgets AS budg
    WHERE budg.level = ord.level
);


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

SELECT salary FROM employees AS emp
WHERE value > (
    SELECT COUNT(salary) FROM schedules AS schd
    WHERE schd.code = emp.code
);


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

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


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

SELECT code FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.id = ord.id
);


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

SELECT salary FROM customers AS cust
WHERE status IN (
    SELECT status FROM accounts AS acct
    WHERE acct.type = cust.type
);


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

SELECT salary FROM sales AS sale
WHERE status IN (
    SELECT status FROM items AS lne
    WHERE lne.status = sale.status
);


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

SELECT salary FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.code = acct.code
);


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

SELECT value FROM managers AS mgr
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.level = mgr.level
);


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

SELECT code FROM warehouses AS whs
WHERE amount > (
    SELECT COUNT(salary) FROM requests AS ordr
    WHERE ordr.type = whs.type
);


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

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


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

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


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

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


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

SELECT code FROM schedules AS schd
WHERE status IN (
    SELECT status FROM categories AS catg
    WHERE catg.level = schd.level
);


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

SELECT salary FROM accounts AS acct
WHERE level IN (
    SELECT level FROM staff AS empl
    WHERE empl.type = acct.type
);


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

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


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

SELECT salary FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM staff AS empl
    WHERE empl.status = mgr.status
);


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

SELECT id FROM sales AS sale
WHERE value > (
    SELECT MAX(value) FROM transactions AS txn
    WHERE txn.type = sale.type
);


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

SELECT amount FROM shipments AS shp
WHERE salary > (
    SELECT MAX(amount) FROM budgets AS budg
    WHERE budg.level = shp.level
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.type = sale.type
);


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

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


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

SELECT id FROM regions AS rgn
WHERE status IN (
    SELECT status FROM services AS srvc
    WHERE srvc.status = rgn.status
);


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

SELECT value FROM sales AS sale
WHERE amount > (
    SELECT MAX(value) FROM budgets AS budg
    WHERE budg.status = sale.status
);


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

SELECT id FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.level = sale.level
);


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

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


Prompt:
Schema:
  services (alias: srvc)(salary, level, id, amount)
  invoices(code, id, status, amount)
Task: Find salary from services where status appears in invoices entries with matching id.
SQL:

SELECT salary FROM services AS srvc
WHERE status IN (
    SELECT status FROM invoices AS inv
    WHERE inv.id = srvc.id
);


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

SELECT salary FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.type = budg.type
);


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

SELECT id FROM accounts AS acct
WHERE type IN (
    SELECT type FROM shipments AS shp
    WHERE shp.id = acct.id
);


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

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


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

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


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

SELECT id FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.code = srvc.code
);


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

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


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

SELECT id FROM employees AS emp
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.type = emp.type
);


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

SELECT value FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT salary FROM orders AS ord
WHERE amount > (
    SELECT MIN(value) FROM schedules AS schd
    WHERE schd.code = ord.code
);


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

SELECT salary FROM sales AS sale
WHERE level IN (
    SELECT level FROM budgets AS budg
    WHERE budg.type = sale.type
);


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

SELECT salary FROM budgets AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.status = budg.status
);


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

SELECT value FROM services AS srvc
WHERE code IN (
    SELECT code FROM departments AS dept
    WHERE dept.level = srvc.level
);


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

SELECT name FROM requests AS ordr
WHERE salary > (
    SELECT MAX(value) FROM budgets AS budg
    WHERE budg.id = ordr.id
);


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

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


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

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


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

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


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

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


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

SELECT name FROM sales AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM managers AS mgr
    WHERE mgr.id = sale.id
);


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

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


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

SELECT amount FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS rgn
    WHERE rgn.status = srvc.status
);


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

SELECT salary FROM accounts AS acct
WHERE level IN (
    SELECT level FROM shipments AS shp
    WHERE shp.code = acct.code
);


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

SELECT salary FROM items AS lne
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS whs
    WHERE whs.id = lne.id
);


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

SELECT code FROM regions AS rgn
WHERE value > (
    SELECT MAX(salary) FROM budgets AS budg
    WHERE budg.code = rgn.code
);


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

SELECT name FROM departments AS dept
WHERE id IN (
    SELECT id FROM employees AS emp
    WHERE emp.level = dept.level
);


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

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


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

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


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

SELECT name FROM regions AS rgn
WHERE level IN (
    SELECT level FROM orders AS ord
    WHERE ord.level = rgn.level
);


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

SELECT salary FROM invoices AS inv
WHERE value > (
    SELECT SUM(amount) FROM transactions AS txn
    WHERE txn.level = inv.level
);


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

SELECT name FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.type = schd.type
);


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

SELECT id FROM items AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS ord
    WHERE ord.status = lne.status
);


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

SELECT id FROM employees AS emp
WHERE salary > (
    SELECT MIN(value) FROM accounts AS acct
    WHERE acct.status = emp.status
);


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

SELECT amount FROM schedules AS schd
WHERE value > (
    SELECT SUM(amount) FROM regions AS rgn
    WHERE rgn.type = schd.type
);


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

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


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

SELECT amount FROM customers AS cust
WHERE id IN (
    SELECT id FROM items AS lne
    WHERE lne.level = cust.level
);


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

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


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

SELECT code FROM schedules AS schd
WHERE salary > (
    SELECT MAX(amount) FROM invoices AS inv
    WHERE inv.id = schd.id
);


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

SELECT value FROM budgets AS budg
WHERE amount > (
    SELECT SUM(value) FROM customers AS cust
    WHERE cust.level = budg.level
);


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

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


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

SELECT code FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.code = srvc.code
);


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

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


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

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


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

SELECT amount FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM managers AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT id FROM employees AS emp
WHERE id IN (
    SELECT id FROM services AS srvc
    WHERE srvc.id = emp.id
);


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

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


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

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


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

SELECT name FROM warehouses AS whs
WHERE salary > (
    SELECT SUM(amount) FROM regions AS rgn
    WHERE rgn.id = whs.id
);


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

SELECT id FROM warehouses AS whs
WHERE salary > (
    SELECT MAX(amount) FROM categories AS catg
    WHERE catg.code = whs.code
);


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

SELECT name FROM invoices AS inv
WHERE amount > (
    SELECT AVG(value) FROM budgets AS budg
    WHERE budg.level = inv.level
);


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

SELECT code FROM budgets AS budg
WHERE salary > (
    SELECT COUNT(value) FROM requests AS ordr
    WHERE ordr.status = budg.status
);


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

SELECT code FROM staff AS empl
WHERE type IN (
    SELECT type FROM departments AS dept
    WHERE dept.status = empl.status
);


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

SELECT salary FROM items AS lne
WHERE EXISTS (
    SELECT 1 FROM budgets AS budg
    WHERE budg.level = lne.level
);


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

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


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

SELECT amount FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.status = ordr.status
);


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

SELECT id FROM managers AS mgr
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.level = mgr.level
);


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

SELECT amount FROM managers AS mgr
WHERE id IN (
    SELECT id FROM schedules AS schd
    WHERE schd.type = mgr.type
);


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

SELECT value FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = srvc.code
);


Prompt:
Schema:
  managers (alias: mgr)(status, code, date, salary)
  invoices(level, code, status, type)
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 inv
    WHERE inv.level = mgr.level
);


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

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


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

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


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

SELECT amount FROM orders AS ord
WHERE level IN (
    SELECT level FROM transactions AS txn
    WHERE txn.status = ord.status
);


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

SELECT id FROM sales AS sale
WHERE code IN (
    SELECT code FROM services AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT amount FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT code FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.type = srvc.type
);


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

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


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

SELECT amount FROM items AS lne
WHERE salary > (
    SELECT MAX(salary) FROM services AS srvc
    WHERE srvc.type = lne.type
);


Prompt:
Schema:
  services (alias: srvc)(amount, salary, status, code)
  managers(amount, code, status, date)
Task: Retrieve code from services with salary above the COUNT(amount) of managers rows sharing the same code.
SQL:

SELECT code FROM services AS srvc
WHERE salary > (
    SELECT COUNT(amount) FROM managers AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT salary FROM employees AS emp
WHERE salary > (
    SELECT MAX(value) FROM items AS lne
    WHERE lne.type = emp.type
);


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

SELECT value FROM regions AS rgn
WHERE status IN (
    SELECT status FROM orders AS ord
    WHERE ord.status = rgn.status
);


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

SELECT amount FROM budgets AS budg
WHERE level IN (
    SELECT level FROM managers AS mgr
    WHERE mgr.status = budg.status
);


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

SELECT value FROM categories AS catg
WHERE EXISTS (
    SELECT 1 FROM items AS lne
    WHERE lne.status = catg.status
);


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

SELECT value FROM warehouses AS whs
WHERE id IN (
    SELECT id FROM staff AS empl
    WHERE empl.status = whs.status
);


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

SELECT id FROM warehouses AS whs
WHERE code IN (
    SELECT code FROM employees AS emp
    WHERE emp.level = whs.level
);


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

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


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

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


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

SELECT amount FROM budgets AS budg
WHERE type IN (
    SELECT type FROM services AS srvc
    WHERE srvc.code = budg.code
);


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

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


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

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


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

SELECT salary FROM services AS srvc
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = srvc.type
);


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

SELECT amount FROM items AS lne
WHERE amount > (
    SELECT MAX(amount) FROM customers AS cust
    WHERE cust.level = lne.level
);


Prompt:
Schema:
  services (alias: srvc)(code, amount, date, name)
  schedules(status, code, type, amount)
Task: Find salary from services where amount exceeds the average value from schedules for the same type.
SQL:

SELECT salary FROM services AS srvc
WHERE amount > (
    SELECT MAX(value) FROM schedules AS schd
    WHERE schd.type = srvc.type
);


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

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


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

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


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

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


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

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


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

SELECT name FROM customers AS cust
WHERE level IN (
    SELECT level FROM staff AS empl
    WHERE empl.id = cust.id
);


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

SELECT value FROM managers AS mgr
WHERE id IN (
    SELECT id FROM accounts AS acct
    WHERE acct.id = mgr.id
);


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

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


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

SELECT salary FROM services AS srvc
WHERE code IN (
    SELECT code FROM regions AS rgn
    WHERE rgn.status = srvc.status
);


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

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


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

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


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

SELECT value FROM managers AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.code = mgr.code
);


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

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


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

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


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

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


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

SELECT salary FROM customers AS cust
WHERE amount > (
    SELECT MIN(value) FROM services AS srvc
    WHERE srvc.id = cust.id
);


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

SELECT code FROM accounts AS acct
WHERE amount > (
    SELECT SUM(value) FROM requests AS ordr
    WHERE ordr.level = acct.level
);


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

SELECT amount FROM employees AS emp
WHERE salary > (
    SELECT COUNT(salary) FROM shipments AS shp
    WHERE shp.id = emp.id
);


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

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


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

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


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

SELECT salary FROM items AS lne
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.code = lne.code
);


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

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


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

SELECT value FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM invoices AS inv
    WHERE inv.code = whs.code
);


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

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


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

SELECT id FROM staff AS empl
WHERE amount > (
    SELECT COUNT(value) FROM requests AS ordr
    WHERE ordr.level = empl.level
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = sale.id
);


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

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


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

SELECT id FROM accounts AS acct
WHERE EXISTS (
    SELECT 1 FROM requests AS ordr
    WHERE ordr.status = acct.status
);


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

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


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

SELECT value FROM requests AS ordr
WHERE value > (
    SELECT AVG(salary) FROM managers AS mgr
    WHERE mgr.status = ordr.status
);


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

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


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

SELECT value FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.type = inv.type
);


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

SELECT value FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM services AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT salary FROM sales AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.status = sale.status
);


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

SELECT salary FROM managers AS mgr
WHERE status IN (
    SELECT status FROM categories AS catg
    WHERE catg.code = mgr.code
);


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

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


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

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


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

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


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

SELECT id FROM accounts AS acct
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.id = acct.id
);


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

SELECT value FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.level = dept.level
);


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

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


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

SELECT amount FROM items AS lne
WHERE value > (
    SELECT MIN(amount) FROM accounts AS acct
    WHERE acct.type = lne.type
);


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

SELECT name FROM staff AS empl
WHERE level IN (
    SELECT level FROM services AS srvc
    WHERE srvc.code = empl.code
);


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

SELECT name FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM schedules AS schd
    WHERE schd.code = cust.code
);


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

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


Prompt:
Schema:
  warehouses (alias: whs)(amount, id, status, date)
  transactions(date, amount, code, value)
Task: Retrieve value from warehouses with amount above the MAX(amount) of transactions rows sharing the same status.
SQL:

SELECT value FROM warehouses AS whs
WHERE amount > (
    SELECT MAX(amount) FROM transactions AS txn
    WHERE txn.status = whs.status
);


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

SELECT value FROM managers AS mgr
WHERE level IN (
    SELECT level FROM schedules AS schd
    WHERE schd.status = mgr.status
);


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

SELECT code FROM requests AS ordr
WHERE level IN (
    SELECT level FROM budgets AS budg
    WHERE budg.type = ordr.type
);


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

SELECT value FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = prod.id
);


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

SELECT name FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = emp.level
);


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

SELECT code FROM products AS prod
WHERE amount > (
    SELECT AVG(amount) FROM transactions AS txn
    WHERE txn.level = prod.level
);


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

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


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

SELECT id FROM budgets AS budg
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS txn
    WHERE txn.type = budg.type
);


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

SELECT code FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.type = inv.type
);


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

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


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

SELECT code FROM budgets AS budg
WHERE level IN (
    SELECT level FROM products AS prod
    WHERE prod.id = budg.id
);


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

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


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

SELECT name FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.id = ordr.id
);


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

SELECT value FROM accounts AS acct
WHERE status IN (
    SELECT status FROM transactions AS txn
    WHERE txn.code = acct.code
);


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

SELECT name FROM sales AS sale
WHERE level IN (
    SELECT level FROM services AS srvc
    WHERE srvc.code = sale.code
);


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

SELECT amount FROM regions AS rgn
WHERE status IN (
    SELECT status FROM schedules AS schd
    WHERE schd.status = rgn.status
);


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

SELECT code FROM customers AS cust
WHERE id IN (
    SELECT id FROM products AS prod
    WHERE prod.id = cust.id
);


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

SELECT id FROM requests AS ordr
WHERE EXISTS (
    SELECT 1 FROM accounts AS acct
    WHERE acct.status = ordr.status
);


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

SELECT code FROM schedules AS schd
WHERE EXISTS (
    SELECT 1 FROM sales AS sale
    WHERE sale.id = schd.id
);


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

SELECT code FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.id = whs.id
);