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

SELECT salary FROM shipments AS whs
WHERE id IN (
    SELECT id FROM accounts AS cust
    WHERE cust.status = whs.status
);


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

SELECT id FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM products AS catg
    WHERE catg.level = cust.level
);


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

SELECT name FROM departments AS lne
WHERE code IN (
    SELECT code FROM products AS whs
    WHERE whs.level = lne.level
);


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

SELECT salary FROM branches AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS inv
    WHERE inv.type = schd.type
);


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

SELECT amount FROM transactions AS mgr
WHERE salary > (
    SELECT COUNT(value) FROM accounts AS schd
    WHERE schd.id = mgr.id
);


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

SELECT amount FROM transactions AS rgn
WHERE EXISTS (
    SELECT 1 FROM shipments AS emp
    WHERE emp.level = rgn.level
);


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

SELECT id FROM transactions AS ordr
WHERE EXISTS (
    SELECT 1 FROM employees AS ord
    WHERE ord.status = ordr.status
);


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

SELECT amount FROM products AS acct
WHERE value > (
    SELECT MIN(value) FROM regions AS whs
    WHERE whs.status = acct.status
);


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

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


Prompt:
Schema:
  accounts (alias: txn)(salary, type, value, name)
  products(salary, name, level, value)
Task: Retrieve name from accounts with amount above the MAX(salary) of products rows sharing the same level.
SQL:

SELECT name FROM accounts AS txn
WHERE amount > (
    SELECT MAX(salary) FROM products AS acct
    WHERE acct.level = txn.level
);


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

SELECT id FROM branches AS cust
WHERE EXISTS (
    SELECT 1 FROM employees AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT code FROM branches AS budg
WHERE EXISTS (
    SELECT 1 FROM regions AS ord
    WHERE ord.code = budg.code
);


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

SELECT amount FROM tasks AS empl
WHERE code IN (
    SELECT code FROM orders AS shp
    WHERE shp.type = empl.type
);


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

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


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

SELECT amount FROM products AS empl
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.status = empl.status
);


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

SELECT name FROM orders AS prod
WHERE amount > (
    SELECT SUM(salary) FROM branches AS schd
    WHERE schd.code = prod.code
);


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

SELECT amount FROM shipments AS shp
WHERE value > (
    SELECT SUM(value) FROM customers AS schd
    WHERE schd.id = shp.id
);


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

SELECT name FROM categories AS dept
WHERE amount > (
    SELECT SUM(amount) FROM tasks AS schd
    WHERE schd.id = dept.id
);


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

SELECT id FROM transactions AS shp
WHERE value > (
    SELECT MIN(salary) FROM customers AS inv
    WHERE inv.status = shp.status
);


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

SELECT code FROM employees AS prod
WHERE EXISTS (
    SELECT 1 FROM branches AS inv
    WHERE inv.status = prod.status
);


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

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


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

SELECT salary FROM accounts AS acct
WHERE type IN (
    SELECT type FROM shipments AS lne
    WHERE lne.status = acct.status
);


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

SELECT name FROM tasks AS ord
WHERE code IN (
    SELECT code FROM invoices AS acct
    WHERE acct.code = ord.code
);


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

SELECT name FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS empl
    WHERE empl.code = whs.code
);


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

SELECT id FROM regions AS sale
WHERE value > (
    SELECT AVG(value) FROM categories AS empl
    WHERE empl.status = sale.status
);


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

SELECT id FROM categories AS cust
WHERE status IN (
    SELECT status FROM branches AS prod
    WHERE prod.level = cust.level
);


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

SELECT salary FROM customers AS schd
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.code = schd.code
);


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

SELECT amount FROM accounts AS ordr
WHERE EXISTS (
    SELECT 1 FROM departments AS sale
    WHERE sale.id = ordr.id
);


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

SELECT name FROM categories AS emp
WHERE salary > (
    SELECT COUNT(value) FROM warehouses AS whs
    WHERE whs.code = emp.code
);


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

SELECT code FROM projects AS catg
WHERE amount > (
    SELECT COUNT(value) FROM customers AS schd
    WHERE schd.status = catg.status
);


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

SELECT salary FROM products AS ordr
WHERE type IN (
    SELECT type FROM shipments AS rgn
    WHERE rgn.code = ordr.code
);


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

SELECT name FROM shipments AS inv
WHERE status IN (
    SELECT status FROM branches AS shp
    WHERE shp.id = inv.id
);


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

SELECT value FROM employees AS whs
WHERE amount > (
    SELECT MAX(salary) FROM transactions AS rgn
    WHERE rgn.status = whs.status
);


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

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


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

SELECT code FROM branches AS mgr
WHERE salary > (
    SELECT AVG(amount) FROM tasks AS sale
    WHERE sale.id = mgr.id
);


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

SELECT salary FROM suppliers AS mgr
WHERE level IN (
    SELECT level FROM categories AS prod
    WHERE prod.id = mgr.id
);


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

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


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

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


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

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


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

SELECT salary FROM transactions AS emp
WHERE salary > (
    SELECT COUNT(amount) FROM employees AS inv
    WHERE inv.status = emp.status
);


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

SELECT salary FROM orders AS mgr
WHERE EXISTS (
    SELECT 1 FROM branches AS shp
    WHERE shp.level = mgr.level
);


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

SELECT amount FROM invoices AS mgr
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.id = mgr.id
);


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

SELECT code FROM customers AS budg
WHERE id IN (
    SELECT id FROM shipments AS dept
    WHERE dept.level = budg.level
);


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

SELECT code FROM accounts AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS budg
    WHERE budg.status = srvc.status
);


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

SELECT salary FROM customers AS prod
WHERE EXISTS (
    SELECT 1 FROM warehouses AS srvc
    WHERE srvc.id = prod.id
);


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

SELECT amount FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM departments AS shp
    WHERE shp.type = prod.type
);


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

SELECT value FROM shipments AS ordr
WHERE status IN (
    SELECT status FROM projects AS lne
    WHERE lne.type = ordr.type
);


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

SELECT salary FROM tasks AS srvc
WHERE id IN (
    SELECT id FROM suppliers AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT name FROM warehouses AS srvc
WHERE EXISTS (
    SELECT 1 FROM products AS empl
    WHERE empl.type = srvc.type
);


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

SELECT value FROM orders AS sale
WHERE status IN (
    SELECT status FROM products AS empl
    WHERE empl.id = sale.id
);


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

SELECT salary FROM invoices AS srvc
WHERE code IN (
    SELECT code FROM categories AS inv
    WHERE inv.code = srvc.code
);


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

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


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

SELECT amount FROM accounts AS prod
WHERE status IN (
    SELECT status FROM products AS shp
    WHERE shp.type = prod.type
);


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

SELECT id FROM warehouses AS ord
WHERE value > (
    SELECT AVG(amount) FROM invoices AS cust
    WHERE cust.type = ord.type
);


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

SELECT salary FROM customers AS prod
WHERE code IN (
    SELECT code FROM employees AS sale
    WHERE sale.level = prod.level
);


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

SELECT salary FROM tasks AS whs
WHERE EXISTS (
    SELECT 1 FROM projects AS cust
    WHERE cust.status = whs.status
);


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

SELECT salary FROM products AS inv
WHERE salary > (
    SELECT SUM(amount) FROM invoices AS ordr
    WHERE ordr.type = inv.type
);


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

SELECT id FROM orders AS acct
WHERE EXISTS (
    SELECT 1 FROM categories AS budg
    WHERE budg.code = acct.code
);


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

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


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

SELECT amount FROM warehouses AS ord
WHERE status IN (
    SELECT status FROM suppliers AS dept
    WHERE dept.level = ord.level
);


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

SELECT salary FROM warehouses AS rgn
WHERE EXISTS (
    SELECT 1 FROM transactions AS prod
    WHERE prod.code = rgn.code
);


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

SELECT name FROM employees AS srvc
WHERE EXISTS (
    SELECT 1 FROM departments AS dept
    WHERE dept.id = srvc.id
);


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

SELECT id FROM projects AS budg
WHERE code IN (
    SELECT code FROM categories AS lne
    WHERE lne.level = budg.level
);


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

SELECT value FROM categories AS ordr
WHERE status IN (
    SELECT status FROM regions AS srvc
    WHERE srvc.level = ordr.level
);


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

SELECT salary FROM categories AS acct
WHERE amount > (
    SELECT AVG(salary) FROM products AS rgn
    WHERE rgn.status = acct.status
);


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

SELECT name FROM departments AS schd
WHERE amount > (
    SELECT COUNT(salary) FROM orders AS inv
    WHERE inv.id = schd.id
);


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

SELECT amount FROM departments AS inv
WHERE EXISTS (
    SELECT 1 FROM regions AS budg
    WHERE budg.code = inv.code
);


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

SELECT value FROM accounts AS srvc
WHERE status IN (
    SELECT status FROM shipments AS schd
    WHERE schd.type = srvc.type
);


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

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


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

SELECT amount FROM customers AS srvc
WHERE EXISTS (
    SELECT 1 FROM branches AS rgn
    WHERE rgn.code = srvc.code
);


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

SELECT code FROM employees AS acct
WHERE status IN (
    SELECT status FROM warehouses AS ordr
    WHERE ordr.id = acct.id
);


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

SELECT id FROM branches AS mgr
WHERE salary > (
    SELECT COUNT(amount) FROM transactions AS schd
    WHERE schd.code = mgr.code
);


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

SELECT code FROM departments AS mgr
WHERE EXISTS (
    SELECT 1 FROM warehouses AS catg
    WHERE catg.level = mgr.level
);


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

SELECT amount FROM categories AS srvc
WHERE type IN (
    SELECT type FROM invoices AS lne
    WHERE lne.type = srvc.type
);


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

SELECT id FROM invoices AS acct
WHERE amount > (
    SELECT COUNT(amount) FROM employees AS cust
    WHERE cust.code = acct.code
);


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

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


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

SELECT amount FROM employees AS inv
WHERE value > (
    SELECT SUM(value) FROM warehouses AS sale
    WHERE sale.id = inv.id
);


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

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


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

SELECT name FROM suppliers AS empl
WHERE type IN (
    SELECT type FROM warehouses AS mgr
    WHERE mgr.type = empl.type
);


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

SELECT name FROM orders AS sale
WHERE code IN (
    SELECT code FROM employees AS emp
    WHERE emp.code = sale.code
);


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

SELECT salary FROM projects AS rgn
WHERE status IN (
    SELECT status FROM categories AS schd
    WHERE schd.status = rgn.status
);


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

SELECT salary FROM orders AS whs
WHERE EXISTS (
    SELECT 1 FROM employees AS budg
    WHERE budg.status = whs.status
);


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

SELECT name FROM shipments AS budg
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.code = budg.code
);


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

SELECT amount FROM tasks AS ord
WHERE code IN (
    SELECT code FROM orders AS lne
    WHERE lne.level = ord.level
);


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

SELECT salary FROM projects AS txn
WHERE id IN (
    SELECT id FROM warehouses AS inv
    WHERE inv.id = txn.id
);


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

SELECT salary FROM employees AS whs
WHERE status IN (
    SELECT status FROM projects AS empl
    WHERE empl.type = whs.type
);


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

SELECT value FROM branches AS ordr
WHERE amount > (
    SELECT SUM(value) FROM orders AS catg
    WHERE catg.code = ordr.code
);


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

SELECT value FROM suppliers AS ordr
WHERE salary > (
    SELECT SUM(value) FROM products AS budg
    WHERE budg.level = ordr.level
);


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

SELECT name FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS srvc
    WHERE srvc.type = mgr.type
);


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

SELECT code FROM employees AS emp
WHERE EXISTS (
    SELECT 1 FROM branches AS catg
    WHERE catg.type = emp.type
);


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

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


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

SELECT code FROM projects AS acct
WHERE amount > (
    SELECT AVG(value) FROM invoices AS emp
    WHERE emp.status = acct.status
);


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

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


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

SELECT value FROM suppliers AS srvc
WHERE value > (
    SELECT AVG(amount) FROM categories AS mgr
    WHERE mgr.code = srvc.code
);


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

SELECT id FROM departments AS dept
WHERE EXISTS (
    SELECT 1 FROM invoices AS budg
    WHERE budg.type = dept.type
);


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

SELECT id FROM transactions AS emp
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.level = emp.level
);


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

SELECT code FROM products AS rgn
WHERE salary > (
    SELECT MAX(salary) FROM tasks AS cust
    WHERE cust.status = rgn.status
);


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

SELECT value FROM transactions AS empl
WHERE code IN (
    SELECT code FROM products AS shp
    WHERE shp.code = empl.code
);


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

SELECT value FROM warehouses AS sale
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.id = sale.id
);


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

SELECT id FROM branches AS sale
WHERE amount > (
    SELECT COUNT(amount) FROM suppliers AS empl
    WHERE empl.type = sale.type
);


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

SELECT amount FROM invoices AS inv
WHERE amount > (
    SELECT COUNT(amount) FROM products AS acct
    WHERE acct.level = inv.level
);


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

SELECT amount FROM employees AS sale
WHERE type IN (
    SELECT type FROM projects AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT id FROM shipments AS shp
WHERE amount > (
    SELECT MIN(amount) FROM products AS ordr
    WHERE ordr.level = shp.level
);


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

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


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

SELECT code FROM shipments AS budg
WHERE type IN (
    SELECT type FROM departments AS ordr
    WHERE ordr.level = budg.level
);


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

SELECT name FROM categories AS lne
WHERE EXISTS (
    SELECT 1 FROM accounts AS mgr
    WHERE mgr.level = lne.level
);


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

SELECT amount FROM shipments AS inv
WHERE amount > (
    SELECT MIN(salary) FROM warehouses AS catg
    WHERE catg.status = inv.status
);


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

SELECT value FROM branches AS rgn
WHERE value > (
    SELECT MAX(salary) FROM transactions AS catg
    WHERE catg.status = rgn.status
);


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

SELECT name FROM accounts AS inv
WHERE salary > (
    SELECT SUM(amount) FROM shipments AS catg
    WHERE catg.id = inv.id
);


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

SELECT value FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM customers AS ordr
    WHERE ordr.status = cust.status
);


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

SELECT amount FROM departments AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS txn
    WHERE txn.id = acct.id
);


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

SELECT value FROM employees AS ordr
WHERE value > (
    SELECT MIN(value) FROM orders AS cust
    WHERE cust.level = ordr.level
);


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

SELECT name FROM suppliers AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS schd
    WHERE schd.status = cust.status
);


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

SELECT id FROM employees AS dept
WHERE level IN (
    SELECT level FROM branches AS mgr
    WHERE mgr.status = dept.status
);


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

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


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

SELECT id FROM transactions AS emp
WHERE code IN (
    SELECT code FROM products AS lne
    WHERE lne.code = emp.code
);


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

SELECT amount FROM suppliers AS inv
WHERE status IN (
    SELECT status FROM employees AS catg
    WHERE catg.id = inv.id
);


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

SELECT name FROM employees AS lne
WHERE salary > (
    SELECT COUNT(salary) FROM accounts AS mgr
    WHERE mgr.status = lne.status
);


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

SELECT value FROM customers AS cust
WHERE EXISTS (
    SELECT 1 FROM projects AS sale
    WHERE sale.status = cust.status
);


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

SELECT amount FROM branches AS mgr
WHERE type IN (
    SELECT type FROM transactions AS srvc
    WHERE srvc.status = mgr.status
);


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

SELECT code FROM regions AS shp
WHERE EXISTS (
    SELECT 1 FROM customers AS sale
    WHERE sale.code = shp.code
);


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

SELECT salary FROM orders AS dept
WHERE amount > (
    SELECT AVG(amount) FROM employees AS sale
    WHERE sale.status = dept.status
);


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

SELECT code FROM warehouses AS catg
WHERE EXISTS (
    SELECT 1 FROM transactions AS ordr
    WHERE ordr.status = catg.status
);


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

SELECT salary FROM customers AS acct
WHERE EXISTS (
    SELECT 1 FROM shipments AS whs
    WHERE whs.status = acct.status
);


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

SELECT code FROM shipments AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.id = empl.id
);


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

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


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

SELECT value FROM orders AS prod
WHERE EXISTS (
    SELECT 1 FROM transactions AS rgn
    WHERE rgn.status = prod.status
);


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

SELECT name FROM accounts AS cust
WHERE EXISTS (
    SELECT 1 FROM departments AS ord
    WHERE ord.level = cust.level
);


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

SELECT code FROM transactions AS schd
WHERE EXISTS (
    SELECT 1 FROM tasks AS empl
    WHERE empl.level = schd.level
);


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

SELECT salary FROM regions AS txn
WHERE type IN (
    SELECT type FROM shipments AS catg
    WHERE catg.type = txn.type
);


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

SELECT salary FROM accounts AS whs
WHERE value > (
    SELECT MIN(value) FROM categories AS sale
    WHERE sale.type = whs.type
);


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

SELECT code FROM employees AS empl
WHERE level IN (
    SELECT level FROM customers AS dept
    WHERE dept.id = empl.id
);


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

SELECT value FROM suppliers AS emp
WHERE salary > (
    SELECT MIN(amount) FROM orders AS catg
    WHERE catg.id = emp.id
);


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

SELECT amount FROM warehouses AS lne
WHERE status IN (
    SELECT status FROM categories AS txn
    WHERE txn.level = lne.level
);


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

SELECT value FROM suppliers AS shp
WHERE value > (
    SELECT MIN(salary) FROM shipments AS cust
    WHERE cust.status = shp.status
);


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

SELECT code FROM regions AS empl
WHERE code IN (
    SELECT code FROM branches AS cust
    WHERE cust.id = empl.id
);


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

SELECT name FROM accounts AS srvc
WHERE code IN (
    SELECT code FROM departments AS prod
    WHERE prod.code = srvc.code
);


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

SELECT name FROM regions AS srvc
WHERE type IN (
    SELECT type FROM branches AS inv
    WHERE inv.status = srvc.status
);


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

SELECT value FROM invoices AS catg
WHERE amount > (
    SELECT SUM(salary) FROM customers AS rgn
    WHERE rgn.level = catg.level
);


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

SELECT value FROM projects AS srvc
WHERE amount > (
    SELECT COUNT(salary) FROM suppliers AS acct
    WHERE acct.level = srvc.level
);


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

SELECT name FROM suppliers AS catg
WHERE EXISTS (
    SELECT 1 FROM projects AS schd
    WHERE schd.level = catg.level
);


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

SELECT code FROM branches AS catg
WHERE type IN (
    SELECT type FROM categories AS cust
    WHERE cust.status = catg.status
);


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

SELECT salary FROM departments AS empl
WHERE level IN (
    SELECT level FROM tasks AS txn
    WHERE txn.code = empl.code
);


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

SELECT salary FROM products AS prod
WHERE EXISTS (
    SELECT 1 FROM regions AS txn
    WHERE txn.code = prod.code
);


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

SELECT salary FROM employees AS rgn
WHERE salary > (
    SELECT SUM(amount) FROM orders AS acct
    WHERE acct.level = rgn.level
);


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

SELECT amount FROM accounts AS dept
WHERE EXISTS (
    SELECT 1 FROM departments AS cust
    WHERE cust.id = dept.id
);


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

SELECT name FROM customers AS budg
WHERE salary > (
    SELECT MIN(value) FROM orders AS txn
    WHERE txn.code = budg.code
);


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

SELECT id FROM accounts AS catg
WHERE value > (
    SELECT MAX(amount) FROM products AS ordr
    WHERE ordr.level = catg.level
);


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

SELECT amount FROM products AS emp
WHERE EXISTS (
    SELECT 1 FROM shipments AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT id FROM suppliers AS budg
WHERE EXISTS (
    SELECT 1 FROM tasks AS schd
    WHERE schd.level = budg.level
);


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

SELECT value FROM projects AS budg
WHERE salary > (
    SELECT COUNT(value) FROM employees AS dept
    WHERE dept.type = budg.type
);


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

SELECT code FROM shipments AS whs
WHERE EXISTS (
    SELECT 1 FROM accounts AS sale
    WHERE sale.level = whs.level
);


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

SELECT id FROM projects AS empl
WHERE EXISTS (
    SELECT 1 FROM tasks AS emp
    WHERE emp.type = empl.type
);


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

SELECT salary FROM suppliers AS dept
WHERE EXISTS (
    SELECT 1 FROM orders AS srvc
    WHERE srvc.level = dept.level
);


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

SELECT id FROM tasks AS sale
WHERE EXISTS (
    SELECT 1 FROM products AS mgr
    WHERE mgr.level = sale.level
);


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

SELECT name FROM projects AS mgr
WHERE id IN (
    SELECT id FROM tasks AS srvc
    WHERE srvc.status = mgr.status
);


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

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


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

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


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

SELECT code FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM warehouses AS emp
    WHERE emp.status = cust.status
);


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

SELECT value FROM customers AS empl
WHERE salary > (
    SELECT SUM(amount) FROM orders AS rgn
    WHERE rgn.code = empl.code
);


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

SELECT name FROM tasks AS empl
WHERE EXISTS (
    SELECT 1 FROM products AS sale
    WHERE sale.id = empl.id
);


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

SELECT salary FROM shipments AS txn
WHERE status IN (
    SELECT status FROM invoices AS mgr
    WHERE mgr.type = txn.type
);


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

SELECT value FROM regions AS cust
WHERE level IN (
    SELECT level FROM transactions AS rgn
    WHERE rgn.id = cust.id
);


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

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


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

SELECT amount FROM employees AS dept
WHERE id IN (
    SELECT id FROM shipments AS shp
    WHERE shp.code = dept.code
);


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

SELECT code FROM tasks AS rgn
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.level = rgn.level
);


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

SELECT amount FROM invoices AS cust
WHERE type IN (
    SELECT type FROM employees AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT name FROM regions AS shp
WHERE code IN (
    SELECT code FROM orders AS budg
    WHERE budg.code = shp.code
);


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

SELECT value FROM shipments AS whs
WHERE type IN (
    SELECT type FROM branches AS inv
    WHERE inv.id = whs.id
);


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

SELECT id FROM invoices AS ordr
WHERE type IN (
    SELECT type FROM projects AS catg
    WHERE catg.id = ordr.id
);


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

SELECT amount FROM employees AS prod
WHERE id IN (
    SELECT id FROM departments AS mgr
    WHERE mgr.level = prod.level
);


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

SELECT salary FROM suppliers AS ord
WHERE EXISTS (
    SELECT 1 FROM accounts AS emp
    WHERE emp.type = ord.type
);


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

SELECT code FROM accounts AS dept
WHERE id IN (
    SELECT id FROM departments AS shp
    WHERE shp.code = dept.code
);


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

SELECT salary FROM categories AS emp
WHERE amount > (
    SELECT MIN(value) FROM shipments AS dept
    WHERE dept.code = emp.code
);


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

SELECT name FROM orders AS acct
WHERE level IN (
    SELECT level FROM departments AS schd
    WHERE schd.level = acct.level
);


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

SELECT value FROM customers AS catg
WHERE id IN (
    SELECT id FROM regions AS dept
    WHERE dept.level = catg.level
);


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

SELECT value FROM tasks AS ord
WHERE EXISTS (
    SELECT 1 FROM customers AS inv
    WHERE inv.code = ord.code
);


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

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


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

SELECT name FROM tasks AS dept
WHERE code IN (
    SELECT code FROM warehouses AS ord
    WHERE ord.level = dept.level
);


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

SELECT value FROM regions AS dept
WHERE value > (
    SELECT MIN(amount) FROM shipments AS srvc
    WHERE srvc.type = dept.type
);


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

SELECT name FROM products AS sale
WHERE value > (
    SELECT MAX(value) FROM departments AS schd
    WHERE schd.level = sale.level
);


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

SELECT name FROM orders AS emp
WHERE level IN (
    SELECT level FROM departments AS empl
    WHERE empl.status = emp.status
);


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

SELECT name FROM customers AS empl
WHERE amount > (
    SELECT MIN(salary) FROM invoices AS txn
    WHERE txn.code = empl.code
);


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

SELECT code FROM projects AS inv
WHERE status IN (
    SELECT status FROM employees AS prod
    WHERE prod.status = inv.status
);


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

SELECT id FROM warehouses AS ordr
WHERE amount > (
    SELECT COUNT(salary) FROM categories AS emp
    WHERE emp.id = ordr.id
);


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

SELECT value FROM transactions AS whs
WHERE level IN (
    SELECT level FROM orders AS rgn
    WHERE rgn.status = whs.status
);


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

SELECT name FROM branches AS whs
WHERE amount > (
    SELECT COUNT(value) FROM employees AS dept
    WHERE dept.code = whs.code
);


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

SELECT salary FROM warehouses AS schd
WHERE EXISTS (
    SELECT 1 FROM orders AS empl
    WHERE empl.id = schd.id
);


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

SELECT amount FROM accounts AS rgn
WHERE salary > (
    SELECT COUNT(salary) FROM tasks AS acct
    WHERE acct.code = rgn.code
);


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

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


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

SELECT value FROM transactions AS emp
WHERE level IN (
    SELECT level FROM projects AS cust
    WHERE cust.status = emp.status
);


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

SELECT amount FROM products AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS rgn
    WHERE rgn.code = acct.code
);


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

SELECT value FROM regions AS whs
WHERE id IN (
    SELECT id FROM tasks AS catg
    WHERE catg.type = whs.type
);


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

SELECT amount FROM customers AS budg
WHERE status IN (
    SELECT status FROM warehouses AS cust
    WHERE cust.status = budg.status
);


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

SELECT name FROM employees AS cust
WHERE id IN (
    SELECT id FROM orders AS rgn
    WHERE rgn.level = cust.level
);


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

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


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

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


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

SELECT amount FROM shipments AS sale
WHERE value > (
    SELECT AVG(salary) FROM accounts AS emp
    WHERE emp.level = sale.level
);


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

SELECT name FROM regions AS shp
WHERE level IN (
    SELECT level FROM transactions AS prod
    WHERE prod.code = shp.code
);


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

SELECT amount FROM products AS whs
WHERE status IN (
    SELECT status FROM categories AS empl
    WHERE empl.level = whs.level
);


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

SELECT value FROM branches AS cust
WHERE type IN (
    SELECT type FROM regions AS ord
    WHERE ord.id = cust.id
);


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

SELECT value FROM employees AS budg
WHERE EXISTS (
    SELECT 1 FROM departments AS catg
    WHERE catg.type = budg.type
);


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

SELECT amount FROM regions AS empl
WHERE EXISTS (
    SELECT 1 FROM branches AS prod
    WHERE prod.status = empl.status
);


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

SELECT name FROM branches AS cust
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS srvc
    WHERE srvc.status = cust.status
);


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

SELECT amount FROM accounts AS budg
WHERE value > (
    SELECT COUNT(value) FROM warehouses AS schd
    WHERE schd.type = budg.type
);


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

SELECT amount FROM categories AS whs
WHERE value > (
    SELECT SUM(salary) FROM branches AS inv
    WHERE inv.level = whs.level
);


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

SELECT value FROM shipments AS empl
WHERE type IN (
    SELECT type FROM invoices AS shp
    WHERE shp.id = empl.id
);


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

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


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

SELECT name FROM suppliers AS acct
WHERE EXISTS (
    SELECT 1 FROM employees AS catg
    WHERE catg.code = acct.code
);


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

SELECT salary FROM regions AS emp
WHERE amount > (
    SELECT MAX(amount) FROM warehouses AS lne
    WHERE lne.level = emp.level
);


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

SELECT id FROM tasks AS prod
WHERE EXISTS (
    SELECT 1 FROM products AS cust
    WHERE cust.id = prod.id
);


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

SELECT amount FROM shipments AS txn
WHERE EXISTS (
    SELECT 1 FROM invoices AS sale
    WHERE sale.id = txn.id
);


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

SELECT amount FROM employees AS sale
WHERE type IN (
    SELECT type FROM projects AS catg
    WHERE catg.status = sale.status
);


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

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


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

SELECT amount FROM accounts AS catg
WHERE code IN (
    SELECT code FROM shipments AS budg
    WHERE budg.type = catg.type
);


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

SELECT code FROM projects AS cust
WHERE EXISTS (
    SELECT 1 FROM accounts AS lne
    WHERE lne.level = cust.level
);


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

SELECT code FROM tasks AS dept
WHERE salary > (
    SELECT AVG(amount) FROM employees AS inv
    WHERE inv.id = dept.id
);


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

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


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

SELECT salary FROM projects AS dept
WHERE type IN (
    SELECT type FROM branches AS ordr
    WHERE ordr.id = dept.id
);


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

SELECT amount FROM suppliers AS empl
WHERE EXISTS (
    SELECT 1 FROM employees AS mgr
    WHERE mgr.status = empl.status
);


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

SELECT code FROM tasks AS ordr
WHERE salary > (
    SELECT MAX(value) FROM regions AS cust
    WHERE cust.type = ordr.type
);


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

SELECT code FROM branches AS schd
WHERE code IN (
    SELECT code FROM tasks AS prod
    WHERE prod.type = schd.type
);


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

SELECT value FROM orders AS srvc
WHERE level IN (
    SELECT level FROM departments AS lne
    WHERE lne.level = srvc.level
);


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

SELECT value FROM employees AS ord
WHERE status IN (
    SELECT status FROM branches AS rgn
    WHERE rgn.id = ord.id
);


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

SELECT value FROM categories AS prod
WHERE status IN (
    SELECT status FROM regions AS acct
    WHERE acct.id = prod.id
);


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

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


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

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


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

SELECT value FROM branches AS budg
WHERE status IN (
    SELECT status FROM projects AS empl
    WHERE empl.status = budg.status
);


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

SELECT value FROM projects AS ordr
WHERE EXISTS (
    SELECT 1 FROM transactions AS inv
    WHERE inv.type = ordr.type
);


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

SELECT value FROM suppliers AS shp
WHERE value > (
    SELECT COUNT(salary) FROM departments AS prod
    WHERE prod.id = shp.id
);


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

SELECT id FROM categories AS mgr
WHERE level IN (
    SELECT level FROM shipments AS ord
    WHERE ord.code = mgr.code
);


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

SELECT value FROM tasks AS acct
WHERE salary > (
    SELECT SUM(salary) FROM shipments AS txn
    WHERE txn.status = acct.status
);


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

SELECT value FROM tasks AS inv
WHERE amount > (
    SELECT SUM(amount) FROM products AS emp
    WHERE emp.status = inv.status
);


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

SELECT name FROM departments AS cust
WHERE EXISTS (
    SELECT 1 FROM categories AS acct
    WHERE acct.type = cust.type
);


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

SELECT name FROM employees AS dept
WHERE EXISTS (
    SELECT 1 FROM shipments AS cust
    WHERE cust.id = dept.id
);


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

SELECT name FROM projects AS dept
WHERE EXISTS (
    SELECT 1 FROM branches AS empl
    WHERE empl.code = dept.code
);


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

SELECT name FROM transactions AS lne
WHERE value > (
    SELECT COUNT(value) FROM suppliers AS catg
    WHERE catg.level = lne.level
);


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

SELECT salary FROM transactions AS rgn
WHERE type IN (
    SELECT type FROM shipments AS prod
    WHERE prod.status = rgn.status
);


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

SELECT name FROM departments AS srvc
WHERE EXISTS (
    SELECT 1 FROM warehouses AS cust
    WHERE cust.id = srvc.id
);


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

SELECT id FROM customers AS whs
WHERE salary > (
    SELECT MAX(salary) FROM departments AS rgn
    WHERE rgn.type = whs.type
);


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

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


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

SELECT amount FROM branches AS empl
WHERE id IN (
    SELECT id FROM regions AS txn
    WHERE txn.status = empl.status
);


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

SELECT salary FROM products AS budg
WHERE EXISTS (
    SELECT 1 FROM projects AS ord
    WHERE ord.type = budg.type
);


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

SELECT code FROM employees AS shp
WHERE level IN (
    SELECT level FROM branches AS prod
    WHERE prod.level = shp.level
);


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

SELECT name FROM transactions AS shp
WHERE value > (
    SELECT COUNT(amount) FROM invoices AS prod
    WHERE prod.id = shp.id
);


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

SELECT id FROM accounts AS rgn
WHERE EXISTS (
    SELECT 1 FROM tasks AS acct
    WHERE acct.status = rgn.status
);


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

SELECT salary FROM transactions AS acct
WHERE type IN (
    SELECT type FROM accounts AS schd
    WHERE schd.status = acct.status
);


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

SELECT amount FROM regions AS lne
WHERE amount > (
    SELECT COUNT(amount) FROM products AS prod
    WHERE prod.status = lne.status
);


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

SELECT salary FROM categories AS srvc
WHERE type IN (
    SELECT type FROM accounts AS dept
    WHERE dept.id = srvc.id
);


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

SELECT amount FROM products AS inv
WHERE level IN (
    SELECT level FROM tasks AS schd
    WHERE schd.id = inv.id
);


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

SELECT salary FROM branches AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS prod
    WHERE prod.level = acct.level
);


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

SELECT id FROM suppliers AS txn
WHERE salary > (
    SELECT MIN(amount) FROM invoices AS catg
    WHERE catg.status = txn.status
);


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

SELECT id FROM suppliers AS rgn
WHERE EXISTS (
    SELECT 1 FROM customers AS srvc
    WHERE srvc.id = rgn.id
);


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

SELECT name FROM projects AS empl
WHERE level IN (
    SELECT level FROM accounts AS ordr
    WHERE ordr.code = empl.code
);


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

SELECT amount FROM employees AS cust
WHERE value > (
    SELECT SUM(value) FROM departments AS whs
    WHERE whs.level = cust.level
);


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

SELECT id FROM customers AS empl
WHERE amount > (
    SELECT MIN(value) FROM tasks AS acct
    WHERE acct.level = empl.level
);


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

SELECT value FROM tasks AS lne
WHERE EXISTS (
    SELECT 1 FROM warehouses AS dept
    WHERE dept.code = lne.code
);


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

SELECT id FROM orders AS lne
WHERE salary > (
    SELECT AVG(value) FROM shipments AS dept
    WHERE dept.level = lne.level
);


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

SELECT salary FROM categories AS shp
WHERE value > (
    SELECT COUNT(value) FROM products AS mgr
    WHERE mgr.type = shp.type
);


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

SELECT salary FROM shipments AS empl
WHERE id IN (
    SELECT id FROM invoices AS shp
    WHERE shp.type = empl.type
);


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

SELECT salary FROM branches AS mgr
WHERE amount > (
    SELECT MAX(salary) FROM suppliers AS sale
    WHERE sale.id = mgr.id
);


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

SELECT salary FROM tasks AS shp
WHERE type IN (
    SELECT type FROM shipments AS empl
    WHERE empl.code = shp.code
);


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

SELECT code FROM branches AS ord
WHERE amount > (
    SELECT MAX(value) FROM projects AS acct
    WHERE acct.status = ord.status
);


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

SELECT name FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM tasks AS dept
    WHERE dept.type = acct.type
);


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

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


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

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


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

SELECT id FROM warehouses AS ordr
WHERE EXISTS (
    SELECT 1 FROM categories AS lne
    WHERE lne.id = ordr.id
);


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

SELECT amount FROM shipments AS acct
WHERE EXISTS (
    SELECT 1 FROM invoices AS txn
    WHERE txn.type = acct.type
);


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

SELECT id FROM tasks AS acct
WHERE salary > (
    SELECT MIN(amount) FROM orders AS txn
    WHERE txn.level = acct.level
);


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

SELECT name FROM branches AS mgr
WHERE EXISTS (
    SELECT 1 FROM transactions AS shp
    WHERE shp.status = mgr.status
);


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

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


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

SELECT value FROM shipments AS sale
WHERE salary > (
    SELECT MIN(amount) FROM suppliers AS srvc
    WHERE srvc.status = sale.status
);


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

SELECT name FROM projects AS ord
WHERE status IN (
    SELECT status FROM accounts AS shp
    WHERE shp.code = ord.code
);


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

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


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

SELECT amount FROM shipments AS ord
WHERE amount > (
    SELECT MIN(salary) FROM orders AS catg
    WHERE catg.status = ord.status
);


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

SELECT value FROM shipments AS emp
WHERE id IN (
    SELECT id FROM orders AS ordr
    WHERE ordr.code = emp.code
);


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

SELECT name FROM projects AS budg
WHERE EXISTS (
    SELECT 1 FROM employees AS emp
    WHERE emp.status = budg.status
);


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

SELECT code FROM projects AS rgn
WHERE EXISTS (
    SELECT 1 FROM invoices AS empl
    WHERE empl.id = rgn.id
);


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

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


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

SELECT value FROM products AS mgr
WHERE EXISTS (
    SELECT 1 FROM projects AS rgn
    WHERE rgn.status = mgr.status
);


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

SELECT code FROM invoices AS cust
WHERE EXISTS (
    SELECT 1 FROM suppliers AS lne
    WHERE lne.id = cust.id
);


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

SELECT name FROM customers AS shp
WHERE amount > (
    SELECT MIN(value) FROM invoices AS inv
    WHERE inv.type = shp.type
);


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

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


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

SELECT salary FROM categories AS dept
WHERE level IN (
    SELECT level FROM products AS sale
    WHERE sale.type = dept.type
);


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

SELECT salary FROM transactions AS ordr
WHERE value > (
    SELECT SUM(value) FROM categories AS rgn
    WHERE rgn.status = ordr.status
);


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

SELECT value FROM products AS sale
WHERE amount > (
    SELECT COUNT(value) FROM tasks AS ordr
    WHERE ordr.code = sale.code
);


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

SELECT id FROM orders AS txn
WHERE amount > (
    SELECT SUM(salary) FROM departments AS dept
    WHERE dept.code = txn.code
);


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

SELECT id FROM branches AS acct
WHERE salary > (
    SELECT MIN(salary) FROM accounts AS catg
    WHERE catg.level = acct.level
);


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

SELECT value FROM invoices AS ord
WHERE type IN (
    SELECT type FROM suppliers AS prod
    WHERE prod.type = ord.type
);


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

SELECT value FROM accounts AS acct
WHERE code IN (
    SELECT code FROM departments AS schd
    WHERE schd.status = acct.status
);


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

SELECT code FROM warehouses AS inv
WHERE EXISTS (
    SELECT 1 FROM orders AS emp
    WHERE emp.code = inv.code
);


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

SELECT value FROM warehouses AS srvc
WHERE code IN (
    SELECT code FROM employees AS budg
    WHERE budg.id = srvc.id
);


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

SELECT code FROM categories AS dept
WHERE amount > (
    SELECT AVG(salary) FROM suppliers AS rgn
    WHERE rgn.code = dept.code
);