question,sql,schema_context,domain,difficulty,query_type Find all products whose name starts with 'Pro'.,SELECT * FROM products WHERE name LIKE 'Pro%';," customers(customer_id, name, email, city, country, created_at, total_spent) orders(order_id, customer_id, order_date, status, total_amount, shipping_city) order_items(item_id, order_id, product_id, quantity, unit_price) products(product_id, name, category, price, stock_quantity, supplier_id) suppliers(supplier_id, name, country, rating)",ecommerce,easy,select What is the average price of 'Electronics' products?,SELECT AVG(price) AS avg_price FROM products WHERE category = 'Electronics';," customers(customer_id, name, email, city, country, created_at, total_spent) orders(order_id, customer_id, order_date, status, total_amount, shipping_city) order_items(item_id, order_id, product_id, quantity, unit_price) products(product_id, name, category, price, stock_quantity, supplier_id) suppliers(supplier_id, name, country, rating)",ecommerce,easy,aggregate Find all customers whose email domain is 'gmail.com'.,SELECT * FROM customers WHERE email LIKE '%@gmail.com';," customers(customer_id, name, email, city, country, created_at, total_spent) orders(order_id, customer_id, order_date, status, total_amount, shipping_city) order_items(item_id, order_id, product_id, quantity, unit_price) products(product_id, name, category, price, stock_quantity, supplier_id) suppliers(supplier_id, name, country, rating)",ecommerce,easy,select How many customers are from Spain?,SELECT COUNT(*) AS customer_count FROM customers WHERE country = 'Spain';," customers(customer_id, name, email, city, country, created_at, total_spent) orders(order_id, customer_id, order_date, status, total_amount, shipping_city) order_items(item_id, order_id, product_id, quantity, unit_price) products(product_id, name, category, price, stock_quantity, supplier_id) suppliers(supplier_id, name, country, rating)",ecommerce,easy,aggregate What is the average product price?,SELECT AVG(price) AS avg_price FROM products;," customers(customer_id, name, email, city, country, created_at, total_spent) orders(order_id, customer_id, order_date, status, total_amount, shipping_city) order_items(item_id, order_id, product_id, quantity, unit_price) products(product_id, name, category, price, stock_quantity, supplier_id) suppliers(supplier_id, name, country, rating)",ecommerce,easy,aggregate List all patients from New York.,SELECT * FROM patients WHERE city = 'New York';," patients(patient_id, name, date_of_birth, gender, city, insurance_type) doctors(doctor_id, name, specialty, hospital_id, years_experience) appointments(appointment_id, patient_id, doctor_id, appointment_date, status, diagnosis) hospitals(hospital_id, name, city, beds, rating) prescriptions(prescription_id, appointment_id, medication, dosage, duration_days)",healthcare,easy,select List all patients with 'private' insurance.,SELECT * FROM patients WHERE insurance_type = 'private';," patients(patient_id, name, date_of_birth, gender, city, insurance_type) doctors(doctor_id, name, specialty, hospital_id, years_experience) appointments(appointment_id, patient_id, doctor_id, appointment_date, status, diagnosis) hospitals(hospital_id, name, city, beds, rating) prescriptions(prescription_id, appointment_id, medication, dosage, duration_days)",healthcare,easy,select Show all doctors with more than 10 years of experience.,SELECT * FROM doctors WHERE years_experience > 10;," patients(patient_id, name, date_of_birth, gender, city, insurance_type) doctors(doctor_id, name, specialty, hospital_id, years_experience) appointments(appointment_id, patient_id, doctor_id, appointment_date, status, diagnosis) hospitals(hospital_id, name, city, beds, rating) prescriptions(prescription_id, appointment_id, medication, dosage, duration_days)",healthcare,easy,select How many users are on the 'enterprise' plan?,SELECT COUNT(*) FROM users WHERE plan = 'enterprise';," events(event_id, user_id, event_type, event_date, page, session_id, duration_seconds) users(user_id, username, signup_date, plan, country, is_active) sessions(session_id, user_id, start_time, end_time, device, browser) pages(page_id, url, title, category, created_at) conversions(conversion_id, user_id, event_date, revenue, campaign_id)",analytics,easy,aggregate Get sessions that lasted more than 10 minutes.,SELECT * FROM events WHERE duration_seconds > 600;," events(event_id, user_id, event_type, event_date, page, session_id, duration_seconds) users(user_id, username, signup_date, plan, country, is_active) sessions(session_id, user_id, start_time, end_time, device, browser) pages(page_id, url, title, category, created_at) conversions(conversion_id, user_id, event_date, revenue, campaign_id)",analytics,easy,select What is the minimum salary in the company?,SELECT MIN(salary) AS min_salary FROM employees;," employees(employee_id, name, department_id, manager_id, hire_date, salary, city) departments(department_id, name, location, budget, head_count) projects(project_id, name, department_id, start_date, end_date, budget) assignments(assignment_id, employee_id, project_id, role, hours_per_week) performance_reviews(review_id, employee_id, review_year, rating, bonus)",hr,easy,aggregate Find all employees with a performance rating of 4.,"SELECT e.name, pr.review_year, pr.bonus FROM employees e JOIN performance_reviews pr ON e.employee_id = pr.employee_id WHERE pr.rating = 4;"," employees(employee_id, name, department_id, manager_id, hire_date, salary, city) departments(department_id, name, location, budget, head_count) projects(project_id, name, department_id, start_date, end_date, budget) assignments(assignment_id, employee_id, project_id, role, hours_per_week) performance_reviews(review_id, employee_id, review_year, rating, bonus)",hr,easy,join What is the total quantity moved as 'shipment' this year?,"SELECT SUM(quantity) FROM movements WHERE movement_type = 'shipment' AND EXTRACT(YEAR FROM movement_date) = EXTRACT(YEAR FROM CURRENT_DATE);"," warehouses(warehouse_id, name, city, country, capacity) items(item_id, name, sku, category, unit_cost, reorder_point) stock(stock_id, item_id, warehouse_id, quantity, last_updated) movements(movement_id, item_id, warehouse_id, movement_type, quantity, movement_date) vendors(vendor_id, name, country, lead_time_days, reliability_score)",inventory,easy,aggregate What is the total quantity moved as 'receipt' this year?,"SELECT SUM(quantity) FROM movements WHERE movement_type = 'receipt' AND EXTRACT(YEAR FROM movement_date) = EXTRACT(YEAR FROM CURRENT_DATE);"," warehouses(warehouse_id, name, city, country, capacity) items(item_id, name, sku, category, unit_cost, reorder_point) stock(stock_id, item_id, warehouse_id, quantity, last_updated) movements(movement_id, item_id, warehouse_id, movement_type, quantity, movement_date) vendors(vendor_id, name, country, lead_time_days, reliability_score)",inventory,easy,aggregate What is the total revenue from 'Electronics' category products?,"SELECT SUM(oi.quantity * oi.unit_price) AS revenue FROM order_items oi JOIN products p ON oi.product_id = p.product_id WHERE p.category = 'Electronics';"," customers(customer_id, name, email, city, country, created_at, total_spent) orders(order_id, customer_id, order_date, status, total_amount, shipping_city) order_items(item_id, order_id, product_id, quantity, unit_price) products(product_id, name, category, price, stock_quantity, supplier_id) suppliers(supplier_id, name, country, rating)",ecommerce,medium,join What is the total revenue from 'Clothing' category products?,"SELECT SUM(oi.quantity * oi.unit_price) AS revenue FROM order_items oi JOIN products p ON oi.product_id = p.product_id WHERE p.category = 'Clothing';"," customers(customer_id, name, email, city, country, created_at, total_spent) orders(order_id, customer_id, order_date, status, total_amount, shipping_city) order_items(item_id, order_id, product_id, quantity, unit_price) products(product_id, name, category, price, stock_quantity, supplier_id) suppliers(supplier_id, name, country, rating)",ecommerce,medium,join How many products are in each category?,"SELECT category, COUNT(*) AS product_count FROM products GROUP BY category ORDER BY product_count DESC;"," customers(customer_id, name, email, city, country, created_at, total_spent) orders(order_id, customer_id, order_date, status, total_amount, shipping_city) order_items(item_id, order_id, product_id, quantity, unit_price) products(product_id, name, category, price, stock_quantity, supplier_id) suppliers(supplier_id, name, country, rating)",ecommerce,medium,aggregate Find patients who have had appointments cancelled more than twice.,"SELECT p.name, COUNT(*) AS cancellations FROM appointments a JOIN patients p ON a.patient_id = p.patient_id WHERE a.status = 'cancelled' GROUP BY p.patient_id, p.name HAVING COUNT(*) > 2;"," patients(patient_id, name, date_of_birth, gender, city, insurance_type) doctors(doctor_id, name, specialty, hospital_id, years_experience) appointments(appointment_id, patient_id, doctor_id, appointment_date, status, diagnosis) hospitals(hospital_id, name, city, beds, rating) prescriptions(prescription_id, appointment_id, medication, dosage, duration_days)",healthcare,medium,aggregate List each doctor along with the hospital name and city they work in.,"SELECT d.name AS doctor_name, d.specialty, h.name AS hospital_name, h.city FROM doctors d JOIN hospitals h ON d.hospital_id = h.hospital_id;"," patients(patient_id, name, date_of_birth, gender, city, insurance_type) doctors(doctor_id, name, specialty, hospital_id, years_experience) appointments(appointment_id, patient_id, doctor_id, appointment_date, status, diagnosis) hospitals(hospital_id, name, city, beds, rating) prescriptions(prescription_id, appointment_id, medication, dosage, duration_days)",healthcare,medium,join How many employees are in each department?,"SELECT d.name AS department, COUNT(e.employee_id) AS employee_count FROM employees e JOIN departments d ON e.department_id = d.department_id GROUP BY d.name ORDER BY employee_count DESC;"," employees(employee_id, name, department_id, manager_id, hire_date, salary, city) departments(department_id, name, location, budget, head_count) projects(project_id, name, department_id, start_date, end_date, budget) assignments(assignment_id, employee_id, project_id, role, hours_per_week) performance_reviews(review_id, employee_id, review_year, rating, bonus)",hr,medium,aggregate List all employees who have never received a bonus.,"SELECT e.name FROM employees e WHERE e.employee_id NOT IN ( SELECT employee_id FROM performance_reviews WHERE bonus > 0 );"," employees(employee_id, name, department_id, manager_id, hire_date, salary, city) departments(department_id, name, location, budget, head_count) projects(project_id, name, department_id, start_date, end_date, budget) assignments(assignment_id, employee_id, project_id, role, hours_per_week) performance_reviews(review_id, employee_id, review_year, rating, bonus)",hr,medium,subquery How many users signed up per month in 2023?,"SELECT DATE_TRUNC('month', signup_date) AS month, COUNT(*) AS signups FROM users WHERE signup_date >= '2023-01-01' AND signup_date < '2024-01-01' GROUP BY month ORDER BY month;"," events(event_id, user_id, event_type, event_date, page, session_id, duration_seconds) users(user_id, username, signup_date, plan, country, is_active) sessions(session_id, user_id, start_time, end_time, device, browser) pages(page_id, url, title, category, created_at) conversions(conversion_id, user_id, event_date, revenue, campaign_id)",analytics,medium,aggregate List each item in stock with its warehouse name and city.,"SELECT i.name AS item_name, i.sku, w.name AS warehouse_name, w.city, s.quantity FROM stock s JOIN items i ON s.item_id = i.item_id JOIN warehouses w ON s.warehouse_id = w.warehouse_id;"," warehouses(warehouse_id, name, city, country, capacity) items(item_id, name, sku, category, unit_cost, reorder_point) stock(stock_id, item_id, warehouse_id, quantity, last_updated) movements(movement_id, item_id, warehouse_id, movement_type, quantity, movement_date) vendors(vendor_id, name, country, lead_time_days, reliability_score)",inventory,medium,join Find the top 3 customers by total order value in 2024.,"SELECT c.name, SUM(o.total_amount) AS total_value FROM orders o JOIN customers c ON o.customer_id = c.customer_id WHERE o.order_date >= '2024-01-01' AND o.order_date < '2025-01-01' GROUP BY c.name ORDER BY total_value DESC LIMIT 3;"," customers(customer_id, name, email, city, country, created_at, total_spent) orders(order_id, customer_id, order_date, status, total_amount, shipping_city) order_items(item_id, order_id, product_id, quantity, unit_price) products(product_id, name, category, price, stock_quantity, supplier_id) suppliers(supplier_id, name, country, rating)",ecommerce,hard,subquery What is the most common diagnosis among female patients?,"SELECT a.diagnosis, COUNT(*) AS cnt FROM appointments a JOIN patients p ON a.patient_id = p.patient_id WHERE p.gender = 'F' GROUP BY a.diagnosis ORDER BY cnt DESC LIMIT 1;"," patients(patient_id, name, date_of_birth, gender, city, insurance_type) doctors(doctor_id, name, specialty, hospital_id, years_experience) appointments(appointment_id, patient_id, doctor_id, appointment_date, status, diagnosis) hospitals(hospital_id, name, city, beds, rating) prescriptions(prescription_id, appointment_id, medication, dosage, duration_days)",healthcare,hard,aggregate Find employees earning more than the average salary in their own department.,"SELECT e.name, e.salary, d.name AS department FROM employees e JOIN departments d ON e.department_id = d.department_id WHERE e.salary > ( SELECT AVG(e2.salary) FROM employees e2 WHERE e2.department_id = e.department_id ) ORDER BY d.name, e.salary DESC;"," employees(employee_id, name, department_id, manager_id, hire_date, salary, city) departments(department_id, name, location, budget, head_count) projects(project_id, name, department_id, start_date, end_date, budget) assignments(assignment_id, employee_id, project_id, role, hours_per_week) performance_reviews(review_id, employee_id, review_year, rating, bonus)",hr,hard,subquery Calculate the 7-day rolling average of daily signups.,"SELECT signup_date, COUNT(*) AS daily_signups, AVG(COUNT(*)) OVER (ORDER BY signup_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS rolling_7d_avg FROM users GROUP BY signup_date ORDER BY signup_date;"," events(event_id, user_id, event_type, event_date, page, session_id, duration_seconds) users(user_id, username, signup_date, plan, country, is_active) sessions(session_id, user_id, start_time, end_time, device, browser) pages(page_id, url, title, category, created_at) conversions(conversion_id, user_id, event_date, revenue, campaign_id)",analytics,hard,window Find items that are stocked in every warehouse.,"SELECT i.name FROM items i WHERE NOT EXISTS ( SELECT 1 FROM warehouses w WHERE NOT EXISTS ( SELECT 1 FROM stock s WHERE s.item_id = i.item_id AND s.warehouse_id = w.warehouse_id ) );"," warehouses(warehouse_id, name, city, country, capacity) items(item_id, name, sku, category, unit_cost, reorder_point) stock(stock_id, item_id, warehouse_id, quantity, last_updated) movements(movement_id, item_id, warehouse_id, movement_type, quantity, movement_date) vendors(vendor_id, name, country, lead_time_days, reliability_score)",inventory,hard,subquery