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

SELECT salary FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.type = inv.type
);


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

SELECT name FROM warehouses AS cust
WHERE amount > (
    SELECT AVG(amount) FROM tasks AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT value FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.type = cust.type
);


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

SELECT id FROM suppliers AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM products AS empl
    WHERE empl.level = srvc.level
);


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

SELECT amount FROM orders AS catg
WHERE salary > (
    SELECT COUNT(salary) FROM warehouses AS budg
    WHERE budg.type = catg.type
);


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

SELECT name FROM employees AS schd
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS shp
    WHERE shp.level = schd.level
);


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

SELECT salary FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS schd
    WHERE schd.status = whs.status
);


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

SELECT id FROM branches AS budg
WHERE type IN (
    SELECT type FROM products AS shp
    WHERE shp.code = budg.code
);


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

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


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

SELECT amount FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.level = sale.level
);


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

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


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

SELECT id FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS catg
    WHERE catg.status = budg.status
);


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

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


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

SELECT amount FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM categories AS srvc
    WHERE srvc.level = ord.level
);


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

SELECT id FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.level = mgr.level
);


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

SELECT code FROM products AS inv
WHERE value > (
    SELECT SUM(salary) FROM suppliers AS lne
    WHERE lne.id = inv.id
);


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

SELECT value FROM projects AS txn
WHERE salary > (
    SELECT COUNT(value) FROM categories AS sale
    WHERE sale.id = txn.id
);


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

SELECT name FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.status = srvc.status
);


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

SELECT salary FROM customers AS catg
WHERE value > (
    SELECT SUM(value) FROM orders AS whs
    WHERE whs.type = catg.type
);


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

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


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

SELECT salary FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM categories AS catg
    WHERE catg.id = sale.id
);


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

SELECT amount FROM orders AS prod
WHERE amount > (
    SELECT SUM(value) FROM employees AS whs
    WHERE whs.id = prod.id
);


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

SELECT name FROM categories AS empl
WHERE code IN (
    SELECT code FROM suppliers AS schd
    WHERE schd.type = empl.type
);


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

SELECT name FROM products AS catg
WHERE id IN (
    SELECT id FROM customers AS lne
    WHERE lne.type = catg.type
);


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

SELECT value FROM accounts AS srvc
WHERE status IN (
    SELECT status FROM regions AS budg
    WHERE budg.code = srvc.code
);


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

SELECT name FROM tasks AS ord
WHERE type IN (
    SELECT type FROM projects AS emp
    WHERE emp.code = ord.code
);


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

SELECT salary FROM tasks AS dept
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS txn
    WHERE txn.id = dept.id
);


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

SELECT name FROM departments AS ord
WHERE code IN (
    SELECT code FROM suppliers AS rgn
    WHERE rgn.status = ord.status
);


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

SELECT id FROM invoices AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.status = srvc.status
);


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

SELECT id FROM customers AS schd
WHERE value > (
    SELECT COUNT(salary) FROM categories AS lne
    WHERE lne.status = schd.status
);


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

SELECT code FROM accounts AS lne
WHERE amount > (
    SELECT SUM(salary) FROM warehouses AS mgr
    WHERE mgr.id = lne.id
);


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

SELECT name FROM accounts AS prod
WHERE status IN (
    SELECT status FROM invoices AS schd
    WHERE schd.code = prod.code
);


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

SELECT salary FROM invoices AS shp
WHERE id IN (
    SELECT id FROM branches AS empl
    WHERE empl.status = shp.status
);


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

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


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

SELECT id FROM regions AS empl
WHERE type IN (
    SELECT type FROM departments AS prod
    WHERE prod.type = empl.type
);


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

SELECT name FROM regions AS catg
WHERE value > (
    SELECT MIN(value) FROM employees AS emp
    WHERE emp.type = catg.type
);


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

SELECT value FROM invoices AS emp
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.type = emp.type
);


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

SELECT value FROM projects AS budg
WHERE amount > (
    SELECT COUNT(salary) FROM customers AS whs
    WHERE whs.status = budg.status
);


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

SELECT code FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.type = cust.type
);


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

SELECT amount FROM invoices AS acct
WHERE code IN (
    SELECT code FROM projects AS budg
    WHERE budg.id = acct.id
);


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

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


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.status = ord.status
);


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

SELECT name FROM suppliers AS acct
WHERE salary > (
    SELECT AVG(value) FROM accounts AS dept
    WHERE dept.code = acct.code
);


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

SELECT code FROM accounts AS dept
WHERE code IN (
    SELECT code FROM products AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT salary FROM projects AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS mgr
    WHERE mgr.status = whs.status
);


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

SELECT code FROM warehouses AS inv
WHERE status IN (
    SELECT status FROM employees AS empl
    WHERE empl.code = inv.code
);


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

SELECT amount FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS shp
    WHERE shp.id = cust.id
);


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

SELECT id FROM shipments AS whs
WHERE id IN (
    SELECT id FROM regions AS schd
    WHERE schd.id = whs.id
);


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

SELECT value FROM customers AS ord
WHERE value > (
    SELECT COUNT(salary) FROM products AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT amount FROM projects AS catg
WHERE value > (
    SELECT MAX(salary) FROM orders AS dept
    WHERE dept.status = catg.status
);


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

SELECT salary FROM invoices AS empl
WHERE salary > (
    SELECT AVG(value) FROM shipments AS cust
    WHERE cust.id = empl.id
);


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

SELECT amount FROM products AS mgr
WHERE value > (
    SELECT AVG(value) FROM accounts AS catg
    WHERE catg.code = mgr.code
);


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

SELECT id FROM suppliers AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.type = whs.type
);


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

SELECT name FROM customers AS whs
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS cust
    WHERE cust.status = whs.status
);


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

SELECT name FROM customers AS cust
WHERE type IN (
    SELECT type FROM transactions AS ordr
    WHERE ordr.type = cust.type
);


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

SELECT id FROM shipments AS srvc
WHERE status IN (
    SELECT status FROM orders AS schd
    WHERE schd.code = srvc.code
);


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

SELECT name FROM invoices AS srvc
WHERE code IN (
    SELECT code FROM suppliers AS emp
    WHERE emp.code = srvc.code
);


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

SELECT salary FROM invoices AS acct
WHERE level IN (
    SELECT level FROM departments AS srvc
    WHERE srvc.code = acct.code
);


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

SELECT salary FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.status = lne.status
);


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

SELECT code FROM invoices AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM accounts AS acct
    WHERE acct.level = rgn.level
);


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

SELECT name FROM regions AS shp
WHERE salary > (
    SELECT MIN(salary) FROM employees AS empl
    WHERE empl.type = shp.type
);


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

SELECT amount FROM suppliers AS inv
WHERE value > (
    SELECT COUNT(value) FROM warehouses AS schd
    WHERE schd.id = inv.id
);


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

SELECT amount FROM products AS ord
WHERE status IN (
    SELECT status FROM regions AS catg
    WHERE catg.status = ord.status
);


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

SELECT id FROM accounts AS empl
WHERE salary > (
    SELECT COUNT(value) FROM branches AS sale
    WHERE sale.code = empl.code
);


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

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


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

SELECT code FROM branches AS inv
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS budg
    WHERE budg.id = inv.id
);


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

SELECT id FROM categories AS catg
WHERE amount > (
    SELECT SUM(amount) FROM employees AS inv
    WHERE inv.status = catg.status
);


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

SELECT amount FROM categories AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.type = sale.type
);


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

SELECT id FROM employees AS inv
WHERE status IN (
    SELECT status FROM orders AS whs
    WHERE whs.code = inv.code
);


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

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


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

SELECT code FROM warehouses AS budg
WHERE value > (
    SELECT MIN(salary) FROM employees AS empl
    WHERE empl.type = budg.type
);


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

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


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

SELECT value FROM accounts AS srvc
WHERE type IN (
    SELECT type FROM employees AS schd
    WHERE schd.level = srvc.level
);


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

SELECT salary FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = budg.id
);


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

SELECT id FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = schd.type
);


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

SELECT amount FROM categories AS mgr
WHERE status IN (
    SELECT status FROM transactions AS srvc
    WHERE srvc.id = mgr.id
);


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

SELECT salary FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM products AS lne
    WHERE lne.level = schd.level
);


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

SELECT salary FROM tasks AS schd
WHERE status IN (
    SELECT status FROM suppliers AS lne
    WHERE lne.code = schd.code
);


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

SELECT code FROM departments AS srvc
WHERE salary > (
    SELECT COUNT(value) FROM products AS cust
    WHERE cust.status = srvc.status
);


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

SELECT value FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.status = txn.status
);


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

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


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

SELECT code FROM branches AS emp
WHERE EXISTS (
    SELECT 1 FROM invoices AS rgn
    WHERE rgn.code = emp.code
);


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

SELECT id FROM warehouses AS prod
WHERE amount > (
    SELECT SUM(amount) FROM customers AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT code FROM employees AS acct
WHERE status IN (
    SELECT status FROM suppliers AS budg
    WHERE budg.type = acct.type
);


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

SELECT name FROM suppliers AS cust
WHERE value > (
    SELECT AVG(amount) FROM accounts AS whs
    WHERE whs.id = cust.id
);


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

SELECT value FROM customers AS sale
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.status = sale.status
);


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

SELECT value FROM orders AS cust
WHERE level IN (
    SELECT level FROM projects AS schd
    WHERE schd.status = cust.status
);


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

SELECT value FROM categories AS cust
WHERE value > (
    SELECT COUNT(value) FROM suppliers AS lne
    WHERE lne.status = cust.status
);


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

SELECT id FROM invoices AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS mgr
    WHERE mgr.code = ordr.code
);


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

SELECT code FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.status = inv.status
);


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

SELECT salary FROM employees AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM categories AS catg
    WHERE catg.level = mgr.level
);


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

SELECT code FROM shipments AS sale
WHERE salary > (
    SELECT SUM(value) FROM projects AS prod
    WHERE prod.id = sale.id
);


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

SELECT value FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM accounts AS txn
    WHERE txn.code = inv.code
);


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

SELECT value FROM branches AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM warehouses AS ordr
    WHERE ordr.id = mgr.id
);


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

SELECT value FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS sale
    WHERE sale.id = schd.id
);


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

SELECT id FROM orders AS sale
WHERE salary > (
    SELECT MAX(value) FROM projects AS dept
    WHERE dept.id = sale.id
);


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

SELECT code FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.level = mgr.level
);


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

SELECT amount FROM products AS lne
WHERE status IN (
    SELECT status FROM warehouses AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT code FROM invoices AS ord
WHERE status IN (
    SELECT status FROM branches AS shp
    WHERE shp.level = ord.level
);


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

SELECT name FROM regions AS txn
WHERE level IN (
    SELECT level FROM transactions AS prod
    WHERE prod.status = txn.status
);


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

SELECT value FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS dept
    WHERE dept.level = sale.level
);


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

SELECT name FROM accounts AS budg
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS catg
    WHERE catg.id = budg.id
);


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

SELECT amount FROM tasks AS shp
WHERE id IN (
    SELECT id FROM branches AS inv
    WHERE inv.code = shp.code
);


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

SELECT id FROM regions AS inv
WHERE status IN (
    SELECT status FROM orders AS ordr
    WHERE ordr.status = inv.status
);


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

SELECT value FROM suppliers AS rgn
WHERE value > (
    SELECT MAX(salary) FROM tasks AS empl
    WHERE empl.id = rgn.id
);


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

SELECT id FROM products AS srvc
WHERE type IN (
    SELECT type FROM employees AS whs
    WHERE whs.code = srvc.code
);


Prompt:
Schema:
  suppliers (alias: prod)(name, salary, value, type)
  regions(date, id, type, value)
Task: Retrieve salary from suppliers with salary above the AVG(salary) of regions rows sharing the same id.
SQL:

SELECT salary FROM suppliers AS prod
WHERE salary > (
    SELECT AVG(salary) FROM regions AS mgr
    WHERE mgr.id = prod.id
);


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

SELECT id FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.type = acct.type
);


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

SELECT id FROM regions AS ordr
WHERE value > (
    SELECT COUNT(salary) FROM warehouses AS catg
    WHERE catg.code = ordr.code
);


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

SELECT code FROM transactions AS dept
WHERE status IN (
    SELECT status FROM regions AS sale
    WHERE sale.status = dept.status
);


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

SELECT name FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.code = rgn.code
);


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

SELECT name FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.code = txn.code
);


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

SELECT amount FROM customers AS whs
WHERE id IN (
    SELECT id FROM suppliers AS rgn
    WHERE rgn.level = whs.level
);


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

SELECT name FROM invoices AS rgn
WHERE status IN (
    SELECT status FROM categories AS sale
    WHERE sale.type = rgn.type
);


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

SELECT salary FROM accounts AS mgr
WHERE code IN (
    SELECT code FROM employees AS prod
    WHERE prod.status = mgr.status
);


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

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


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

SELECT code FROM branches AS whs
WHERE level IN (
    SELECT level FROM transactions AS acct
    WHERE acct.id = whs.id
);


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

SELECT value FROM branches AS ordr
WHERE type IN (
    SELECT type FROM employees AS inv
    WHERE inv.level = ordr.level
);


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

SELECT salary FROM categories AS whs
WHERE salary > (
    SELECT AVG(amount) FROM shipments AS sale
    WHERE sale.id = whs.id
);


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

SELECT value FROM suppliers AS catg
WHERE code IN (
    SELECT code FROM projects AS shp
    WHERE shp.id = catg.id
);


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

SELECT salary FROM invoices AS acct
WHERE salary > (
    SELECT MAX(salary) FROM suppliers AS sale
    WHERE sale.id = acct.id
);


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

SELECT salary FROM employees AS empl
WHERE id IN (
    SELECT id FROM shipments AS cust
    WHERE cust.id = empl.id
);


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

SELECT amount FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.status = ord.status
);


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

SELECT value FROM regions AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.code = lne.code
);


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

SELECT code FROM regions AS shp
WHERE code IN (
    SELECT code FROM warehouses AS txn
    WHERE txn.status = shp.status
);


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

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


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

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


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

SELECT salary FROM orders AS whs
WHERE code IN (
    SELECT code FROM regions AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT amount FROM accounts AS emp
WHERE amount > (
    SELECT MIN(salary) FROM branches AS rgn
    WHERE rgn.level = emp.level
);


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

SELECT name FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT code FROM regions AS sale
WHERE EXISTS (
    SELECT 1 FROM employees AS acct
    WHERE acct.status = sale.status
);


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

SELECT code FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.type = prod.type
);


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

SELECT id FROM orders AS emp
WHERE amount > (
    SELECT COUNT(value) FROM warehouses AS budg
    WHERE budg.code = emp.code
);


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

SELECT code FROM transactions AS acct
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS budg
    WHERE budg.level = acct.level
);


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

SELECT name FROM regions AS txn
WHERE status IN (
    SELECT status FROM projects AS emp
    WHERE emp.code = txn.code
);


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

SELECT amount FROM customers AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS acct
    WHERE acct.code = sale.code
);


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

SELECT amount FROM regions AS emp
WHERE salary > (
    SELECT MAX(value) FROM shipments AS prod
    WHERE prod.id = emp.id
);


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

SELECT name FROM warehouses AS prod
WHERE status IN (
    SELECT status FROM orders AS inv
    WHERE inv.level = prod.level
);


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

SELECT name FROM categories AS dept
WHERE type IN (
    SELECT type FROM warehouses AS budg
    WHERE budg.id = dept.id
);


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

SELECT value FROM employees AS cust
WHERE value > (
    SELECT MIN(value) FROM projects AS srvc
    WHERE srvc.type = cust.type
);


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

SELECT value FROM shipments AS ordr
WHERE EXISTS (
    SELECT 1 FROM tasks AS shp
    WHERE shp.status = ordr.status
);


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

SELECT salary FROM employees AS lne
WHERE status IN (
    SELECT status FROM departments AS ordr
    WHERE ordr.level = lne.level
);


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

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


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

SELECT amount FROM departments AS dept
WHERE id IN (
    SELECT id FROM warehouses AS inv
    WHERE inv.status = dept.status
);


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

SELECT name FROM customers AS prod
WHERE salary > (
    SELECT AVG(amount) FROM branches AS dept
    WHERE dept.code = prod.code
);


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

SELECT value FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.id = whs.id
);


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

SELECT name FROM tasks AS mgr
WHERE value > (
    SELECT MAX(amount) FROM invoices AS empl
    WHERE empl.code = mgr.code
);


Prompt:
Schema:
  products (alias: schd)(status, value, code, salary)
  suppliers(value, salary, type, amount)
Task: Find value from products where amount exceeds the average value from suppliers for the same level.
SQL:

SELECT value FROM products AS schd
WHERE amount > (
    SELECT AVG(value) FROM suppliers AS sale
    WHERE sale.level = schd.level
);


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

SELECT amount FROM departments AS schd
WHERE level IN (
    SELECT level FROM regions AS sale
    WHERE sale.status = schd.status
);


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

SELECT amount FROM employees AS sale
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.type = sale.type
);


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

SELECT id FROM projects AS schd
WHERE level IN (
    SELECT level FROM invoices AS sale
    WHERE sale.code = schd.code
);


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

SELECT value FROM invoices AS mgr
WHERE status IN (
    SELECT status FROM tasks AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT name FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS budg
    WHERE budg.status = acct.status
);


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

SELECT value FROM categories AS srvc
WHERE EXISTS (
    SELECT 1 FROM invoices AS dept
    WHERE dept.id = srvc.id
);


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

SELECT code FROM transactions AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.status = srvc.status
);


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

SELECT name FROM branches AS acct
WHERE amount > (
    SELECT MIN(salary) FROM employees AS emp
    WHERE emp.type = acct.type
);


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

SELECT salary FROM invoices AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.level = prod.level
);


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

SELECT name FROM shipments AS cust
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS mgr
    WHERE mgr.code = cust.code
);


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

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


Prompt:
Schema:
  branches (alias: schd)(name, level, amount, date)
  products(code, name, amount, status)
Task: Retrieve code from branches with amount above the MIN(salary) of products rows sharing the same level.
SQL:

SELECT code FROM branches AS schd
WHERE amount > (
    SELECT MIN(salary) FROM products AS sale
    WHERE sale.level = schd.level
);


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

SELECT name FROM tasks AS ord
WHERE level IN (
    SELECT level FROM employees AS catg
    WHERE catg.type = ord.type
);


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

SELECT salary FROM orders AS lne
WHERE level IN (
    SELECT level FROM suppliers AS dept
    WHERE dept.level = lne.level
);


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

SELECT code FROM invoices AS emp
WHERE id IN (
    SELECT id FROM tasks AS empl
    WHERE empl.code = emp.code
);


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

SELECT code FROM employees AS lne
WHERE value > (
    SELECT MAX(value) FROM transactions AS cust
    WHERE cust.id = lne.id
);


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

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


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

SELECT salary FROM customers AS ordr
WHERE salary > (
    SELECT SUM(salary) FROM departments AS inv
    WHERE inv.status = ordr.status
);


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

SELECT name FROM warehouses AS dept
WHERE status IN (
    SELECT status FROM projects AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT amount FROM warehouses AS txn
WHERE salary > (
    SELECT MIN(amount) FROM employees AS budg
    WHERE budg.type = txn.type
);


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

SELECT amount FROM categories AS empl
WHERE code IN (
    SELECT code FROM departments AS ordr
    WHERE ordr.code = empl.code
);


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

SELECT salary FROM customers AS txn
WHERE type IN (
    SELECT type FROM orders AS lne
    WHERE lne.type = txn.type
);


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

SELECT id FROM orders AS schd
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS inv
    WHERE inv.status = schd.status
);


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

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


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

SELECT name FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM employees AS rgn
    WHERE rgn.level = prod.level
);


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

SELECT name FROM accounts AS prod
WHERE id IN (
    SELECT id FROM orders AS inv
    WHERE inv.status = prod.status
);


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

SELECT value FROM customers AS inv
WHERE salary > (
    SELECT AVG(salary) FROM products AS ord
    WHERE ord.id = inv.id
);


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

SELECT name FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS whs
    WHERE whs.type = budg.type
);


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

SELECT amount FROM employees AS srvc
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS schd
    WHERE schd.level = srvc.level
);


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

SELECT value FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.status = ord.status
);


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

SELECT salary FROM shipments AS rgn
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS cust
    WHERE cust.level = rgn.level
);


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

SELECT name FROM shipments AS ordr
WHERE type IN (
    SELECT type FROM departments AS txn
    WHERE txn.level = ordr.level
);


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

SELECT code FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.level = cust.level
);


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

SELECT salary FROM accounts AS rgn
WHERE id IN (
    SELECT id FROM tasks AS whs
    WHERE whs.id = rgn.id
);


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

SELECT code FROM tasks AS rgn
WHERE code IN (
    SELECT code FROM branches AS budg
    WHERE budg.type = rgn.type
);


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

SELECT value FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.type = empl.type
);


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

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


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

SELECT salary FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.level = whs.level
);


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

SELECT salary FROM customers AS prod
WHERE code IN (
    SELECT code FROM warehouses AS shp
    WHERE shp.id = prod.id
);


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

SELECT value FROM invoices AS empl
WHERE level IN (
    SELECT level FROM employees AS budg
    WHERE budg.type = empl.type
);


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

SELECT name FROM orders AS budg
WHERE type IN (
    SELECT type FROM branches AS sale
    WHERE sale.code = budg.code
);


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

SELECT value FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.level = prod.level
);


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

SELECT code FROM projects AS srvc
WHERE value > (
    SELECT AVG(amount) FROM categories AS dept
    WHERE dept.level = srvc.level
);


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

SELECT code FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.code = ordr.code
);


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

SELECT amount FROM tasks AS schd
WHERE salary > (
    SELECT MIN(value) FROM regions AS lne
    WHERE lne.level = schd.level
);


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

SELECT id FROM shipments AS rgn
WHERE code IN (
    SELECT code FROM tasks AS txn
    WHERE txn.status = rgn.status
);


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

SELECT salary FROM regions AS dept
WHERE id IN (
    SELECT id FROM shipments AS mgr
    WHERE mgr.status = dept.status
);


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

SELECT code FROM categories AS sale
WHERE amount > (
    SELECT MAX(amount) FROM regions AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT value FROM customers AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.level = whs.level
);


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

SELECT id FROM projects AS rgn
WHERE amount > (
    SELECT SUM(salary) FROM suppliers AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT code FROM regions AS dept
WHERE code IN (
    SELECT code FROM branches AS ordr
    WHERE ordr.code = dept.code
);


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

SELECT id FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.code = dept.code
);


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

SELECT value FROM suppliers AS ordr
WHERE type IN (
    SELECT type FROM employees AS shp
    WHERE shp.status = ordr.status
);


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

SELECT amount FROM categories AS txn
WHERE amount > (
    SELECT SUM(amount) FROM transactions AS catg
    WHERE catg.status = txn.status
);


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

SELECT amount FROM suppliers AS mgr
WHERE salary > (
    SELECT MAX(amount) FROM regions AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT salary FROM suppliers AS budg
WHERE value > (
    SELECT AVG(value) FROM orders AS schd
    WHERE schd.status = budg.status
);


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

SELECT value FROM invoices AS empl
WHERE level IN (
    SELECT level FROM employees AS shp
    WHERE shp.id = empl.id
);


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

SELECT code FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS shp
    WHERE shp.level = mgr.level
);


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

SELECT id FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS acct
    WHERE acct.status = ord.status
);


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

SELECT value FROM branches AS txn
WHERE amount > (
    SELECT SUM(amount) FROM products AS inv
    WHERE inv.code = txn.code
);


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

SELECT name FROM transactions AS lne
WHERE status IN (
    SELECT status FROM categories AS sale
    WHERE sale.level = lne.level
);


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

SELECT name FROM regions AS whs
WHERE salary > (
    SELECT SUM(value) FROM employees AS schd
    WHERE schd.type = whs.type
);


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

SELECT amount FROM categories AS whs
WHERE code IN (
    SELECT code FROM projects AS rgn
    WHERE rgn.type = whs.type
);


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

SELECT salary FROM invoices AS dept
WHERE value > (
    SELECT MIN(value) FROM categories AS cust
    WHERE cust.status = dept.status
);


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

SELECT code FROM suppliers AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS lne
    WHERE lne.code = inv.code
);


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

SELECT id FROM accounts AS lne
WHERE value > (
    SELECT COUNT(salary) FROM tasks AS prod
    WHERE prod.code = lne.code
);


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

SELECT amount FROM invoices AS whs
WHERE amount > (
    SELECT COUNT(amount) FROM warehouses AS cust
    WHERE cust.status = whs.status
);


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

SELECT id FROM categories AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.id = prod.id
);


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

SELECT code FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.id = empl.id
);


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

SELECT name FROM employees AS whs
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS ordr
    WHERE ordr.id = whs.id
);


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

SELECT id FROM branches AS rgn
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.level = rgn.level
);


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

SELECT value FROM tasks AS catg
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.type = catg.type
);


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

SELECT value FROM shipments AS catg
WHERE salary > (
    SELECT MAX(amount) FROM customers AS lne
    WHERE lne.id = catg.id
);


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

SELECT code FROM regions AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.level = ordr.level
);


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

SELECT salary FROM accounts AS cust
WHERE type IN (
    SELECT type FROM products AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT amount FROM employees AS shp
WHERE value > (
    SELECT SUM(amount) FROM branches AS srvc
    WHERE srvc.code = shp.code
);


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

SELECT amount FROM customers AS empl
WHERE level IN (
    SELECT level FROM tasks AS rgn
    WHERE rgn.type = empl.type
);


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

SELECT salary FROM tasks AS ordr
WHERE id IN (
    SELECT id FROM products AS shp
    WHERE shp.id = ordr.id
);


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

SELECT salary FROM projects AS lne
WHERE type IN (
    SELECT type FROM tasks AS srvc
    WHERE srvc.level = lne.level
);


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

SELECT code FROM warehouses AS sale
WHERE code IN (
    SELECT code FROM categories AS txn
    WHERE txn.level = sale.level
);


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

SELECT salary FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS empl
    WHERE empl.code = budg.code
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM warehouses AS whs
    WHERE whs.status = inv.status
);


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

SELECT code FROM categories AS ord
WHERE id IN (
    SELECT id FROM transactions AS shp
    WHERE shp.code = ord.code
);


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

SELECT amount FROM branches AS ord
WHERE id IN (
    SELECT id FROM accounts AS dept
    WHERE dept.id = ord.id
);


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

SELECT code FROM accounts AS srvc
WHERE amount > (
    SELECT AVG(value) FROM branches AS cust
    WHERE cust.level = srvc.level
);


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

SELECT name FROM projects AS acct
WHERE salary > (
    SELECT AVG(value) FROM products AS txn
    WHERE txn.type = acct.type
);


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

SELECT id FROM suppliers AS inv
WHERE level IN (
    SELECT level FROM accounts AS empl
    WHERE empl.level = inv.level
);


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

SELECT name FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.code = srvc.code
);


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

SELECT value FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS schd
    WHERE schd.status = cust.status
);


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

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


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

SELECT value FROM departments AS cust
WHERE salary > (
    SELECT SUM(amount) FROM projects AS acct
    WHERE acct.level = cust.level
);


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

SELECT salary FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM accounts AS whs
    WHERE whs.id = mgr.id
);


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

SELECT amount FROM invoices AS emp
WHERE value > (
    SELECT SUM(salary) FROM categories AS schd
    WHERE schd.code = emp.code
);


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

SELECT salary FROM customers AS srvc
WHERE status IN (
    SELECT status FROM categories AS inv
    WHERE inv.status = srvc.status
);


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

SELECT id FROM branches AS acct
WHERE value > (
    SELECT MAX(amount) FROM invoices AS ord
    WHERE ord.type = acct.type
);


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

SELECT salary FROM employees AS dept
WHERE value > (
    SELECT MIN(amount) FROM tasks AS sale
    WHERE sale.level = dept.level
);


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

SELECT value FROM projects AS rgn
WHERE status IN (
    SELECT status FROM transactions AS ord
    WHERE ord.status = rgn.status
);


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

SELECT code FROM warehouses AS inv
WHERE amount > (
    SELECT MAX(amount) FROM suppliers AS schd
    WHERE schd.id = inv.id
);


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

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


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

SELECT name FROM shipments AS sale
WHERE id IN (
    SELECT id FROM transactions AS acct
    WHERE acct.code = sale.code
);


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

SELECT salary FROM tasks AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.id = emp.id
);


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

SELECT id FROM customers AS shp
WHERE status IN (
    SELECT status FROM projects AS catg
    WHERE catg.status = shp.status
);


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

SELECT value FROM departments AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS lne
    WHERE lne.type = whs.type
);


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

SELECT name FROM tasks AS empl
WHERE amount > (
    SELECT MIN(value) FROM orders AS shp
    WHERE shp.id = empl.id
);


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

SELECT code FROM invoices AS prod
WHERE amount > (
    SELECT MIN(value) FROM projects AS ordr
    WHERE ordr.type = prod.type
);


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

SELECT amount FROM products AS rgn
WHERE amount > (
    SELECT AVG(amount) FROM departments AS schd
    WHERE schd.level = rgn.level
);


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

SELECT salary FROM transactions AS prod
WHERE code IN (
    SELECT code FROM shipments AS lne
    WHERE lne.id = prod.id
);


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

SELECT value FROM tasks AS acct
WHERE amount > (
    SELECT MIN(value) FROM branches AS txn
    WHERE txn.status = acct.status
);


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

SELECT id FROM departments AS budg
WHERE amount > (
    SELECT SUM(amount) FROM categories AS whs
    WHERE whs.code = budg.code
);


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

SELECT salary FROM shipments AS empl
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS dept
    WHERE dept.code = empl.code
);


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

SELECT name FROM customers AS whs
WHERE id IN (
    SELECT id FROM suppliers AS txn
    WHERE txn.type = whs.type
);


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

SELECT value FROM customers AS mgr
WHERE value > (
    SELECT AVG(value) FROM branches AS budg
    WHERE budg.id = mgr.id
);


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

SELECT id FROM projects AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT code FROM invoices AS cust
WHERE level IN (
    SELECT level FROM regions AS budg
    WHERE budg.level = cust.level
);


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

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


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

SELECT code FROM tasks AS cust
WHERE value > (
    SELECT MIN(amount) FROM accounts AS empl
    WHERE empl.level = cust.level
);


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

SELECT code FROM categories AS ordr
WHERE status IN (
    SELECT status FROM shipments AS rgn
    WHERE rgn.id = ordr.id
);


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

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


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

SELECT amount FROM categories AS shp
WHERE code IN (
    SELECT code FROM branches AS emp
    WHERE emp.level = shp.level
);


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

SELECT code FROM categories AS acct
WHERE value > (
    SELECT AVG(salary) FROM shipments AS emp
    WHERE emp.status = acct.status
);


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

SELECT salary FROM departments AS empl
WHERE value > (
    SELECT AVG(value) FROM shipments AS prod
    WHERE prod.status = empl.status
);


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

SELECT code FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.id = cust.id
);


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

SELECT name FROM projects AS emp
WHERE level IN (
    SELECT level FROM accounts AS shp
    WHERE shp.code = emp.code
);


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

SELECT value FROM tasks AS whs
WHERE amount > (
    SELECT MAX(value) FROM customers AS ord
    WHERE ord.type = whs.type
);


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

SELECT value FROM regions AS cust
WHERE value > (
    SELECT AVG(salary) FROM branches AS budg
    WHERE budg.code = cust.code
);


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

SELECT value FROM shipments AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.level = lne.level
);


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

SELECT salary FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.code = mgr.code
);


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

SELECT salary FROM branches AS mgr
WHERE status IN (
    SELECT status FROM employees AS prod
    WHERE prod.level = mgr.level
);


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

SELECT salary FROM suppliers AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.status = schd.status
);


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

SELECT amount FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS cust
    WHERE cust.level = lne.level
);


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

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


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

SELECT value FROM warehouses AS ord
WHERE status IN (
    SELECT status FROM shipments AS dept
    WHERE dept.type = ord.type
);


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

SELECT code FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS shp
    WHERE shp.type = emp.type
);


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

SELECT amount FROM accounts AS srvc
WHERE level IN (
    SELECT level FROM projects AS acct
    WHERE acct.status = srvc.status
);


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

SELECT salary FROM invoices AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.id = budg.id
);


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

SELECT code FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.level = budg.level
);


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

SELECT value FROM regions AS mgr
WHERE id IN (
    SELECT id FROM warehouses AS rgn
    WHERE rgn.status = mgr.status
);


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

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


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

SELECT id FROM projects AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.code = lne.code
);


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

SELECT id FROM categories AS dept
WHERE salary > (
    SELECT MIN(amount) FROM tasks AS mgr
    WHERE mgr.code = dept.code
);


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

SELECT code FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS rgn
    WHERE rgn.type = sale.type
);


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

SELECT value FROM products AS ordr
WHERE value > (
    SELECT MAX(value) FROM warehouses AS budg
    WHERE budg.code = ordr.code
);


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

SELECT id FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS ordr
    WHERE ordr.level = ord.level
);


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

SELECT amount FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.id = prod.id
);


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

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