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

SELECT amount FROM employees AS txn
WHERE status IN (
    SELECT status FROM regions AS budg
    WHERE budg.status = txn.status
);


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

SELECT value FROM categories AS rgn
WHERE code IN (
    SELECT code FROM accounts AS txn
    WHERE txn.code = rgn.code
);


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

SELECT value FROM branches AS shp
WHERE id IN (
    SELECT id FROM departments AS rgn
    WHERE rgn.type = shp.type
);


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

SELECT name FROM products AS shp
WHERE code IN (
    SELECT code FROM accounts AS cust
    WHERE cust.level = shp.level
);


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

SELECT salary FROM shipments AS rgn
WHERE type IN (
    SELECT type FROM invoices AS inv
    WHERE inv.status = rgn.status
);


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

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


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

SELECT code FROM transactions AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS whs
    WHERE whs.level = catg.level
);


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

SELECT code FROM categories AS emp
WHERE value > (
    SELECT MIN(salary) FROM orders AS srvc
    WHERE srvc.id = emp.id
);


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

SELECT salary FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.level = ordr.level
);


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

SELECT code FROM customers AS shp
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.code = shp.code
);


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

SELECT name FROM warehouses AS sale
WHERE value > (
    SELECT MAX(salary) FROM orders AS rgn
    WHERE rgn.type = sale.type
);


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

SELECT salary FROM categories AS shp
WHERE code IN (
    SELECT code FROM employees AS rgn
    WHERE rgn.status = shp.status
);


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

SELECT code FROM orders AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS shp
    WHERE shp.status = cust.status
);


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

SELECT code FROM departments AS inv
WHERE value > (
    SELECT COUNT(amount) FROM projects AS acct
    WHERE acct.id = inv.id
);


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

SELECT amount FROM products AS schd
WHERE level IN (
    SELECT level FROM customers AS txn
    WHERE txn.type = schd.type
);


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

SELECT id FROM employees AS emp
WHERE value > (
    SELECT MAX(salary) FROM categories AS sale
    WHERE sale.level = emp.level
);


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

SELECT salary FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM suppliers AS acct
    WHERE acct.level = srvc.level
);


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

SELECT name FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.type = catg.type
);


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

SELECT id FROM orders AS mgr
WHERE value > (
    SELECT SUM(value) FROM suppliers AS shp
    WHERE shp.status = mgr.status
);


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

SELECT name FROM tasks AS budg
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.code = budg.code
);


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

SELECT name FROM departments AS srvc
WHERE amount > (
    SELECT MAX(salary) FROM warehouses AS dept
    WHERE dept.id = srvc.id
);


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

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


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

SELECT salary FROM invoices AS sale
WHERE salary > (
    SELECT COUNT(amount) FROM tasks AS catg
    WHERE catg.id = sale.id
);


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

SELECT id FROM tasks AS whs
WHERE level IN (
    SELECT level FROM customers AS empl
    WHERE empl.type = whs.type
);


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

SELECT name FROM projects AS schd
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.code = schd.code
);


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

SELECT amount FROM invoices AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS dept
    WHERE dept.level = inv.level
);


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

SELECT name FROM customers AS dept
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.code = dept.code
);


Prompt:
Schema:
  orders (alias: whs)(value, id, level, type)
  regions(id, name, value, type)
Task: Retrieve code from orders with value above the SUM(value) of regions rows sharing the same code.
SQL:

SELECT code FROM orders AS whs
WHERE value > (
    SELECT SUM(value) FROM regions AS mgr
    WHERE mgr.code = whs.code
);


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

SELECT value FROM accounts AS sale
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.status = sale.status
);


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

SELECT salary FROM warehouses AS budg
WHERE type IN (
    SELECT type FROM regions AS prod
    WHERE prod.level = budg.level
);


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

SELECT value FROM tasks AS rgn
WHERE level IN (
    SELECT level FROM products AS mgr
    WHERE mgr.type = rgn.type
);


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

SELECT id FROM employees AS sale
WHERE EXISTS (
    SELECT 1 FROM customers AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT code FROM invoices AS rgn
WHERE type IN (
    SELECT type FROM customers AS mgr
    WHERE mgr.id = rgn.id
);


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM shipments AS budg
    WHERE budg.type = ord.type
);


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

SELECT salary FROM warehouses AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS lne
    WHERE lne.level = whs.level
);


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

SELECT amount FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM orders AS ord
    WHERE ord.level = catg.level
);


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

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


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

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


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

SELECT id FROM suppliers AS acct
WHERE type IN (
    SELECT type FROM transactions AS budg
    WHERE budg.code = acct.code
);


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

SELECT name FROM departments AS acct
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS empl
    WHERE empl.level = acct.level
);


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

SELECT code FROM regions AS txn
WHERE id IN (
    SELECT id FROM shipments AS acct
    WHERE acct.code = txn.code
);


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

SELECT value FROM tasks AS budg
WHERE salary > (
    SELECT AVG(value) FROM suppliers AS sale
    WHERE sale.code = budg.code
);


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

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


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

SELECT id FROM orders AS acct
WHERE code IN (
    SELECT code FROM products AS prod
    WHERE prod.status = acct.status
);


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

SELECT code FROM employees AS empl
WHERE salary > (
    SELECT SUM(salary) FROM customers AS mgr
    WHERE mgr.level = empl.level
);


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

SELECT code FROM products AS ord
WHERE amount > (
    SELECT MAX(value) FROM tasks AS mgr
    WHERE mgr.status = ord.status
);


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

SELECT code FROM departments AS catg
WHERE EXISTS (
    SELECT 1 FROM regions AS lne
    WHERE lne.type = catg.type
);


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

SELECT amount FROM departments AS budg
WHERE status IN (
    SELECT status FROM tasks AS catg
    WHERE catg.code = budg.code
);


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

SELECT value FROM projects AS budg
WHERE salary > (
    SELECT COUNT(amount) FROM suppliers AS ord
    WHERE ord.type = budg.type
);


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

SELECT id FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM regions AS sale
    WHERE sale.level = whs.level
);


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

SELECT code FROM orders AS txn
WHERE status IN (
    SELECT status FROM shipments AS ord
    WHERE ord.status = txn.status
);


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

SELECT id FROM invoices AS dept
WHERE code IN (
    SELECT code FROM accounts AS txn
    WHERE txn.level = dept.level
);


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

SELECT value FROM employees AS empl
WHERE level IN (
    SELECT level FROM projects AS mgr
    WHERE mgr.level = empl.level
);


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

SELECT salary FROM invoices AS budg
WHERE amount > (
    SELECT COUNT(value) FROM shipments AS inv
    WHERE inv.code = budg.code
);


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

SELECT salary FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.id = lne.id
);


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

SELECT id FROM suppliers AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS dept
    WHERE dept.type = lne.type
);


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

SELECT name FROM shipments AS prod
WHERE code IN (
    SELECT code FROM projects AS ordr
    WHERE ordr.id = prod.id
);


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

SELECT amount FROM shipments AS sale
WHERE level IN (
    SELECT level FROM departments AS prod
    WHERE prod.status = sale.status
);


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

SELECT name FROM orders AS shp
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.level = shp.level
);


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

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


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

SELECT amount FROM categories AS shp
WHERE salary > (
    SELECT COUNT(salary) FROM branches AS ordr
    WHERE ordr.status = shp.status
);


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

SELECT value FROM warehouses AS whs
WHERE salary > (
    SELECT COUNT(value) FROM orders AS dept
    WHERE dept.code = whs.code
);


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

SELECT id FROM orders AS shp
WHERE status IN (
    SELECT status FROM products AS srvc
    WHERE srvc.status = shp.status
);


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

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


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

SELECT salary FROM invoices AS dept
WHERE EXISTS (
    SELECT 1 FROM customers AS cust
    WHERE cust.status = dept.status
);


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

SELECT amount FROM suppliers AS sale
WHERE level IN (
    SELECT level FROM accounts AS rgn
    WHERE rgn.id = sale.id
);


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

SELECT code FROM transactions AS inv
WHERE level IN (
    SELECT level FROM tasks AS emp
    WHERE emp.code = inv.code
);


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

SELECT value FROM invoices AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM suppliers AS txn
    WHERE txn.level = sale.level
);


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

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


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

SELECT value FROM suppliers AS prod
WHERE level IN (
    SELECT level FROM shipments AS emp
    WHERE emp.type = prod.type
);


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

SELECT code FROM projects AS emp
WHERE amount > (
    SELECT COUNT(amount) FROM warehouses AS sale
    WHERE sale.status = emp.status
);


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

SELECT salary FROM regions AS cust
WHERE value > (
    SELECT MAX(amount) FROM projects AS budg
    WHERE budg.level = cust.level
);


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

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


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

SELECT value FROM tasks AS empl
WHERE salary > (
    SELECT AVG(value) FROM accounts AS acct
    WHERE acct.level = empl.level
);


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

SELECT value FROM projects AS shp
WHERE salary > (
    SELECT MIN(amount) FROM warehouses AS rgn
    WHERE rgn.code = shp.code
);


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

SELECT amount FROM customers AS empl
WHERE status IN (
    SELECT status FROM departments AS emp
    WHERE emp.level = empl.level
);


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

SELECT value FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.code = acct.code
);


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

SELECT value FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM suppliers AS rgn
    WHERE rgn.code = acct.code
);


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

SELECT code FROM categories AS inv
WHERE type IN (
    SELECT type FROM customers AS txn
    WHERE txn.level = inv.level
);


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

SELECT code FROM regions AS prod
WHERE EXISTS (
    SELECT 1 FROM categories AS inv
    WHERE inv.code = prod.code
);


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

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


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

SELECT value FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.id = prod.id
);


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

SELECT amount FROM customers AS acct
WHERE type IN (
    SELECT type FROM employees AS schd
    WHERE schd.code = acct.code
);


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

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


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

SELECT code FROM categories AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS whs
    WHERE whs.type = rgn.type
);


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

SELECT name FROM tasks AS inv
WHERE value > (
    SELECT MIN(value) FROM employees AS acct
    WHERE acct.type = inv.type
);


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

SELECT id FROM suppliers AS mgr
WHERE salary > (
    SELECT COUNT(salary) FROM orders AS schd
    WHERE schd.type = mgr.type
);


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

SELECT code FROM categories AS ord
WHERE salary > (
    SELECT AVG(value) FROM invoices AS cust
    WHERE cust.code = ord.code
);


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

SELECT salary FROM warehouses AS lne
WHERE id IN (
    SELECT id FROM regions AS cust
    WHERE cust.code = lne.code
);


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

SELECT name FROM shipments AS schd
WHERE amount > (
    SELECT AVG(salary) FROM suppliers AS cust
    WHERE cust.level = schd.level
);


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

SELECT code FROM customers AS budg
WHERE value > (
    SELECT MAX(amount) FROM categories AS whs
    WHERE whs.id = budg.id
);


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

SELECT salary FROM suppliers AS schd
WHERE code IN (
    SELECT code FROM warehouses AS whs
    WHERE whs.status = schd.status
);


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

SELECT amount FROM warehouses AS empl
WHERE value > (
    SELECT AVG(amount) FROM orders AS catg
    WHERE catg.id = empl.id
);


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

SELECT id FROM projects AS budg
WHERE value > (
    SELECT MAX(amount) FROM products AS rgn
    WHERE rgn.status = budg.status
);


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

SELECT salary FROM employees AS inv
WHERE id IN (
    SELECT id FROM accounts AS acct
    WHERE acct.type = inv.type
);


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

SELECT id FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM customers AS budg
    WHERE budg.type = mgr.type
);


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

SELECT code FROM categories AS sale
WHERE level IN (
    SELECT level FROM accounts AS dept
    WHERE dept.code = sale.code
);


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

SELECT amount FROM employees AS ordr
WHERE salary > (
    SELECT MIN(value) FROM regions AS prod
    WHERE prod.level = ordr.level
);


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

SELECT value FROM branches AS txn
WHERE value > (
    SELECT COUNT(amount) FROM categories AS srvc
    WHERE srvc.level = txn.level
);


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

SELECT name FROM warehouses AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS schd
    WHERE schd.id = cust.id
);


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

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


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

SELECT salary FROM employees AS inv
WHERE amount > (
    SELECT MAX(value) FROM orders AS ord
    WHERE ord.status = inv.status
);


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

SELECT amount FROM suppliers AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM categories AS whs
    WHERE whs.id = sale.id
);


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

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


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

SELECT name FROM departments AS cust
WHERE amount > (
    SELECT AVG(salary) FROM orders AS rgn
    WHERE rgn.type = cust.type
);


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

SELECT amount FROM regions AS shp
WHERE id IN (
    SELECT id FROM projects AS lne
    WHERE lne.id = shp.id
);


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

SELECT salary FROM departments AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS dept
    WHERE dept.level = shp.level
);


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

SELECT id FROM orders AS inv
WHERE id IN (
    SELECT id FROM projects AS catg
    WHERE catg.id = inv.id
);


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

SELECT value FROM transactions AS rgn
WHERE value > (
    SELECT MAX(amount) FROM customers AS empl
    WHERE empl.status = rgn.status
);


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

SELECT amount FROM projects AS shp
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.level = shp.level
);


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

SELECT salary FROM projects AS schd
WHERE salary > (
    SELECT COUNT(salary) FROM products AS shp
    WHERE shp.level = schd.level
);


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

SELECT code FROM customers AS ordr
WHERE type IN (
    SELECT type FROM transactions AS mgr
    WHERE mgr.type = ordr.type
);


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

SELECT name FROM transactions AS lne
WHERE amount > (
    SELECT MIN(amount) FROM tasks AS ordr
    WHERE ordr.status = lne.status
);


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

SELECT salary FROM products AS schd
WHERE EXISTS (
    SELECT 1 FROM departments AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT name FROM categories AS empl
WHERE amount > (
    SELECT MIN(value) FROM accounts AS schd
    WHERE schd.level = empl.level
);


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

SELECT value FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS acct
    WHERE acct.code = empl.code
);


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

SELECT name FROM departments AS inv
WHERE salary > (
    SELECT MIN(value) FROM orders AS catg
    WHERE catg.id = inv.id
);


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

SELECT name FROM customers AS sale
WHERE value > (
    SELECT SUM(salary) FROM warehouses AS inv
    WHERE inv.id = sale.id
);


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

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


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

SELECT code FROM orders AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.code = schd.code
);


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

SELECT name FROM warehouses AS prod
WHERE type IN (
    SELECT type FROM tasks AS budg
    WHERE budg.id = prod.id
);


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

SELECT amount FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS empl
    WHERE empl.code = whs.code
);


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

SELECT name FROM invoices AS ordr
WHERE EXISTS (
    SELECT 1 FROM orders AS shp
    WHERE shp.status = ordr.status
);


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

SELECT value FROM regions AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS ord
    WHERE ord.code = cust.code
);


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

SELECT id FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM departments AS prod
    WHERE prod.level = sale.level
);


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

SELECT id FROM regions AS catg
WHERE amount > (
    SELECT COUNT(salary) FROM invoices AS srvc
    WHERE srvc.id = catg.id
);


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

SELECT id FROM customers AS emp
WHERE type IN (
    SELECT type FROM suppliers AS srvc
    WHERE srvc.code = emp.code
);


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

SELECT value FROM accounts AS whs
WHERE salary > (
    SELECT AVG(salary) FROM warehouses AS inv
    WHERE inv.level = whs.level
);


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

SELECT amount FROM regions AS dept
WHERE value > (
    SELECT MIN(value) FROM orders AS mgr
    WHERE mgr.id = dept.id
);


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

SELECT value FROM products AS mgr
WHERE value > (
    SELECT AVG(value) FROM employees AS acct
    WHERE acct.level = mgr.level
);


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

SELECT salary FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM branches AS schd
    WHERE schd.id = cust.id
);


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

SELECT code FROM projects AS ordr
WHERE salary > (
    SELECT SUM(amount) FROM transactions AS mgr
    WHERE mgr.code = ordr.code
);


Prompt:
Schema:
  products (alias: empl)(amount, value, salary, name)
  tasks(salary, value, id, type)
Task: Select name from products where id exists in tasks for the same type.
SQL:

SELECT name FROM products AS empl
WHERE id IN (
    SELECT id FROM tasks AS ord
    WHERE ord.type = empl.type
);


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

SELECT salary FROM projects AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS shp
    WHERE shp.id = emp.id
);


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

SELECT salary FROM orders AS empl
WHERE EXISTS (
    SELECT 1 FROM categories AS whs
    WHERE whs.level = empl.level
);


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

SELECT value FROM transactions AS catg
WHERE type IN (
    SELECT type FROM employees AS prod
    WHERE prod.id = catg.id
);


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

SELECT code FROM invoices AS lne
WHERE EXISTS (
    SELECT 1 FROM employees AS txn
    WHERE txn.type = lne.type
);


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

SELECT value FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM invoices AS lne
    WHERE lne.id = budg.id
);


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

SELECT value FROM warehouses AS inv
WHERE salary > (
    SELECT COUNT(salary) FROM categories AS emp
    WHERE emp.level = inv.level
);


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

SELECT salary FROM customers AS rgn
WHERE EXISTS (
    SELECT 1 FROM suppliers AS inv
    WHERE inv.status = rgn.status
);


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

SELECT amount FROM accounts AS budg
WHERE EXISTS (
    SELECT 1 FROM suppliers AS cust
    WHERE cust.code = budg.code
);


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

SELECT salary FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.status = cust.status
);


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

SELECT amount FROM projects AS inv
WHERE level IN (
    SELECT level FROM customers AS dept
    WHERE dept.id = inv.id
);


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

SELECT salary FROM accounts AS mgr
WHERE level IN (
    SELECT level FROM customers AS inv
    WHERE inv.code = mgr.code
);


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

SELECT amount FROM branches AS acct
WHERE type IN (
    SELECT type FROM accounts AS ord
    WHERE ord.status = acct.status
);


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

SELECT value FROM employees AS cust
WHERE EXISTS (
    SELECT 1 FROM regions AS emp
    WHERE emp.level = cust.level
);


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

SELECT code FROM employees AS schd
WHERE EXISTS (
    SELECT 1 FROM warehouses AS ord
    WHERE ord.level = schd.level
);


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

SELECT amount FROM warehouses AS mgr
WHERE id IN (
    SELECT id FROM departments AS ord
    WHERE ord.level = mgr.level
);


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

SELECT id FROM products AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS srvc
    WHERE srvc.code = whs.code
);


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

SELECT code FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM warehouses AS prod
    WHERE prod.id = empl.id
);


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

SELECT code FROM warehouses AS schd
WHERE type IN (
    SELECT type FROM accounts AS whs
    WHERE whs.level = schd.level
);


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

SELECT salary FROM regions AS empl
WHERE value > (
    SELECT AVG(amount) FROM projects AS dept
    WHERE dept.id = empl.id
);


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

SELECT amount FROM warehouses AS ord
WHERE id IN (
    SELECT id FROM invoices AS rgn
    WHERE rgn.code = ord.code
);


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

SELECT code FROM customers AS prod
WHERE amount > (
    SELECT COUNT(value) FROM employees AS lne
    WHERE lne.level = prod.level
);


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

SELECT value FROM accounts AS schd
WHERE type IN (
    SELECT type FROM orders AS mgr
    WHERE mgr.status = schd.status
);


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

SELECT value FROM departments AS emp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS txn
    WHERE txn.type = emp.type
);


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

SELECT value FROM departments AS txn
WHERE status IN (
    SELECT status FROM tasks AS schd
    WHERE schd.id = txn.id
);


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

SELECT salary FROM regions AS emp
WHERE code IN (
    SELECT code FROM shipments AS ord
    WHERE ord.type = emp.type
);


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

SELECT salary FROM suppliers AS catg
WHERE value > (
    SELECT AVG(value) FROM warehouses AS prod
    WHERE prod.code = catg.code
);


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

SELECT value FROM projects AS rgn
WHERE id IN (
    SELECT id FROM departments AS cust
    WHERE cust.type = rgn.type
);


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

SELECT code FROM transactions AS rgn
WHERE value > (
    SELECT COUNT(value) FROM categories AS ord
    WHERE ord.id = rgn.id
);


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

SELECT salary FROM suppliers AS mgr
WHERE value > (
    SELECT SUM(value) FROM warehouses AS dept
    WHERE dept.status = mgr.status
);


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

SELECT name FROM branches AS rgn
WHERE salary > (
    SELECT COUNT(amount) FROM customers AS budg
    WHERE budg.level = rgn.level
);


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

SELECT name FROM warehouses AS srvc
WHERE type IN (
    SELECT type FROM accounts AS cust
    WHERE cust.level = srvc.level
);


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

SELECT value FROM suppliers AS inv
WHERE level IN (
    SELECT level FROM orders AS schd
    WHERE schd.type = inv.type
);


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

SELECT code FROM customers AS mgr
WHERE amount > (
    SELECT AVG(amount) FROM regions AS srvc
    WHERE srvc.id = mgr.id
);


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

SELECT value FROM products AS mgr
WHERE salary > (
    SELECT MAX(salary) FROM categories AS dept
    WHERE dept.code = mgr.code
);


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

SELECT salary FROM customers AS sale
WHERE type IN (
    SELECT type FROM projects AS emp
    WHERE emp.level = sale.level
);


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

SELECT value FROM warehouses AS txn
WHERE salary > (
    SELECT MAX(value) FROM customers AS rgn
    WHERE rgn.type = txn.type
);


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

SELECT code FROM products AS acct
WHERE amount > (
    SELECT MAX(salary) FROM categories AS emp
    WHERE emp.type = acct.type
);


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

SELECT name FROM regions AS emp
WHERE salary > (
    SELECT AVG(salary) FROM projects AS catg
    WHERE catg.type = emp.type
);


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

SELECT amount FROM suppliers AS cust
WHERE code IN (
    SELECT code FROM accounts AS lne
    WHERE lne.level = cust.level
);


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

SELECT salary FROM categories AS shp
WHERE status IN (
    SELECT status FROM regions AS whs
    WHERE whs.type = shp.type
);


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

SELECT salary FROM orders AS txn
WHERE id IN (
    SELECT id FROM warehouses AS ord
    WHERE ord.type = txn.type
);


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

SELECT name FROM accounts AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS ord
    WHERE ord.level = shp.level
);


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

SELECT name FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.type = cust.type
);


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

SELECT code FROM departments AS srvc
WHERE amount > (
    SELECT COUNT(value) FROM invoices AS txn
    WHERE txn.code = srvc.code
);


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

SELECT amount FROM categories AS lne
WHERE salary > (
    SELECT COUNT(value) FROM invoices AS srvc
    WHERE srvc.code = lne.code
);


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

SELECT value FROM categories AS shp
WHERE salary > (
    SELECT SUM(value) FROM branches AS inv
    WHERE inv.status = shp.status
);


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

SELECT salary FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.id = inv.id
);


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

SELECT salary FROM suppliers AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS emp
    WHERE emp.type = srvc.type
);


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

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


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

SELECT value FROM shipments AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS budg
    WHERE budg.level = sale.level
);


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

SELECT value FROM orders AS rgn
WHERE type IN (
    SELECT type FROM customers AS inv
    WHERE inv.type = rgn.type
);


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

SELECT name FROM categories AS cust
WHERE type IN (
    SELECT type FROM invoices AS txn
    WHERE txn.id = cust.id
);


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

SELECT code FROM employees AS txn
WHERE EXISTS (
    SELECT 1 FROM projects AS dept
    WHERE dept.id = txn.id
);


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

SELECT value FROM departments AS whs
WHERE value > (
    SELECT SUM(salary) FROM projects AS budg
    WHERE budg.type = whs.type
);


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

SELECT value FROM products AS srvc
WHERE type IN (
    SELECT type FROM categories AS catg
    WHERE catg.status = srvc.status
);


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

SELECT id FROM products AS empl
WHERE level IN (
    SELECT level FROM orders AS emp
    WHERE emp.code = empl.code
);


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

SELECT id FROM warehouses AS rgn
WHERE id IN (
    SELECT id FROM branches AS prod
    WHERE prod.type = rgn.type
);


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

SELECT salary FROM tasks AS dept
WHERE EXISTS (
    SELECT 1 FROM regions AS inv
    WHERE inv.code = dept.code
);


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

SELECT amount FROM branches AS ord
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.level = ord.level
);


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

SELECT id FROM departments AS txn
WHERE code IN (
    SELECT code FROM shipments AS whs
    WHERE whs.status = txn.status
);


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

SELECT name FROM employees AS dept
WHERE value > (
    SELECT SUM(value) FROM branches AS empl
    WHERE empl.id = dept.id
);


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

SELECT name FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.code = mgr.code
);


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

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


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

SELECT name FROM accounts AS schd
WHERE EXISTS (
    SELECT 1 FROM invoices AS acct
    WHERE acct.status = schd.status
);


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

SELECT id FROM accounts AS ordr
WHERE id IN (
    SELECT id FROM products AS ord
    WHERE ord.type = ordr.type
);


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

SELECT value FROM accounts AS shp
WHERE id IN (
    SELECT id FROM products AS lne
    WHERE lne.status = shp.status
);


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

SELECT name FROM projects AS lne
WHERE status IN (
    SELECT status FROM branches AS schd
    WHERE schd.status = lne.status
);


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

SELECT id FROM tasks AS inv
WHERE EXISTS (
    SELECT 1 FROM invoices AS whs
    WHERE whs.code = inv.code
);


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

SELECT amount FROM orders AS cust
WHERE value > (
    SELECT AVG(salary) FROM accounts AS catg
    WHERE catg.type = cust.type
);


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

SELECT code FROM products AS schd
WHERE value > (
    SELECT AVG(value) FROM projects AS ordr
    WHERE ordr.code = schd.code
);


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

SELECT amount FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.id = catg.id
);


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

SELECT value FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS emp
    WHERE emp.status = prod.status
);


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

SELECT amount FROM customers AS ord
WHERE EXISTS (
    SELECT 1 FROM regions AS cust
    WHERE cust.id = ord.id
);


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

SELECT value FROM invoices AS whs
WHERE EXISTS (
    SELECT 1 FROM branches AS lne
    WHERE lne.id = whs.id
);


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

SELECT code FROM categories AS empl
WHERE EXISTS (
    SELECT 1 FROM suppliers AS catg
    WHERE catg.code = empl.code
);


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

SELECT name FROM customers AS lne
WHERE value > (
    SELECT SUM(salary) FROM departments AS prod
    WHERE prod.id = lne.id
);


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

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


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

SELECT value FROM products AS srvc
WHERE id IN (
    SELECT id FROM employees AS budg
    WHERE budg.level = srvc.level
);


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

SELECT code FROM transactions AS schd
WHERE value > (
    SELECT COUNT(salary) FROM branches AS catg
    WHERE catg.status = schd.status
);


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

SELECT id FROM employees AS rgn
WHERE id IN (
    SELECT id FROM products AS emp
    WHERE emp.type = rgn.type
);


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

SELECT id FROM tasks AS ordr
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.level = ordr.level
);


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

SELECT id FROM categories AS shp
WHERE level IN (
    SELECT level FROM suppliers AS ordr
    WHERE ordr.code = shp.code
);


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

SELECT salary FROM projects AS prod
WHERE status IN (
    SELECT status FROM shipments AS emp
    WHERE emp.code = prod.code
);


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

SELECT salary FROM invoices AS rgn
WHERE value > (
    SELECT MAX(amount) FROM employees AS srvc
    WHERE srvc.code = rgn.code
);


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

SELECT id FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.status = acct.status
);


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

SELECT name FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.code = cust.code
);


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

SELECT name FROM branches AS empl
WHERE EXISTS (
    SELECT 1 FROM invoices AS ordr
    WHERE ordr.type = empl.type
);


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

SELECT amount FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM transactions AS schd
    WHERE schd.level = cust.level
);


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

SELECT id FROM warehouses AS rgn
WHERE id IN (
    SELECT id FROM orders AS dept
    WHERE dept.status = rgn.status
);


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

SELECT value FROM regions AS dept
WHERE salary > (
    SELECT COUNT(salary) FROM suppliers AS ordr
    WHERE ordr.status = dept.status
);


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

SELECT salary FROM suppliers AS catg
WHERE amount > (
    SELECT SUM(value) FROM transactions AS whs
    WHERE whs.id = catg.id
);


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

SELECT salary FROM employees AS rgn
WHERE code IN (
    SELECT code FROM shipments AS inv
    WHERE inv.level = rgn.level
);


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

SELECT amount FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM tasks AS catg
    WHERE catg.code = cust.code
);


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

SELECT value FROM projects AS sale
WHERE salary > (
    SELECT MAX(salary) FROM departments AS emp
    WHERE emp.code = sale.code
);


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

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


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

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


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

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


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

SELECT value FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.id = ord.id
);


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

SELECT salary FROM regions AS ord
WHERE amount > (
    SELECT AVG(salary) FROM projects AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT salary FROM products AS ord
WHERE EXISTS (
    SELECT 1 FROM orders AS sale
    WHERE sale.type = ord.type
);


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

SELECT value FROM employees AS ord
WHERE level IN (
    SELECT level FROM categories AS srvc
    WHERE srvc.type = ord.type
);


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

SELECT name FROM accounts AS shp
WHERE type IN (
    SELECT type FROM tasks AS txn
    WHERE txn.code = shp.code
);


Prompt:
Schema:
  regions (alias: catg)(id, salary, code, level)
  projects(level, id, date, code)
Task: Select salary from regions where id exists in projects for the same code.
SQL:

SELECT salary FROM regions AS catg
WHERE id IN (
    SELECT id FROM projects AS emp
    WHERE emp.code = catg.code
);


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

SELECT amount FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM employees AS sale
    WHERE sale.id = mgr.id
);


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

SELECT amount FROM warehouses AS catg
WHERE amount > (
    SELECT MAX(salary) FROM invoices AS sale
    WHERE sale.status = catg.status
);


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

SELECT amount FROM branches AS sale
WHERE level IN (
    SELECT level FROM categories AS cust
    WHERE cust.code = sale.code
);


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

SELECT id FROM customers AS inv
WHERE id IN (
    SELECT id FROM branches AS acct
    WHERE acct.level = inv.level
);


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

SELECT code FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.level = empl.level
);


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

SELECT value FROM employees AS empl
WHERE value > (
    SELECT MIN(salary) FROM orders AS acct
    WHERE acct.level = empl.level
);


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

SELECT name FROM projects AS srvc
WHERE amount > (
    SELECT COUNT(amount) FROM departments AS catg
    WHERE catg.code = srvc.code
);


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

SELECT name FROM shipments AS txn
WHERE value > (
    SELECT MIN(amount) FROM regions AS rgn
    WHERE rgn.status = txn.status
);


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

SELECT value FROM customers AS acct
WHERE status IN (
    SELECT status FROM suppliers AS sale
    WHERE sale.status = acct.status
);


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

SELECT code FROM invoices AS txn
WHERE type IN (
    SELECT type FROM employees AS cust
    WHERE cust.status = txn.status
);


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

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


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

SELECT amount FROM invoices AS mgr
WHERE amount > (
    SELECT COUNT(value) FROM customers AS ordr
    WHERE ordr.type = mgr.type
);


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

SELECT id FROM projects AS cust
WHERE id IN (
    SELECT id FROM warehouses AS shp
    WHERE shp.type = cust.type
);


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

SELECT amount FROM invoices AS prod
WHERE type IN (
    SELECT type FROM shipments AS dept
    WHERE dept.level = prod.level
);


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

SELECT amount FROM tasks AS lne
WHERE code IN (
    SELECT code FROM transactions AS shp
    WHERE shp.level = lne.level
);


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

SELECT value FROM tasks AS sale
WHERE level IN (
    SELECT level FROM categories AS schd
    WHERE schd.code = sale.code
);


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

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


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

SELECT salary FROM transactions AS ord
WHERE value > (
    SELECT COUNT(salary) FROM projects AS sale
    WHERE sale.code = ord.code
);


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

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


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

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


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

SELECT name FROM accounts AS emp
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.type = emp.type
);


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

SELECT amount FROM invoices AS budg
WHERE id IN (
    SELECT id FROM products AS emp
    WHERE emp.id = budg.id
);


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

SELECT code FROM transactions AS lne
WHERE amount > (
    SELECT AVG(amount) FROM products AS sale
    WHERE sale.id = lne.id
);


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

SELECT amount FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM shipments AS ord
    WHERE ord.type = whs.type
);


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

SELECT code FROM invoices AS txn
WHERE EXISTS (
    SELECT 1 FROM branches AS dept
    WHERE dept.level = txn.level
);


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

SELECT code FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM transactions AS catg
    WHERE catg.status = empl.status
);


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

SELECT name FROM employees AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS empl
    WHERE empl.id = mgr.id
);


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

SELECT amount FROM projects AS acct
WHERE salary > (
    SELECT MAX(amount) FROM products AS emp
    WHERE emp.type = acct.type
);


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

SELECT id FROM accounts AS shp
WHERE code IN (
    SELECT code FROM suppliers AS cust
    WHERE cust.type = shp.type
);


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

SELECT name FROM accounts AS schd
WHERE value > (
    SELECT SUM(amount) FROM projects AS shp
    WHERE shp.status = schd.status
);


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

SELECT value FROM invoices AS acct
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.code = acct.code
);


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

SELECT value FROM warehouses AS txn
WHERE level IN (
    SELECT level FROM projects AS sale
    WHERE sale.level = txn.level
);


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

SELECT amount FROM departments AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS txn
    WHERE txn.status = schd.status
);


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

SELECT code FROM regions AS mgr
WHERE EXISTS (
    SELECT 1 FROM departments AS schd
    WHERE schd.status = mgr.status
);


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

SELECT code FROM branches AS shp
WHERE value > (
    SELECT MAX(salary) FROM tasks AS txn
    WHERE txn.level = shp.level
);


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

SELECT value FROM categories AS acct
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.id = acct.id
);


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

SELECT name FROM invoices AS sale
WHERE EXISTS (
    SELECT 1 FROM accounts AS empl
    WHERE empl.id = sale.id
);


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

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


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

SELECT id FROM customers AS ordr
WHERE amount > (
    SELECT SUM(salary) FROM orders AS dept
    WHERE dept.id = ordr.id
);


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

SELECT value FROM products AS txn
WHERE id IN (
    SELECT id FROM invoices AS rgn
    WHERE rgn.level = txn.level
);


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

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


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

SELECT id FROM categories AS ord
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.id = ord.id
);


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

SELECT salary FROM invoices AS catg
WHERE EXISTS (
    SELECT 1 FROM branches AS sale
    WHERE sale.code = catg.code
);


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

SELECT salary FROM departments AS cust
WHERE value > (
    SELECT COUNT(salary) FROM transactions AS txn
    WHERE txn.level = cust.level
);


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

SELECT id FROM projects AS dept
WHERE salary > (
    SELECT MAX(salary) FROM products AS schd
    WHERE schd.status = dept.status
);


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

SELECT name FROM products AS shp
WHERE EXISTS (
    SELECT 1 FROM suppliers AS empl
    WHERE empl.type = shp.type
);


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

SELECT value FROM warehouses AS ordr
WHERE status IN (
    SELECT status FROM tasks AS schd
    WHERE schd.type = ordr.type
);


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

SELECT code FROM suppliers AS txn
WHERE EXISTS (
    SELECT 1 FROM tasks AS budg
    WHERE budg.code = txn.code
);


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

SELECT id FROM suppliers AS sale
WHERE status IN (
    SELECT status FROM warehouses AS budg
    WHERE budg.type = sale.type
);


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

SELECT id FROM warehouses AS inv
WHERE value > (
    SELECT COUNT(value) FROM employees AS ord
    WHERE ord.status = inv.status
);


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

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


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

SELECT amount FROM customers AS inv
WHERE EXISTS (
    SELECT 1 FROM shipments AS prod
    WHERE prod.level = inv.level
);


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

SELECT name FROM tasks AS catg
WHERE type IN (
    SELECT type FROM shipments AS prod
    WHERE prod.type = catg.type
);


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

SELECT salary FROM tasks AS sale
WHERE status IN (
    SELECT status FROM warehouses AS schd
    WHERE schd.type = sale.type
);


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

SELECT id FROM suppliers AS whs
WHERE type IN (
    SELECT type FROM shipments AS prod
    WHERE prod.status = whs.status
);


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

SELECT code FROM warehouses AS shp
WHERE EXISTS (
    SELECT 1 FROM accounts AS catg
    WHERE catg.code = shp.code
);


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

SELECT value FROM employees AS schd
WHERE code IN (
    SELECT code FROM projects AS mgr
    WHERE mgr.type = schd.type
);


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

SELECT salary FROM categories AS shp
WHERE status IN (
    SELECT status FROM shipments AS txn
    WHERE txn.id = shp.id
);


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

SELECT id FROM suppliers AS sale
WHERE value > (
    SELECT AVG(value) FROM departments AS cust
    WHERE cust.id = sale.id
);