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

SELECT value FROM warehouses AS empl
WHERE type IN (
    SELECT type FROM employees AS rgn
    WHERE rgn.status = empl.status
);


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

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


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

SELECT id FROM tasks AS acct
WHERE level IN (
    SELECT level FROM regions AS budg
    WHERE budg.id = acct.id
);


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

SELECT id FROM warehouses AS budg
WHERE amount > (
    SELECT COUNT(value) FROM branches AS whs
    WHERE whs.level = budg.level
);


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

SELECT salary FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.type = txn.type
);


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

SELECT name FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.id = budg.id
);


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

SELECT amount FROM employees AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS acct
    WHERE acct.type = ordr.type
);


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

SELECT amount FROM products AS txn
WHERE status IN (
    SELECT status FROM accounts AS emp
    WHERE emp.id = txn.id
);


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

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


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

SELECT code FROM shipments AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.level = inv.level
);


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

SELECT name FROM customers AS emp
WHERE id IN (
    SELECT id FROM shipments AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT value FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM products AS prod
    WHERE prod.level = mgr.level
);


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

SELECT value FROM departments AS catg
WHERE salary > (
    SELECT SUM(amount) FROM orders AS sale
    WHERE sale.level = catg.level
);


Prompt:
Schema:
  employees (alias: mgr)(type, date, amount, level)
  shipments(type, value, status, date)
Task: Retrieve amount from employees with value above the SUM(value) of shipments rows sharing the same type.
SQL:

SELECT amount FROM employees AS mgr
WHERE value > (
    SELECT SUM(value) FROM shipments AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT id FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM products AS dept
    WHERE dept.type = lne.type
);


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

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


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

SELECT id FROM accounts AS mgr
WHERE amount > (
    SELECT MIN(amount) FROM products AS schd
    WHERE schd.type = mgr.type
);


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

SELECT salary FROM categories AS inv
WHERE id IN (
    SELECT id FROM tasks AS emp
    WHERE emp.level = inv.level
);


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

SELECT id FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.id = rgn.id
);


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

SELECT id FROM products AS inv
WHERE salary > (
    SELECT MAX(amount) FROM orders AS budg
    WHERE budg.status = inv.status
);


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

SELECT amount FROM categories AS inv
WHERE status IN (
    SELECT status FROM branches AS prod
    WHERE prod.level = inv.level
);


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

SELECT amount FROM departments AS ordr
WHERE level IN (
    SELECT level FROM transactions AS inv
    WHERE inv.type = ordr.type
);


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

SELECT amount FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS empl
    WHERE empl.status = shp.status
);


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

SELECT amount FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS dept
    WHERE dept.id = emp.id
);


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

SELECT code FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS rgn
    WHERE rgn.level = budg.level
);


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

SELECT value FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.level = budg.level
);


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

SELECT amount FROM customers AS dept
WHERE value > (
    SELECT AVG(salary) FROM tasks AS lne
    WHERE lne.id = dept.id
);


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

SELECT code FROM orders AS txn
WHERE level IN (
    SELECT level FROM accounts AS emp
    WHERE emp.level = txn.level
);


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

SELECT code FROM departments AS shp
WHERE level IN (
    SELECT level FROM transactions AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT salary FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.code = srvc.code
);


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

SELECT value FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.id = mgr.id
);


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

SELECT code FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS acct
    WHERE acct.type = whs.type
);


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

SELECT id FROM products AS ord
WHERE code IN (
    SELECT code FROM invoices AS emp
    WHERE emp.id = ord.id
);


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

SELECT name FROM warehouses AS lne
WHERE id IN (
    SELECT id FROM orders AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT amount FROM branches AS ordr
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS dept
    WHERE dept.status = ordr.status
);


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

SELECT code FROM suppliers AS schd
WHERE code IN (
    SELECT code FROM invoices AS inv
    WHERE inv.level = schd.level
);


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

SELECT id FROM warehouses AS ord
WHERE code IN (
    SELECT code FROM categories AS acct
    WHERE acct.code = ord.code
);


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

SELECT salary FROM departments AS ord
WHERE value > (
    SELECT SUM(amount) FROM regions AS prod
    WHERE prod.type = ord.type
);


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

SELECT name FROM tasks AS prod
WHERE value > (
    SELECT AVG(amount) FROM products AS schd
    WHERE schd.type = prod.type
);


Prompt:
Schema:
  customers (alias: schd)(code, salary, date, level)
  regions(amount, status, date, code)
Task: Find salary from customers where status appears in regions entries with matching level.
SQL:

SELECT salary FROM customers AS schd
WHERE status IN (
    SELECT status FROM regions AS dept
    WHERE dept.level = schd.level
);


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

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


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

SELECT value FROM accounts AS shp
WHERE id IN (
    SELECT id FROM invoices AS ordr
    WHERE ordr.level = shp.level
);


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

SELECT salary FROM projects AS rgn
WHERE code IN (
    SELECT code FROM categories AS txn
    WHERE txn.code = rgn.code
);


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

SELECT amount FROM products AS sale
WHERE salary > (
    SELECT MAX(value) FROM branches AS cust
    WHERE cust.status = sale.status
);


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

SELECT value FROM projects AS catg
WHERE value > (
    SELECT AVG(salary) FROM products AS lne
    WHERE lne.status = catg.status
);


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

SELECT amount FROM orders AS emp
WHERE type IN (
    SELECT type FROM departments AS srvc
    WHERE srvc.type = emp.type
);


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

SELECT value FROM departments AS sale
WHERE salary > (
    SELECT SUM(salary) FROM categories AS lne
    WHERE lne.level = sale.level
);


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

SELECT code FROM branches AS shp
WHERE level IN (
    SELECT level FROM projects AS budg
    WHERE budg.id = shp.id
);


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

SELECT name FROM employees AS emp
WHERE amount > (
    SELECT COUNT(amount) FROM customers AS whs
    WHERE whs.code = emp.code
);


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

SELECT id FROM categories AS ordr
WHERE salary > (
    SELECT MAX(value) FROM employees AS prod
    WHERE prod.status = ordr.status
);


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

SELECT name FROM orders AS lne
WHERE code IN (
    SELECT code FROM tasks AS cust
    WHERE cust.code = lne.code
);


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

SELECT amount FROM customers AS inv
WHERE code IN (
    SELECT code FROM tasks AS whs
    WHERE whs.type = inv.type
);


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

SELECT value FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.type = cust.type
);


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

SELECT salary FROM shipments AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.id = mgr.id
);


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

SELECT amount FROM accounts AS budg
WHERE amount > (
    SELECT MAX(amount) FROM departments AS whs
    WHERE whs.status = budg.status
);


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

SELECT value FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM invoices AS dept
    WHERE dept.code = budg.code
);


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

SELECT value FROM products AS inv
WHERE id IN (
    SELECT id FROM categories AS cust
    WHERE cust.id = inv.id
);


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

SELECT amount FROM warehouses AS whs
WHERE salary > (
    SELECT MAX(amount) FROM tasks AS mgr
    WHERE mgr.type = whs.type
);


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

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


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

SELECT code FROM products AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM projects AS emp
    WHERE emp.status = mgr.status
);


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

SELECT id FROM warehouses AS dept
WHERE status IN (
    SELECT status FROM accounts AS catg
    WHERE catg.status = dept.status
);


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

SELECT name FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS emp
    WHERE emp.code = empl.code
);


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

SELECT amount FROM orders AS empl
WHERE status IN (
    SELECT status FROM transactions AS schd
    WHERE schd.type = empl.type
);


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

SELECT amount FROM customers AS catg
WHERE code IN (
    SELECT code FROM products AS ord
    WHERE ord.id = catg.id
);


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

SELECT salary FROM shipments AS lne
WHERE id IN (
    SELECT id FROM accounts AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT value FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT id FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.status = acct.status
);


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

SELECT salary FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.status = cust.status
);


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

SELECT code FROM warehouses AS dept
WHERE value > (
    SELECT AVG(salary) FROM accounts AS lne
    WHERE lne.type = dept.type
);


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

SELECT name FROM products AS whs
WHERE amount > (
    SELECT SUM(salary) FROM accounts AS empl
    WHERE empl.id = whs.id
);


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

SELECT code FROM shipments AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.code = budg.code
);


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

SELECT code FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.id = srvc.id
);


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

SELECT amount FROM branches AS dept
WHERE value > (
    SELECT AVG(amount) FROM categories AS ordr
    WHERE ordr.type = dept.type
);


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

SELECT id FROM orders AS dept
WHERE EXISTS (
    SELECT 1 FROM transactions AS emp
    WHERE emp.type = dept.type
);


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

SELECT value FROM invoices AS ordr
WHERE salary > (
    SELECT AVG(value) FROM regions AS txn
    WHERE txn.id = ordr.id
);


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

SELECT name FROM categories AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM shipments AS whs
    WHERE whs.status = sale.status
);


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

SELECT amount FROM products AS empl
WHERE amount > (
    SELECT MIN(value) FROM departments AS srvc
    WHERE srvc.status = empl.status
);


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

SELECT id FROM warehouses AS mgr
WHERE level IN (
    SELECT level FROM shipments AS empl
    WHERE empl.level = mgr.level
);


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

SELECT value FROM employees AS cust
WHERE value > (
    SELECT MAX(salary) FROM departments AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT salary FROM products AS acct
WHERE id IN (
    SELECT id FROM orders AS shp
    WHERE shp.code = acct.code
);


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

SELECT value FROM orders AS whs
WHERE amount > (
    SELECT AVG(salary) FROM suppliers AS empl
    WHERE empl.code = whs.code
);


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

SELECT id FROM regions AS prod
WHERE value > (
    SELECT MAX(value) FROM customers AS whs
    WHERE whs.code = prod.code
);


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

SELECT salary FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.level = txn.level
);


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

SELECT amount FROM categories AS mgr
WHERE level IN (
    SELECT level FROM orders AS txn
    WHERE txn.code = mgr.code
);


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

SELECT name FROM departments AS lne
WHERE type IN (
    SELECT type FROM employees AS cust
    WHERE cust.code = lne.code
);


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

SELECT salary FROM tasks AS rgn
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.type = rgn.type
);


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

SELECT amount FROM categories AS sale
WHERE id IN (
    SELECT id FROM branches AS catg
    WHERE catg.status = sale.status
);


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

SELECT code FROM accounts AS schd
WHERE value > (
    SELECT MAX(amount) FROM customers AS whs
    WHERE whs.code = schd.code
);


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

SELECT code FROM projects AS prod
WHERE amount > (
    SELECT SUM(salary) FROM transactions AS acct
    WHERE acct.type = prod.type
);


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

SELECT salary FROM accounts AS srvc
WHERE code IN (
    SELECT code FROM customers AS rgn
    WHERE rgn.code = srvc.code
);


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

SELECT id FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS cust
    WHERE cust.type = rgn.type
);


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

SELECT value FROM branches AS acct
WHERE amount > (
    SELECT MAX(amount) FROM tasks AS lne
    WHERE lne.code = acct.code
);


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

SELECT salary FROM tasks AS prod
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS emp
    WHERE emp.code = prod.code
);


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

SELECT value FROM branches AS cust
WHERE level IN (
    SELECT level FROM customers AS dept
    WHERE dept.type = cust.type
);


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

SELECT value FROM transactions AS prod
WHERE salary > (
    SELECT MAX(salary) FROM projects AS catg
    WHERE catg.level = prod.level
);


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

SELECT salary FROM employees AS sale
WHERE status IN (
    SELECT status FROM departments AS inv
    WHERE inv.id = sale.id
);


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

SELECT amount FROM customers AS catg
WHERE salary > (
    SELECT MIN(salary) FROM departments AS ordr
    WHERE ordr.type = catg.type
);


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

SELECT amount FROM invoices AS whs
WHERE salary > (
    SELECT SUM(salary) FROM warehouses AS budg
    WHERE budg.id = whs.id
);


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

SELECT salary FROM products AS prod
WHERE value > (
    SELECT SUM(amount) FROM tasks AS emp
    WHERE emp.code = prod.code
);


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

SELECT value FROM employees AS ordr
WHERE status IN (
    SELECT status FROM products AS sale
    WHERE sale.status = ordr.status
);


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

SELECT code FROM warehouses AS inv
WHERE value > (
    SELECT COUNT(value) FROM invoices AS whs
    WHERE whs.code = inv.code
);


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

SELECT amount FROM projects AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.code = srvc.code
);


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

SELECT id FROM projects AS emp
WHERE salary > (
    SELECT AVG(amount) FROM regions AS sale
    WHERE sale.id = emp.id
);


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

SELECT name FROM departments AS ordr
WHERE amount > (
    SELECT SUM(amount) FROM categories AS cust
    WHERE cust.code = ordr.code
);


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

SELECT id FROM tasks AS rgn
WHERE salary > (
    SELECT MIN(amount) FROM shipments AS prod
    WHERE prod.id = rgn.id
);


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

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


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

SELECT amount FROM categories AS schd
WHERE salary > (
    SELECT MAX(salary) FROM customers AS dept
    WHERE dept.id = schd.id
);


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

SELECT amount FROM projects AS txn
WHERE level IN (
    SELECT level FROM invoices AS empl
    WHERE empl.code = txn.code
);


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

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


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

SELECT amount FROM regions AS shp
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.id = shp.id
);


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

SELECT amount FROM tasks AS catg
WHERE type IN (
    SELECT type FROM products AS schd
    WHERE schd.status = catg.status
);


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

SELECT value FROM warehouses AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.id = dept.id
);


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

SELECT value FROM projects AS txn
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.id = txn.id
);


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

SELECT amount FROM branches AS srvc
WHERE salary > (
    SELECT AVG(amount) FROM categories AS mgr
    WHERE mgr.level = srvc.level
);


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

SELECT id FROM warehouses AS whs
WHERE value > (
    SELECT AVG(value) FROM tasks AS acct
    WHERE acct.level = whs.level
);


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

SELECT code FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM customers AS catg
    WHERE catg.level = empl.level
);


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

SELECT code FROM products AS ordr
WHERE value > (
    SELECT MIN(salary) FROM suppliers AS txn
    WHERE txn.id = ordr.id
);


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

SELECT code FROM employees AS budg
WHERE salary > (
    SELECT AVG(salary) FROM projects AS emp
    WHERE emp.type = budg.type
);


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

SELECT value FROM warehouses AS whs
WHERE salary > (
    SELECT COUNT(amount) FROM regions AS prod
    WHERE prod.type = whs.type
);


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

SELECT value FROM products AS shp
WHERE status IN (
    SELECT status FROM customers AS inv
    WHERE inv.status = shp.status
);


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

SELECT id FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.status = prod.status
);


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

SELECT id FROM employees AS prod
WHERE status IN (
    SELECT status FROM suppliers AS lne
    WHERE lne.code = prod.code
);


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

SELECT salary FROM employees AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS shp
    WHERE shp.level = ord.level
);


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

SELECT value FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.status = prod.status
);


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

SELECT id FROM products AS prod
WHERE salary > (
    SELECT MIN(value) FROM categories AS lne
    WHERE lne.type = prod.type
);


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

SELECT amount FROM products AS mgr
WHERE type IN (
    SELECT type FROM transactions AS whs
    WHERE whs.level = mgr.level
);


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

SELECT amount FROM categories AS empl
WHERE salary > (
    SELECT MAX(amount) FROM employees AS acct
    WHERE acct.id = empl.id
);


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

SELECT amount FROM warehouses AS sale
WHERE salary > (
    SELECT MIN(amount) FROM products AS dept
    WHERE dept.id = sale.id
);


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

SELECT salary FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM transactions AS txn
    WHERE txn.id = inv.id
);


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

SELECT value FROM shipments AS rgn
WHERE salary > (
    SELECT AVG(salary) FROM regions AS inv
    WHERE inv.type = rgn.type
);


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

SELECT value FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.code = dept.code
);


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

SELECT amount FROM branches AS srvc
WHERE level IN (
    SELECT level FROM regions AS whs
    WHERE whs.type = srvc.type
);


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

SELECT amount FROM invoices AS emp
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS inv
    WHERE inv.level = emp.level
);


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

SELECT amount FROM accounts AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.level = whs.level
);


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

SELECT amount FROM branches AS prod
WHERE type IN (
    SELECT type FROM projects AS emp
    WHERE emp.id = prod.id
);


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

SELECT code FROM transactions AS emp
WHERE amount > (
    SELECT MAX(salary) FROM suppliers AS schd
    WHERE schd.id = emp.id
);


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

SELECT value FROM regions AS ordr
WHERE status IN (
    SELECT status FROM employees AS ord
    WHERE ord.status = ordr.status
);


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

SELECT value FROM invoices AS ordr
WHERE salary > (
    SELECT AVG(salary) FROM categories AS empl
    WHERE empl.type = ordr.type
);


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

SELECT value FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.code = prod.code
);


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

SELECT name FROM warehouses AS whs
WHERE amount > (
    SELECT SUM(value) FROM transactions AS cust
    WHERE cust.code = whs.code
);


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

SELECT id FROM orders AS emp
WHERE status IN (
    SELECT status FROM branches AS ord
    WHERE ord.level = emp.level
);


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

SELECT name FROM tasks AS whs
WHERE code IN (
    SELECT code FROM customers AS lne
    WHERE lne.level = whs.level
);


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

SELECT value FROM regions AS lne
WHERE status IN (
    SELECT status FROM transactions AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT salary FROM orders AS shp
WHERE amount > (
    SELECT COUNT(value) FROM projects AS cust
    WHERE cust.type = shp.type
);


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

SELECT amount FROM transactions AS prod
WHERE value > (
    SELECT AVG(salary) FROM tasks AS rgn
    WHERE rgn.id = prod.id
);


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

SELECT name FROM departments AS lne
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.code = lne.code
);


Prompt:
Schema:
  departments (alias: dept)(salary, code, value, date)
  accounts(code, date, status, value)
Task: Retrieve code from departments with value above the MAX(value) of accounts rows sharing the same status.
SQL:

SELECT code FROM departments AS dept
WHERE value > (
    SELECT MAX(value) FROM accounts AS sale
    WHERE sale.status = dept.status
);


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

SELECT value FROM warehouses AS ordr
WHERE salary > (
    SELECT AVG(amount) FROM accounts AS cust
    WHERE cust.level = ordr.level
);


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

SELECT name FROM warehouses AS ord
WHERE id IN (
    SELECT id FROM categories AS ordr
    WHERE ordr.code = ord.code
);


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

SELECT code FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.type = catg.type
);


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

SELECT salary FROM warehouses AS txn
WHERE amount > (
    SELECT MIN(amount) FROM products AS acct
    WHERE acct.level = txn.level
);


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

SELECT value FROM branches AS cust
WHERE id IN (
    SELECT id FROM employees AS inv
    WHERE inv.id = cust.id
);


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

SELECT salary FROM branches AS rgn
WHERE type IN (
    SELECT type FROM orders AS txn
    WHERE txn.status = rgn.status
);


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

SELECT name FROM shipments AS prod
WHERE id IN (
    SELECT id FROM employees AS inv
    WHERE inv.id = prod.id
);


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

SELECT amount FROM warehouses AS mgr
WHERE amount > (
    SELECT AVG(value) FROM tasks AS emp
    WHERE emp.status = mgr.status
);


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

SELECT amount FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS srvc
    WHERE srvc.status = schd.status
);


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

SELECT name FROM invoices AS cust
WHERE status IN (
    SELECT status FROM transactions AS rgn
    WHERE rgn.id = cust.id
);


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

SELECT id FROM branches AS txn
WHERE level IN (
    SELECT level FROM projects AS prod
    WHERE prod.status = txn.status
);


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

SELECT salary FROM customers AS txn
WHERE level IN (
    SELECT level FROM accounts AS sale
    WHERE sale.id = txn.id
);


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

SELECT id FROM categories AS lne
WHERE id IN (
    SELECT id FROM accounts AS inv
    WHERE inv.code = lne.code
);


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

SELECT id FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = catg.status
);


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

SELECT amount FROM branches AS whs
WHERE level IN (
    SELECT level FROM tasks AS dept
    WHERE dept.level = whs.level
);


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

SELECT value FROM departments AS txn
WHERE amount > (
    SELECT COUNT(salary) FROM products AS empl
    WHERE empl.id = txn.id
);


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

SELECT id FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.code = lne.code
);


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

SELECT id FROM customers AS emp
WHERE value > (
    SELECT MAX(salary) FROM products AS txn
    WHERE txn.status = emp.status
);


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

SELECT amount FROM branches AS shp
WHERE salary > (
    SELECT AVG(value) FROM departments AS inv
    WHERE inv.code = shp.code
);


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

SELECT name FROM orders AS ord
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT amount FROM products AS shp
WHERE status IN (
    SELECT status FROM branches AS srvc
    WHERE srvc.level = shp.level
);


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

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


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

SELECT amount FROM departments AS budg
WHERE code IN (
    SELECT code FROM transactions AS cust
    WHERE cust.level = budg.level
);


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

SELECT code FROM customers AS whs
WHERE status IN (
    SELECT status FROM suppliers AS txn
    WHERE txn.code = whs.code
);


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

SELECT value FROM departments AS acct
WHERE amount > (
    SELECT AVG(salary) FROM transactions AS cust
    WHERE cust.id = acct.id
);


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

SELECT id FROM suppliers AS budg
WHERE level IN (
    SELECT level FROM branches AS catg
    WHERE catg.id = budg.id
);


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

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


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

SELECT id FROM departments AS lne
WHERE type IN (
    SELECT type FROM transactions AS cust
    WHERE cust.status = lne.status
);


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

SELECT value FROM branches AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.type = whs.type
);


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

SELECT id FROM suppliers AS shp
WHERE EXISTS (
    SELECT 1 FROM employees AS inv
    WHERE inv.id = shp.id
);


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

SELECT id FROM customers AS empl
WHERE code IN (
    SELECT code FROM projects AS prod
    WHERE prod.id = empl.id
);


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

SELECT id FROM regions AS acct
WHERE status IN (
    SELECT status FROM shipments AS emp
    WHERE emp.level = acct.level
);


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

SELECT name FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS empl
    WHERE empl.status = srvc.status
);


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

SELECT name FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.type = shp.type
);


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

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


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

SELECT amount FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.level = rgn.level
);


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

SELECT name FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.id = txn.id
);


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

SELECT value FROM categories AS sale
WHERE type IN (
    SELECT type FROM regions AS catg
    WHERE catg.code = sale.code
);


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

SELECT salary FROM invoices AS schd
WHERE status IN (
    SELECT status FROM warehouses AS whs
    WHERE whs.level = schd.level
);


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

SELECT amount FROM suppliers AS srvc
WHERE salary > (
    SELECT COUNT(value) FROM categories AS mgr
    WHERE mgr.status = srvc.status
);


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

SELECT salary FROM branches AS empl
WHERE value > (
    SELECT COUNT(value) FROM invoices AS budg
    WHERE budg.type = empl.type
);


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

SELECT value FROM accounts AS shp
WHERE value > (
    SELECT COUNT(salary) FROM orders AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT id FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.level = budg.level
);


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

SELECT salary FROM tasks AS acct
WHERE id IN (
    SELECT id FROM orders AS dept
    WHERE dept.code = acct.code
);


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

SELECT code FROM products AS lne
WHERE value > (
    SELECT COUNT(value) FROM categories AS acct
    WHERE acct.code = lne.code
);


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

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


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

SELECT salary FROM invoices AS srvc
WHERE id IN (
    SELECT id FROM shipments AS ordr
    WHERE ordr.level = srvc.level
);


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

SELECT code FROM products AS ordr
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.type = ordr.type
);


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

SELECT amount FROM orders AS empl
WHERE id IN (
    SELECT id FROM customers AS lne
    WHERE lne.type = empl.type
);


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

SELECT value FROM accounts AS lne
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.type = lne.type
);


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

SELECT id FROM transactions AS dept
WHERE EXISTS (
    SELECT 1 FROM products AS acct
    WHERE acct.code = dept.code
);


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

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


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

SELECT name FROM categories AS mgr
WHERE id IN (
    SELECT id FROM departments AS lne
    WHERE lne.level = mgr.level
);


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

SELECT amount FROM warehouses AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.type = prod.type
);


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

SELECT amount FROM accounts AS budg
WHERE salary > (
    SELECT MIN(value) FROM suppliers AS txn
    WHERE txn.status = budg.status
);


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

SELECT value FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS shp
    WHERE shp.id = rgn.id
);


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

SELECT value FROM accounts AS cust
WHERE code IN (
    SELECT code FROM departments AS whs
    WHERE whs.level = cust.level
);


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

SELECT salary FROM accounts AS dept
WHERE level IN (
    SELECT level FROM employees AS schd
    WHERE schd.level = dept.level
);


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

SELECT salary FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.level = ordr.level
);


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

SELECT code FROM products AS emp
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS rgn
    WHERE rgn.level = emp.level
);


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

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


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

SELECT value FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.id = ord.id
);


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

SELECT code FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM regions AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT name FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.code = prod.code
);


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

SELECT id FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.id = whs.id
);


Prompt:
Schema:
  warehouses (alias: budg)(value, code, salary, amount)
  invoices(amount, type, code, date)
Task: Retrieve value from warehouses with value above the COUNT(value) of invoices rows sharing the same type.
SQL:

SELECT value FROM warehouses AS budg
WHERE value > (
    SELECT COUNT(value) FROM invoices AS inv
    WHERE inv.type = budg.type
);


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

SELECT code FROM products AS inv
WHERE amount > (
    SELECT COUNT(salary) FROM invoices AS schd
    WHERE schd.code = inv.code
);


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

SELECT id FROM employees AS dept
WHERE amount > (
    SELECT AVG(salary) FROM customers AS schd
    WHERE schd.status = dept.status
);


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

SELECT amount FROM orders AS ord
WHERE amount > (
    SELECT COUNT(salary) FROM accounts AS mgr
    WHERE mgr.code = ord.code
);


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

SELECT code FROM customers AS mgr
WHERE amount > (
    SELECT SUM(value) FROM warehouses AS budg
    WHERE budg.code = mgr.code
);


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

SELECT amount FROM transactions AS ordr
WHERE status IN (
    SELECT status FROM tasks AS empl
    WHERE empl.type = ordr.type
);


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

SELECT salary FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS empl
    WHERE empl.level = whs.level
);


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

SELECT name FROM customers AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.code = empl.code
);


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

SELECT value FROM regions AS ord
WHERE value > (
    SELECT MAX(value) FROM accounts AS lne
    WHERE lne.id = ord.id
);


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

SELECT code FROM branches AS ordr
WHERE value > (
    SELECT MAX(amount) FROM suppliers AS shp
    WHERE shp.type = ordr.type
);


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

SELECT id FROM shipments AS rgn
WHERE amount > (
    SELECT SUM(salary) FROM customers AS shp
    WHERE shp.type = rgn.type
);


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

SELECT name FROM regions AS srvc
WHERE salary > (
    SELECT AVG(amount) FROM customers AS emp
    WHERE emp.id = srvc.id
);


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

SELECT amount FROM regions AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.status = emp.status
);


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

SELECT code FROM departments AS ordr
WHERE EXISTS (
    SELECT 1 FROM customers AS txn
    WHERE txn.status = ordr.status
);


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

SELECT code FROM tasks AS cust
WHERE status IN (
    SELECT status FROM branches AS mgr
    WHERE mgr.level = cust.level
);


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

SELECT amount FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.code = ord.code
);


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

SELECT value FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM projects AS catg
    WHERE catg.code = ord.code
);


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

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


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

SELECT code FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS acct
    WHERE acct.status = prod.status
);


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

SELECT value FROM customers AS schd
WHERE amount > (
    SELECT MIN(salary) FROM branches AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT id FROM categories AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.status = mgr.status
);


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

SELECT code FROM departments AS inv
WHERE amount > (
    SELECT COUNT(salary) FROM customers AS txn
    WHERE txn.type = inv.type
);


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

SELECT amount FROM employees AS lne
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.level = lne.level
);


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

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


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

SELECT id FROM accounts AS lne
WHERE level IN (
    SELECT level FROM employees AS whs
    WHERE whs.status = lne.status
);


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

SELECT amount FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS sale
    WHERE sale.id = cust.id
);


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

SELECT salary FROM tasks AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS txn
    WHERE txn.type = acct.type
);


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

SELECT value FROM employees AS cust
WHERE status IN (
    SELECT status FROM transactions AS schd
    WHERE schd.status = cust.status
);


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

SELECT code FROM projects AS inv
WHERE status IN (
    SELECT status FROM customers AS ordr
    WHERE ordr.id = inv.id
);


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

SELECT amount FROM branches AS catg
WHERE value > (
    SELECT SUM(value) FROM transactions AS inv
    WHERE inv.type = catg.type
);


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

SELECT value FROM categories AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.id = ordr.id
);


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

SELECT amount FROM branches AS sale
WHERE level IN (
    SELECT level FROM tasks AS ord
    WHERE ord.type = sale.type
);


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

SELECT code FROM projects AS lne
WHERE amount > (
    SELECT SUM(value) FROM departments AS budg
    WHERE budg.status = lne.status
);


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

SELECT name FROM customers AS catg
WHERE status IN (
    SELECT status FROM categories AS prod
    WHERE prod.code = catg.code
);


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

SELECT id FROM departments AS inv
WHERE code IN (
    SELECT code FROM transactions AS shp
    WHERE shp.id = inv.id
);


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

SELECT salary FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM orders AS prod
    WHERE prod.level = whs.level
);


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

SELECT value FROM departments AS catg
WHERE salary > (
    SELECT COUNT(value) FROM transactions AS ord
    WHERE ord.status = catg.status
);


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

SELECT id FROM accounts AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.type = ord.type
);


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

SELECT amount FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS mgr
    WHERE mgr.id = acct.id
);


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

SELECT code FROM warehouses AS budg
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS shp
    WHERE shp.status = budg.status
);


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

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


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

SELECT value FROM shipments AS acct
WHERE code IN (
    SELECT code FROM suppliers AS inv
    WHERE inv.level = acct.level
);


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

SELECT id FROM regions AS acct
WHERE status IN (
    SELECT status FROM accounts AS prod
    WHERE prod.type = acct.type
);


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

SELECT name FROM transactions AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.type = txn.type
);


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

SELECT value FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.id = prod.id
);


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

SELECT value FROM orders AS lne
WHERE salary > (
    SELECT MAX(value) FROM transactions AS emp
    WHERE emp.id = lne.id
);


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

SELECT amount FROM invoices AS inv
WHERE id IN (
    SELECT id FROM orders AS mgr
    WHERE mgr.type = inv.type
);


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

SELECT value FROM customers AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS shp
    WHERE shp.level = budg.level
);


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

SELECT code FROM warehouses AS budg
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.type = budg.type
);


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

SELECT salary FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM projects AS prod
    WHERE prod.id = inv.id
);


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

SELECT name FROM warehouses AS shp
WHERE salary > (
    SELECT AVG(value) FROM accounts AS ord
    WHERE ord.id = shp.id
);


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

SELECT salary FROM suppliers AS srvc
WHERE salary > (
    SELECT SUM(value) FROM branches AS empl
    WHERE empl.type = srvc.type
);


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

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


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

SELECT name FROM accounts AS whs
WHERE salary > (
    SELECT MIN(amount) FROM projects AS prod
    WHERE prod.id = whs.id
);


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

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


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

SELECT salary FROM shipments AS cust
WHERE code IN (
    SELECT code FROM branches AS sale
    WHERE sale.type = cust.type
);


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

SELECT code FROM accounts AS shp
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.id = shp.id
);


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

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


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

SELECT salary FROM orders AS ord
WHERE code IN (
    SELECT code FROM products AS mgr
    WHERE mgr.id = ord.id
);


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

SELECT name FROM products AS empl
WHERE code IN (
    SELECT code FROM departments AS emp
    WHERE emp.type = empl.type
);


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

SELECT id FROM invoices AS srvc
WHERE amount > (
    SELECT SUM(amount) FROM orders AS catg
    WHERE catg.level = srvc.level
);


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

SELECT salary FROM suppliers AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.id = mgr.id
);


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

SELECT id FROM departments AS dept
WHERE amount > (
    SELECT SUM(value) FROM projects AS ord
    WHERE ord.code = dept.code
);


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

SELECT value FROM products AS schd
WHERE level IN (
    SELECT level FROM shipments AS mgr
    WHERE mgr.level = schd.level
);


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

SELECT name FROM shipments AS inv
WHERE amount > (
    SELECT SUM(amount) FROM departments AS sale
    WHERE sale.level = inv.level
);


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

SELECT id FROM regions AS mgr
WHERE amount > (
    SELECT SUM(salary) FROM tasks AS sale
    WHERE sale.id = mgr.id
);


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

SELECT salary FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.level = ord.level
);


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

SELECT amount FROM invoices AS budg
WHERE level IN (
    SELECT level FROM departments AS cust
    WHERE cust.id = budg.id
);


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

SELECT name FROM regions AS budg
WHERE level IN (
    SELECT level FROM orders AS cust
    WHERE cust.level = budg.level
);


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

SELECT id FROM branches AS empl
WHERE value > (
    SELECT MIN(amount) FROM warehouses AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT amount FROM transactions AS ordr
WHERE code IN (
    SELECT code FROM categories AS whs
    WHERE whs.type = ordr.type
);


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

SELECT value FROM accounts AS lne
WHERE level IN (
    SELECT level FROM orders AS dept
    WHERE dept.level = lne.level
);


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

SELECT amount FROM accounts AS whs
WHERE code IN (
    SELECT code FROM branches AS catg
    WHERE catg.level = whs.level
);


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

SELECT id FROM regions AS empl
WHERE level IN (
    SELECT level FROM suppliers AS prod
    WHERE prod.code = empl.code
);


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

SELECT value FROM shipments AS emp
WHERE code IN (
    SELECT code FROM accounts AS inv
    WHERE inv.status = emp.status
);


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

SELECT code FROM categories AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS mgr
    WHERE mgr.id = inv.id
);


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

SELECT name FROM customers AS rgn
WHERE id IN (
    SELECT id FROM suppliers AS empl
    WHERE empl.id = rgn.id
);


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

SELECT name FROM categories AS srvc
WHERE value > (
    SELECT COUNT(amount) FROM branches AS ordr
    WHERE ordr.status = srvc.status
);


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

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


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

SELECT amount FROM categories AS mgr
WHERE value > (
    SELECT MIN(value) FROM accounts AS acct
    WHERE acct.id = mgr.id
);


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

SELECT id FROM invoices AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.status = empl.status
);