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

SELECT salary FROM employees AS catg
WHERE level IN (
    SELECT level FROM orders AS budg
    WHERE budg.status = catg.status
);


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

SELECT salary FROM customers AS empl
WHERE amount > (
    SELECT AVG(amount) FROM projects AS rgn
    WHERE rgn.id = empl.id
);


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

SELECT code FROM branches AS dept
WHERE level IN (
    SELECT level FROM categories AS empl
    WHERE empl.type = dept.type
);


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

SELECT id FROM transactions AS srvc
WHERE amount > (
    SELECT AVG(salary) FROM invoices AS prod
    WHERE prod.level = srvc.level
);


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

SELECT code FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM customers AS schd
    WHERE schd.level = acct.level
);


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

SELECT salary FROM orders AS cust
WHERE amount > (
    SELECT COUNT(value) FROM transactions AS srvc
    WHERE srvc.code = cust.code
);


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

SELECT amount FROM departments AS emp
WHERE status IN (
    SELECT status FROM regions AS lne
    WHERE lne.type = emp.type
);


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

SELECT name FROM employees AS catg
WHERE salary > (
    SELECT MIN(salary) FROM categories AS rgn
    WHERE rgn.type = catg.type
);


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

SELECT amount FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.level = ord.level
);


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

SELECT amount FROM suppliers AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.level = ordr.level
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS ordr
    WHERE ordr.type = whs.type
);


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

SELECT salary FROM invoices AS shp
WHERE id IN (
    SELECT id FROM suppliers AS emp
    WHERE emp.level = shp.level
);


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

SELECT id FROM customers AS prod
WHERE salary > (
    SELECT AVG(amount) FROM transactions AS whs
    WHERE whs.code = prod.code
);


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

SELECT salary FROM employees AS prod
WHERE amount > (
    SELECT COUNT(amount) FROM accounts AS budg
    WHERE budg.type = prod.type
);


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

SELECT salary FROM branches AS txn
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.id = txn.id
);


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

SELECT name FROM accounts AS emp
WHERE salary > (
    SELECT AVG(value) FROM orders AS rgn
    WHERE rgn.type = emp.type
);


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

SELECT name FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.status = prod.status
);


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

SELECT salary FROM categories AS dept
WHERE code IN (
    SELECT code FROM regions AS emp
    WHERE emp.level = dept.level
);


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

SELECT amount FROM categories AS lne
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS cust
    WHERE cust.status = lne.status
);


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

SELECT value FROM branches AS catg
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.type = catg.type
);


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

SELECT amount FROM accounts AS mgr
WHERE level IN (
    SELECT level FROM tasks AS emp
    WHERE emp.level = mgr.level
);


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

SELECT name FROM customers AS whs
WHERE level IN (
    SELECT level FROM accounts AS prod
    WHERE prod.id = whs.id
);


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

SELECT name FROM customers AS empl
WHERE amount > (
    SELECT SUM(value) FROM suppliers AS prod
    WHERE prod.id = empl.id
);


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

SELECT name FROM shipments AS rgn
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.status = rgn.status
);


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

SELECT amount FROM customers AS cust
WHERE id IN (
    SELECT id FROM orders AS acct
    WHERE acct.id = cust.id
);


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

SELECT name FROM invoices AS empl
WHERE type IN (
    SELECT type FROM suppliers AS rgn
    WHERE rgn.level = empl.level
);


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

SELECT value FROM departments AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.level = txn.level
);


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

SELECT id FROM shipments AS catg
WHERE value > (
    SELECT MIN(value) FROM employees AS ord
    WHERE ord.id = catg.id
);


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

SELECT salary FROM projects AS schd
WHERE value > (
    SELECT COUNT(value) FROM categories AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT id FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.id = emp.id
);


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

SELECT amount FROM suppliers AS shp
WHERE value > (
    SELECT SUM(amount) FROM branches AS lne
    WHERE lne.type = shp.type
);


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

SELECT amount FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.type = budg.type
);


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

SELECT amount FROM branches AS txn
WHERE value > (
    SELECT SUM(salary) FROM employees AS prod
    WHERE prod.type = txn.type
);


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

SELECT value FROM products AS acct
WHERE value > (
    SELECT SUM(salary) FROM customers AS schd
    WHERE schd.level = acct.level
);


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

SELECT salary FROM transactions AS dept
WHERE value > (
    SELECT MAX(salary) FROM warehouses AS emp
    WHERE emp.level = dept.level
);


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

SELECT code FROM projects AS catg
WHERE status IN (
    SELECT status FROM branches AS inv
    WHERE inv.code = catg.code
);


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

SELECT amount FROM warehouses AS catg
WHERE salary > (
    SELECT AVG(salary) FROM tasks AS acct
    WHERE acct.level = catg.level
);


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

SELECT salary FROM projects AS emp
WHERE amount > (
    SELECT AVG(amount) FROM branches AS cust
    WHERE cust.code = emp.code
);


Prompt:
Schema:
  orders (alias: shp)(id, amount, status, level)
  regions(code, date, id, status)
Task: Retrieve name from orders with amount above the COUNT(amount) of regions rows sharing the same id.
SQL:

SELECT name FROM orders AS shp
WHERE amount > (
    SELECT COUNT(amount) FROM regions AS ord
    WHERE ord.id = shp.id
);


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

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


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

SELECT salary FROM branches AS whs
WHERE code IN (
    SELECT code FROM invoices AS srvc
    WHERE srvc.type = whs.type
);


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

SELECT name FROM suppliers AS prod
WHERE EXISTS (
    SELECT 1 FROM projects AS srvc
    WHERE srvc.type = prod.type
);


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

SELECT value FROM branches AS prod
WHERE code IN (
    SELECT code FROM employees AS ord
    WHERE ord.status = prod.status
);


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

SELECT value FROM categories AS empl
WHERE status IN (
    SELECT status FROM invoices AS srvc
    WHERE srvc.type = empl.type
);


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

SELECT salary FROM categories AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.status = txn.status
);


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

SELECT id FROM warehouses AS dept
WHERE salary > (
    SELECT MAX(salary) FROM shipments AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT salary FROM regions AS mgr
WHERE amount > (
    SELECT MIN(salary) FROM branches AS sale
    WHERE sale.status = mgr.status
);


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

SELECT code FROM products AS txn
WHERE status IN (
    SELECT status FROM categories AS ordr
    WHERE ordr.type = txn.type
);


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

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


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

SELECT id FROM suppliers AS empl
WHERE id IN (
    SELECT id FROM branches AS acct
    WHERE acct.status = empl.status
);


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

SELECT amount FROM suppliers AS cust
WHERE status IN (
    SELECT status FROM employees AS lne
    WHERE lne.type = cust.type
);


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

SELECT value FROM departments AS ord
WHERE type IN (
    SELECT type FROM customers AS cust
    WHERE cust.level = ord.level
);


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

SELECT name FROM orders AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.code = lne.code
);


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

SELECT value FROM regions AS budg
WHERE id IN (
    SELECT id FROM transactions AS prod
    WHERE prod.type = budg.type
);


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

SELECT value FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.type = shp.type
);


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

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


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

SELECT id FROM employees AS rgn
WHERE EXISTS (
    SELECT 1 FROM projects AS txn
    WHERE txn.type = rgn.type
);


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

SELECT amount FROM invoices AS acct
WHERE amount > (
    SELECT MIN(amount) FROM shipments AS inv
    WHERE inv.type = acct.type
);


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

SELECT amount FROM departments AS mgr
WHERE salary > (
    SELECT MAX(value) FROM warehouses AS schd
    WHERE schd.status = mgr.status
);


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

SELECT value FROM warehouses AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS ordr
    WHERE ordr.status = ord.status
);


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

SELECT salary FROM accounts AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM departments AS budg
    WHERE budg.type = lne.type
);


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

SELECT id FROM shipments AS emp
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS catg
    WHERE catg.status = emp.status
);


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

SELECT amount FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.id = lne.id
);


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

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


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

SELECT value FROM shipments AS mgr
WHERE amount > (
    SELECT MAX(value) FROM orders AS empl
    WHERE empl.status = mgr.status
);


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

SELECT name FROM suppliers AS sale
WHERE salary > (
    SELECT MAX(value) FROM regions AS emp
    WHERE emp.level = sale.level
);


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

SELECT value FROM transactions AS sale
WHERE level IN (
    SELECT level FROM warehouses AS shp
    WHERE shp.code = sale.code
);


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

SELECT salary FROM projects AS emp
WHERE salary > (
    SELECT AVG(amount) FROM warehouses AS empl
    WHERE empl.code = emp.code
);


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

SELECT id FROM employees AS ord
WHERE salary > (
    SELECT SUM(value) FROM transactions AS prod
    WHERE prod.status = ord.status
);


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

SELECT salary FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.type = schd.type
);


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

SELECT salary FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.level = emp.level
);


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

SELECT amount FROM departments AS empl
WHERE type IN (
    SELECT type FROM categories AS shp
    WHERE shp.id = empl.id
);


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

SELECT name FROM orders AS rgn
WHERE code IN (
    SELECT code FROM accounts AS schd
    WHERE schd.level = rgn.level
);


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

SELECT name FROM employees AS prod
WHERE value > (
    SELECT MIN(value) FROM transactions AS empl
    WHERE empl.id = prod.id
);


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

SELECT amount FROM employees AS empl
WHERE value > (
    SELECT SUM(salary) FROM invoices AS lne
    WHERE lne.id = empl.id
);


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

SELECT code FROM categories AS budg
WHERE level IN (
    SELECT level FROM departments AS schd
    WHERE schd.status = budg.status
);


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

SELECT id FROM warehouses AS dept
WHERE id IN (
    SELECT id FROM projects AS whs
    WHERE whs.level = dept.level
);


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

SELECT amount FROM branches AS sale
WHERE amount > (
    SELECT COUNT(value) FROM warehouses AS ord
    WHERE ord.status = sale.status
);


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

SELECT salary FROM customers AS lne
WHERE EXISTS (
    SELECT 1 FROM orders AS catg
    WHERE catg.id = lne.id
);


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

SELECT code FROM suppliers AS emp
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.id = emp.id
);


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

SELECT value FROM customers AS emp
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.id = emp.id
);


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

SELECT amount FROM employees AS emp
WHERE level IN (
    SELECT level FROM warehouses AS budg
    WHERE budg.code = emp.code
);


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

SELECT amount FROM suppliers AS catg
WHERE code IN (
    SELECT code FROM regions AS lne
    WHERE lne.id = catg.id
);


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

SELECT value FROM branches AS mgr
WHERE level IN (
    SELECT level FROM transactions AS catg
    WHERE catg.code = mgr.code
);


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

SELECT id FROM departments AS budg
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS acct
    WHERE acct.id = budg.id
);


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

SELECT salary FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS dept
    WHERE dept.level = catg.level
);


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

SELECT amount FROM warehouses AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM customers AS sale
    WHERE sale.type = rgn.type
);


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

SELECT amount FROM regions AS inv
WHERE level IN (
    SELECT level FROM transactions AS srvc
    WHERE srvc.level = inv.level
);


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

SELECT id FROM shipments AS sale
WHERE amount > (
    SELECT COUNT(value) FROM branches AS inv
    WHERE inv.id = sale.id
);


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

SELECT id FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.code = ordr.code
);


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

SELECT amount FROM orders AS srvc
WHERE status IN (
    SELECT status FROM regions AS budg
    WHERE budg.code = srvc.code
);


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

SELECT code FROM regions AS lne
WHERE id IN (
    SELECT id FROM employees AS txn
    WHERE txn.type = lne.type
);


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

SELECT salary FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.type = prod.type
);


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

SELECT salary FROM employees AS inv
WHERE salary > (
    SELECT AVG(amount) FROM branches AS catg
    WHERE catg.type = inv.type
);


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

SELECT name FROM accounts AS cust
WHERE code IN (
    SELECT code FROM orders AS acct
    WHERE acct.code = cust.code
);


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

SELECT id FROM projects AS whs
WHERE amount > (
    SELECT AVG(value) FROM employees AS sale
    WHERE sale.id = whs.id
);


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

SELECT amount FROM employees AS budg
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.level = budg.level
);


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

SELECT name FROM customers AS budg
WHERE id IN (
    SELECT id FROM categories AS whs
    WHERE whs.code = budg.code
);


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

SELECT code FROM accounts AS lne
WHERE salary > (
    SELECT SUM(amount) FROM branches AS rgn
    WHERE rgn.type = lne.type
);


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

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


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

SELECT amount FROM shipments AS dept
WHERE value > (
    SELECT SUM(salary) FROM customers AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT value FROM projects AS txn
WHERE value > (
    SELECT AVG(amount) FROM branches AS inv
    WHERE inv.level = txn.level
);


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

SELECT code FROM transactions AS cust
WHERE salary > (
    SELECT MIN(salary) FROM tasks AS ord
    WHERE ord.status = cust.status
);


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

SELECT amount FROM transactions AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS txn
    WHERE txn.code = empl.code
);


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

SELECT amount FROM departments AS dept
WHERE value > (
    SELECT COUNT(amount) FROM tasks AS srvc
    WHERE srvc.status = dept.status
);


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

SELECT name FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.code = catg.code
);


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

SELECT value FROM departments AS txn
WHERE id IN (
    SELECT id FROM projects AS schd
    WHERE schd.level = txn.level
);


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

SELECT name FROM regions AS sale
WHERE type IN (
    SELECT type FROM categories AS dept
    WHERE dept.status = sale.status
);


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

SELECT salary FROM departments AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = rgn.id
);


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

SELECT code FROM products AS emp
WHERE type IN (
    SELECT type FROM warehouses AS catg
    WHERE catg.level = emp.level
);


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

SELECT value FROM invoices AS whs
WHERE amount > (
    SELECT SUM(amount) FROM orders AS sale
    WHERE sale.type = whs.type
);


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

SELECT salary FROM projects AS rgn
WHERE value > (
    SELECT COUNT(value) FROM regions AS ordr
    WHERE ordr.id = rgn.id
);


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

SELECT value FROM transactions AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS mgr
    WHERE mgr.code = budg.code
);


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

SELECT id FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM departments AS ordr
    WHERE ordr.code = inv.code
);


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

SELECT amount FROM accounts AS txn
WHERE salary > (
    SELECT SUM(amount) FROM branches AS whs
    WHERE whs.type = txn.type
);


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

SELECT amount FROM products AS inv
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.level = inv.level
);


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

SELECT value FROM regions AS ord
WHERE id IN (
    SELECT id FROM warehouses AS sale
    WHERE sale.code = ord.code
);


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

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


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

SELECT name FROM tasks AS whs
WHERE status IN (
    SELECT status FROM departments AS cust
    WHERE cust.type = whs.type
);


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

SELECT name FROM employees AS cust
WHERE code IN (
    SELECT code FROM shipments AS whs
    WHERE whs.status = cust.status
);


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

SELECT value FROM regions AS sale
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS shp
    WHERE shp.code = sale.code
);


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

SELECT amount FROM suppliers AS inv
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS catg
    WHERE catg.type = inv.type
);


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

SELECT code FROM categories AS inv
WHERE amount > (
    SELECT SUM(value) FROM departments AS sale
    WHERE sale.id = inv.id
);


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

SELECT amount FROM products AS txn
WHERE value > (
    SELECT AVG(value) FROM regions AS whs
    WHERE whs.type = txn.type
);


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

SELECT name FROM branches AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS lne
    WHERE lne.status = inv.status
);


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

SELECT salary FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS emp
    WHERE emp.type = dept.type
);


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

SELECT code FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.status = emp.status
);


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

SELECT amount FROM tasks AS whs
WHERE amount > (
    SELECT MIN(amount) FROM accounts AS budg
    WHERE budg.level = whs.level
);


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

SELECT salary FROM projects AS cust
WHERE salary > (
    SELECT AVG(value) FROM departments AS schd
    WHERE schd.status = cust.status
);


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

SELECT code FROM suppliers AS txn
WHERE salary > (
    SELECT COUNT(salary) FROM warehouses AS srvc
    WHERE srvc.type = txn.type
);


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

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


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

SELECT code FROM departments AS sale
WHERE level IN (
    SELECT level FROM customers AS mgr
    WHERE mgr.type = sale.type
);


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

SELECT amount FROM categories AS prod
WHERE amount > (
    SELECT COUNT(salary) FROM transactions AS shp
    WHERE shp.code = prod.code
);


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

SELECT value FROM projects AS prod
WHERE status IN (
    SELECT status FROM warehouses AS shp
    WHERE shp.level = prod.level
);


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

SELECT code FROM tasks AS budg
WHERE status IN (
    SELECT status FROM invoices AS txn
    WHERE txn.level = budg.level
);


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

SELECT value FROM transactions AS inv
WHERE EXISTS (
    SELECT 1 FROM tasks AS ordr
    WHERE ordr.code = inv.code
);


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

SELECT id FROM categories AS catg
WHERE amount > (
    SELECT SUM(value) FROM projects AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT salary FROM tasks AS catg
WHERE amount > (
    SELECT MAX(amount) FROM products AS whs
    WHERE whs.id = catg.id
);


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

SELECT code FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS lne
    WHERE lne.level = txn.level
);


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

SELECT value FROM customers AS shp
WHERE amount > (
    SELECT MAX(value) FROM shipments AS emp
    WHERE emp.type = shp.type
);


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

SELECT code FROM shipments AS lne
WHERE level IN (
    SELECT level FROM employees AS rgn
    WHERE rgn.id = lne.id
);


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

SELECT salary FROM shipments AS emp
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.id = emp.id
);


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

SELECT amount FROM suppliers AS lne
WHERE status IN (
    SELECT status FROM branches AS rgn
    WHERE rgn.level = lne.level
);


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

SELECT id FROM customers AS ordr
WHERE value > (
    SELECT SUM(amount) FROM regions AS mgr
    WHERE mgr.level = ordr.level
);


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

SELECT value FROM shipments AS mgr
WHERE amount > (
    SELECT COUNT(amount) FROM branches AS ord
    WHERE ord.level = mgr.level
);


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

SELECT code FROM orders AS dept
WHERE amount > (
    SELECT COUNT(salary) FROM employees AS mgr
    WHERE mgr.id = dept.id
);


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

SELECT value FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.status = shp.status
);


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

SELECT code FROM customers AS lne
WHERE amount > (
    SELECT MIN(amount) FROM transactions AS schd
    WHERE schd.level = lne.level
);


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

SELECT salary FROM transactions AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.code = whs.code
);


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

SELECT amount FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.code = srvc.code
);


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

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


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

SELECT name FROM accounts AS lne
WHERE value > (
    SELECT SUM(salary) FROM branches AS inv
    WHERE inv.type = lne.type
);


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

SELECT amount FROM employees AS catg
WHERE salary > (
    SELECT AVG(salary) FROM categories AS cust
    WHERE cust.id = catg.id
);


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

SELECT salary FROM warehouses AS budg
WHERE salary > (
    SELECT SUM(value) FROM employees AS sale
    WHERE sale.level = budg.level
);


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

SELECT value FROM projects AS prod
WHERE salary > (
    SELECT MAX(amount) FROM employees AS emp
    WHERE emp.type = prod.type
);


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

SELECT name FROM products AS acct
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS mgr
    WHERE mgr.type = acct.type
);


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

SELECT id FROM products AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.id = lne.id
);


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

SELECT code FROM projects AS lne
WHERE salary > (
    SELECT MAX(value) FROM tasks AS dept
    WHERE dept.level = lne.level
);


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

SELECT amount FROM shipments AS dept
WHERE type IN (
    SELECT type FROM tasks AS sale
    WHERE sale.status = dept.status
);


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

SELECT amount FROM shipments AS inv
WHERE id IN (
    SELECT id FROM suppliers AS prod
    WHERE prod.status = inv.status
);


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

SELECT name FROM accounts AS catg
WHERE EXISTS (
    SELECT 1 FROM departments AS acct
    WHERE acct.level = catg.level
);


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

SELECT amount FROM projects AS catg
WHERE code IN (
    SELECT code FROM employees AS schd
    WHERE schd.level = catg.level
);


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

SELECT amount FROM projects AS schd
WHERE value > (
    SELECT MIN(amount) FROM warehouses AS txn
    WHERE txn.code = schd.code
);


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

SELECT name FROM accounts AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM categories AS cust
    WHERE cust.status = rgn.status
);


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

SELECT salary FROM projects AS inv
WHERE level IN (
    SELECT level FROM departments AS ord
    WHERE ord.type = inv.type
);


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

SELECT code FROM transactions AS lne
WHERE code IN (
    SELECT code FROM categories AS empl
    WHERE empl.type = lne.type
);


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

SELECT id FROM departments AS shp
WHERE id IN (
    SELECT id FROM branches AS prod
    WHERE prod.level = shp.level
);


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

SELECT name FROM transactions AS sale
WHERE amount > (
    SELECT MAX(salary) FROM branches AS rgn
    WHERE rgn.status = sale.status
);


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

SELECT salary FROM employees AS mgr
WHERE status IN (
    SELECT status FROM products AS inv
    WHERE inv.code = mgr.code
);


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

SELECT salary FROM invoices AS sale
WHERE status IN (
    SELECT status FROM accounts AS dept
    WHERE dept.id = sale.id
);


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

SELECT id FROM tasks AS dept
WHERE amount > (
    SELECT AVG(amount) FROM warehouses AS lne
    WHERE lne.status = dept.status
);


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

SELECT amount FROM suppliers AS catg
WHERE amount > (
    SELECT COUNT(amount) FROM orders AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT code FROM products AS catg
WHERE type IN (
    SELECT type FROM accounts AS empl
    WHERE empl.status = catg.status
);


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

SELECT salary FROM warehouses AS cust
WHERE salary > (
    SELECT AVG(value) FROM accounts AS txn
    WHERE txn.type = cust.type
);


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

SELECT amount FROM customers AS acct
WHERE salary > (
    SELECT SUM(amount) FROM accounts AS catg
    WHERE catg.type = acct.type
);


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

SELECT id FROM products AS budg
WHERE code IN (
    SELECT code FROM projects AS sale
    WHERE sale.type = budg.type
);


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

SELECT name FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS schd
    WHERE schd.type = shp.type
);


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

SELECT salary FROM suppliers AS catg
WHERE salary > (
    SELECT COUNT(value) FROM products AS emp
    WHERE emp.status = catg.status
);


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

SELECT code FROM customers AS srvc
WHERE type IN (
    SELECT type FROM warehouses AS ordr
    WHERE ordr.code = srvc.code
);


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

SELECT salary FROM tasks AS budg
WHERE amount > (
    SELECT SUM(amount) FROM employees AS mgr
    WHERE mgr.level = budg.level
);


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

SELECT name FROM branches AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.id = dept.id
);


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

SELECT id FROM tasks AS prod
WHERE salary > (
    SELECT COUNT(salary) FROM products AS cust
    WHERE cust.level = prod.level
);


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

SELECT amount FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS txn
    WHERE txn.code = rgn.code
);


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

SELECT amount FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.type = prod.type
);


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

SELECT amount FROM categories AS ordr
WHERE code IN (
    SELECT code FROM suppliers AS cust
    WHERE cust.id = ordr.id
);


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

SELECT name FROM employees AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS empl
    WHERE empl.level = catg.level
);


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

SELECT amount FROM customers AS srvc
WHERE salary > (
    SELECT MIN(salary) FROM branches AS catg
    WHERE catg.status = srvc.status
);


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

SELECT amount FROM suppliers AS rgn
WHERE level IN (
    SELECT level FROM regions AS ordr
    WHERE ordr.status = rgn.status
);


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

SELECT value FROM categories AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS inv
    WHERE inv.type = cust.type
);


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

SELECT value FROM employees AS txn
WHERE amount > (
    SELECT AVG(salary) FROM customers AS lne
    WHERE lne.code = txn.code
);


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

SELECT name FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.type = schd.type
);


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

SELECT amount FROM customers AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.status = mgr.status
);


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

SELECT code FROM categories AS sale
WHERE value > (
    SELECT SUM(value) FROM tasks AS dept
    WHERE dept.id = sale.id
);


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

SELECT value FROM suppliers AS dept
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS emp
    WHERE emp.id = dept.id
);


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

SELECT amount FROM projects AS sale
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.type = sale.type
);


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

SELECT id FROM customers AS rgn
WHERE salary > (
    SELECT AVG(amount) FROM suppliers AS lne
    WHERE lne.id = rgn.id
);


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

SELECT code FROM employees AS txn
WHERE level IN (
    SELECT level FROM departments AS inv
    WHERE inv.code = txn.code
);


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

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


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

SELECT salary FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM customers AS prod
    WHERE prod.id = emp.id
);


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

SELECT value FROM departments AS sale
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.id = sale.id
);


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

SELECT code FROM categories AS whs
WHERE id IN (
    SELECT id FROM projects AS lne
    WHERE lne.status = whs.status
);


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

SELECT id FROM invoices AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT value FROM customers AS sale
WHERE amount > (
    SELECT SUM(amount) FROM regions AS lne
    WHERE lne.id = sale.id
);


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

SELECT salary FROM categories AS ord
WHERE status IN (
    SELECT status FROM suppliers AS lne
    WHERE lne.type = ord.type
);


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

SELECT id FROM invoices AS catg
WHERE value > (
    SELECT MAX(amount) FROM tasks AS lne
    WHERE lne.id = catg.id
);


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

SELECT name FROM regions AS srvc
WHERE EXISTS (
    SELECT 1 FROM accounts AS cust
    WHERE cust.status = srvc.status
);


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

SELECT name FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS ordr
    WHERE ordr.status = empl.status
);


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

SELECT code FROM tasks AS srvc
WHERE EXISTS (
    SELECT 1 FROM transactions AS ord
    WHERE ord.type = srvc.type
);


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

SELECT code FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM departments AS inv
    WHERE inv.status = whs.status
);


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

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


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

SELECT name FROM products AS rgn
WHERE code IN (
    SELECT code FROM accounts AS ord
    WHERE ord.type = rgn.type
);


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

SELECT salary FROM warehouses AS srvc
WHERE level IN (
    SELECT level FROM transactions AS sale
    WHERE sale.level = srvc.level
);


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

SELECT value FROM branches AS sale
WHERE EXISTS (
    SELECT 1 FROM shipments AS mgr
    WHERE mgr.status = sale.status
);


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

SELECT code FROM employees AS empl
WHERE amount > (
    SELECT AVG(value) FROM invoices AS ordr
    WHERE ordr.id = empl.id
);


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

SELECT salary FROM categories AS sale
WHERE amount > (
    SELECT SUM(value) FROM invoices AS lne
    WHERE lne.status = sale.status
);


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

SELECT salary FROM customers AS whs
WHERE salary > (
    SELECT MIN(value) FROM projects AS ord
    WHERE ord.id = whs.id
);


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

SELECT code FROM departments AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS cust
    WHERE cust.status = prod.status
);


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

SELECT salary FROM categories AS ord
WHERE EXISTS (
    SELECT 1 FROM products AS shp
    WHERE shp.status = ord.status
);


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

SELECT value FROM projects AS srvc
WHERE amount > (
    SELECT COUNT(amount) FROM transactions AS ordr
    WHERE ordr.status = srvc.status
);


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

SELECT salary FROM regions AS inv
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.code = inv.code
);


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

SELECT salary FROM products AS dept
WHERE code IN (
    SELECT code FROM customers AS shp
    WHERE shp.status = dept.status
);


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

SELECT value FROM customers AS txn
WHERE EXISTS (
    SELECT 1 FROM regions AS schd
    WHERE schd.type = txn.type
);


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

SELECT amount FROM tasks AS empl
WHERE level IN (
    SELECT level FROM customers AS cust
    WHERE cust.status = empl.status
);


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

SELECT salary FROM departments AS ord
WHERE level IN (
    SELECT level FROM suppliers AS shp
    WHERE shp.code = ord.code
);


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

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


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

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


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

SELECT value FROM warehouses AS empl
WHERE value > (
    SELECT SUM(amount) FROM regions AS emp
    WHERE emp.status = empl.status
);


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

SELECT id FROM transactions AS srvc
WHERE value > (
    SELECT MIN(salary) FROM branches AS budg
    WHERE budg.status = srvc.status
);


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

SELECT amount FROM orders AS acct
WHERE code IN (
    SELECT code FROM categories AS rgn
    WHERE rgn.level = acct.level
);


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

SELECT id FROM orders AS acct
WHERE amount > (
    SELECT COUNT(amount) FROM shipments AS prod
    WHERE prod.level = acct.level
);


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

SELECT value FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.code = catg.code
);


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

SELECT salary FROM orders AS shp
WHERE value > (
    SELECT AVG(value) FROM suppliers AS rgn
    WHERE rgn.type = shp.type
);


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

SELECT name FROM transactions AS acct
WHERE code IN (
    SELECT code FROM projects AS cust
    WHERE cust.id = acct.id
);


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

SELECT value FROM regions AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = ord.level
);


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

SELECT name FROM transactions AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS inv
    WHERE inv.type = sale.type
);


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

SELECT id FROM products AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.id = dept.id
);


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

SELECT salary FROM projects AS mgr
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.id = mgr.id
);


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

SELECT salary FROM shipments AS lne
WHERE code IN (
    SELECT code FROM branches AS sale
    WHERE sale.status = lne.status
);


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

SELECT salary FROM products AS acct
WHERE value > (
    SELECT MIN(value) FROM invoices AS srvc
    WHERE srvc.level = acct.level
);


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

SELECT name FROM products AS mgr
WHERE salary > (
    SELECT SUM(value) FROM departments AS srvc
    WHERE srvc.id = mgr.id
);


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

SELECT name FROM departments AS ordr
WHERE value > (
    SELECT AVG(amount) FROM regions AS catg
    WHERE catg.level = ordr.level
);


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

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


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

SELECT value FROM tasks AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS ordr
    WHERE ordr.status = schd.status
);


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

SELECT id FROM transactions AS shp
WHERE value > (
    SELECT MAX(amount) FROM products AS sale
    WHERE sale.code = shp.code
);


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

SELECT id FROM products AS txn
WHERE code IN (
    SELECT code FROM tasks AS whs
    WHERE whs.code = txn.code
);


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

SELECT code FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM customers AS ord
    WHERE ord.id = whs.id
);


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

SELECT value FROM suppliers AS catg
WHERE id IN (
    SELECT id FROM transactions AS empl
    WHERE empl.type = catg.type
);


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

SELECT salary FROM orders AS rgn
WHERE level IN (
    SELECT level FROM products AS whs
    WHERE whs.code = rgn.code
);


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

SELECT name FROM orders AS sale
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.type = sale.type
);


Prompt:
Schema:
  products (alias: emp)(code, id, amount, name)
  departments(amount, code, name, level)
Task: Select name from products where id exists in departments for the same id.
SQL:

SELECT name FROM products AS emp
WHERE id IN (
    SELECT id FROM departments AS rgn
    WHERE rgn.id = emp.id
);


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

SELECT id FROM transactions AS lne
WHERE id IN (
    SELECT id FROM suppliers AS schd
    WHERE schd.level = lne.level
);


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

SELECT name FROM tasks AS shp
WHERE code IN (
    SELECT code FROM customers AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT amount FROM branches AS ordr
WHERE id IN (
    SELECT id FROM categories AS srvc
    WHERE srvc.type = ordr.type
);


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

SELECT id FROM regions AS empl
WHERE id IN (
    SELECT id FROM orders AS txn
    WHERE txn.id = empl.id
);


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

SELECT id FROM projects AS catg
WHERE salary > (
    SELECT AVG(amount) FROM customers AS emp
    WHERE emp.type = catg.type
);


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

SELECT name FROM transactions AS ord
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ordr
    WHERE ordr.type = ord.type
);


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

SELECT amount FROM categories AS budg
WHERE level IN (
    SELECT level FROM regions AS inv
    WHERE inv.type = budg.type
);


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

SELECT name FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.type = schd.type
);


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

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


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

SELECT name FROM products AS catg
WHERE amount > (
    SELECT MIN(salary) FROM customers AS cust
    WHERE cust.id = catg.id
);


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

SELECT code FROM warehouses AS emp
WHERE level IN (
    SELECT level FROM categories AS empl
    WHERE empl.id = emp.id
);


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

SELECT salary FROM projects AS whs
WHERE salary > (
    SELECT SUM(salary) FROM suppliers AS cust
    WHERE cust.type = whs.type
);


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

SELECT id FROM products AS txn
WHERE type IN (
    SELECT type FROM customers AS empl
    WHERE empl.status = txn.status
);


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

SELECT name FROM departments AS emp
WHERE amount > (
    SELECT MAX(salary) FROM projects AS whs
    WHERE whs.type = emp.type
);


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

SELECT id FROM regions AS empl
WHERE type IN (
    SELECT type FROM invoices AS srvc
    WHERE srvc.id = empl.id
);


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

SELECT name FROM warehouses AS emp
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.type = emp.type
);


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

SELECT amount FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS rgn
    WHERE rgn.code = cust.code
);


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

SELECT code FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM shipments AS srvc
    WHERE srvc.level = empl.level
);


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

SELECT value FROM invoices AS ord
WHERE status IN (
    SELECT status FROM projects AS shp
    WHERE shp.status = ord.status
);


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

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


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

SELECT value FROM customers AS whs
WHERE status IN (
    SELECT status FROM accounts AS catg
    WHERE catg.status = whs.status
);


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

SELECT code FROM accounts AS inv
WHERE EXISTS (
    SELECT 1 FROM categories AS sale
    WHERE sale.type = inv.type
);


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

SELECT amount FROM branches AS lne
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.type = lne.type
);


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

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


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

SELECT salary FROM regions AS rgn
WHERE value > (
    SELECT MIN(amount) FROM departments AS cust
    WHERE cust.id = rgn.id
);


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

SELECT id FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM suppliers AS srvc
    WHERE srvc.code = schd.code
);


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

SELECT id FROM projects AS ordr
WHERE value > (
    SELECT AVG(amount) FROM customers AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT id FROM transactions AS shp
WHERE id IN (
    SELECT id FROM categories AS cust
    WHERE cust.type = shp.type
);


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

SELECT value FROM suppliers AS budg
WHERE status IN (
    SELECT status FROM tasks AS prod
    WHERE prod.status = budg.status
);


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

SELECT value FROM orders AS txn
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.status = txn.status
);


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

SELECT code FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM regions AS dept
    WHERE dept.type = ordr.type
);


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

SELECT name FROM warehouses AS lne
WHERE amount > (
    SELECT MAX(amount) FROM invoices AS mgr
    WHERE mgr.type = lne.type
);


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

SELECT salary FROM tasks AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.status = shp.status
);


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

SELECT code FROM tasks AS shp
WHERE level IN (
    SELECT level FROM customers AS sale
    WHERE sale.level = shp.level
);


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

SELECT value FROM shipments AS ord
WHERE type IN (
    SELECT type FROM invoices AS empl
    WHERE empl.status = ord.status
);


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

SELECT amount FROM employees AS shp
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.level = shp.level
);


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

SELECT value FROM branches AS ordr
WHERE code IN (
    SELECT code FROM projects AS schd
    WHERE schd.status = ordr.status
);


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

SELECT code FROM accounts AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM regions AS prod
    WHERE prod.level = catg.level
);


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

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


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

SELECT salary FROM employees AS empl
WHERE id IN (
    SELECT id FROM projects AS inv
    WHERE inv.status = empl.status
);


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

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


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

SELECT code FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS schd
    WHERE schd.level = txn.level
);