question stringlengths 18 249 | sql stringlengths 31 552 | level stringclasses 3
values |
|---|---|---|
how much revenue was there in Q3 2026 | SELECT SUM(oi.quantity * oi.unit_price) AS revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status != 'cancelled' AND o.order_date BETWEEN '2026-07-01' AND '2026-09-30' | easy |
average order value without discount codes | SELECT AVG(order_total) AS avg_order_value FROM (SELECT o.order_id, SUM(oi.quantity * oi.unit_price) AS order_total FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status <> 'cancelled' AND o.discount_code IS NULL GROUP BY o.order_id) | medium |
Which product has the highest refund total? | SELECT p.name, SUM(r.refund_amount) AS total_refund FROM returns r JOIN products p ON r.product_id = p.product_id GROUP BY p.product_id ORDER BY total_refund DESC LIMIT 1 | easy |
How many orders have been shipped but not yet delivered? | SELECT COUNT(*) FROM orders WHERE status = 'shipped' | hard |
How many delivered orders had a return for a product that was launched after the order date? | SELECT COUNT(DISTINCT o.order_id) FROM orders o JOIN returns r ON o.order_id = r.order_id JOIN order_items oi ON o.order_id = oi.order_id JOIN products p ON oi.product_id = p.product_id WHERE o.status = 'delivered' AND p.launched_on > o.order_date | hard |
How many customers are from either the USA or Canada? | SELECT COUNT(*) FROM customers WHERE country IN ('USA', 'Canada') | hard |
How many consumers have a higher average rating than the overall average rating for products they reviewed? | SELECT COUNT(*) AS consumer_count FROM (SELECT r.customer_id FROM reviews r JOIN products p ON r.product_id = p.product_id GROUP BY r.customer_id HAVING AVG(r.rating) > (SELECT AVG(rating) FROM reviews)) AS filtered | medium |
What's the top revenue product right now? | SELECT p.product_id, p.name, SUM(oi.quantity * oi.unit_price) AS revenue FROM order_items oi JOIN orders o ON oi.order_id = o.order_id JOIN products p ON oi.product_id = p.product_id WHERE o.status <> 'cancelled' GROUP BY p.product_id, p.name ORDER BY revenue DESC LIMIT 1 | medium |
How many customers are located in each country represented in the customers table? | SELECT country, COUNT(*) AS customer_count FROM customers GROUP BY country | medium |
What's the average order value for store channel orders in September 2026? | SELECT AVG(revenue) AS avg_order_value FROM (SELECT o.order_id, SUM(oi.quantity * oi.unit_price) AS revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.channel = 'store' AND o.status != 'cancelled' AND o.order_date >= '2026-09-01' AND o.order_date < '2026-10-01' GROUP BY o.order_id) t | medium |
monthly revenue for last month | SELECT SUM(order_items.quantity * order_items.unit_price) AS monthly_revenue FROM orders JOIN order_items ON orders.order_id = order_items.order_id WHERE orders.status <> 'cancelled' AND orders.order_date >= '2026-09-01' AND orders.order_date <= '2026-09-30' | easy |
How many reviews did products in the 'electronics' category get this year? | SELECT COUNT(*) FROM reviews r JOIN products p ON r.product_id = p.product_id JOIN categories c ON p.category_id = c.category_id WHERE c.name = 'electronics' AND r.review_date >= '2026-01-01' AND r.review_date <= '2026-12-31' | hard |
How many customers signed up in this year? | SELECT COUNT(*) AS customer_count FROM customers WHERE signup_date >= '2026-01-01' AND signup_date <= '2026-12-31' | medium |
What are the average ratings grouped by product? | SELECT product_id, AVG(rating) AS average_rating FROM reviews GROUP BY product_id | easy |
How many returns were made for products in the 'electronics' category during this year? | SELECT COUNT(*) FROM returns r JOIN products p ON r.product_id = p.product_id JOIN categories cat ON p.category_id = cat.category_id WHERE cat.name = 'electronics' AND r.return_date >= '2026-01-01' AND r.return_date <= '2026-10-01' | medium |
Which product had the most returns this year? | SELECT p.name, COUNT(rt.return_id) AS return_count FROM returns rt JOIN products p ON rt.product_id = p.product_id WHERE rt.return_date >= '2026-01-01' AND rt.return_date < '2027-01-01' GROUP BY p.product_id ORDER BY return_count DESC LIMIT 1 | easy |
number of cancelled orders with discount codes in October 2026 | SELECT COUNT(*) AS cancelled_count FROM orders WHERE order_date >= '2026-10-01' AND order_date < '2026-11-01' AND status = 'cancelled' AND discount_code IS NOT NULL | medium |
How many customers are in Germany? | SELECT COUNT(*) FROM customers WHERE country = 'Germany' | medium |
What's the average rating for each product, and how many reviews did it get? | SELECT p.product_id, p.name, AVG(r.rating) AS avg_rating, COUNT(r.review_id) AS review_count FROM reviews r JOIN products p ON r.product_id = p.product_id GROUP BY p.product_id, p.name ORDER BY p.product_id | medium |
How many reviews did customers in the USA give in this year? | SELECT COUNT(*) AS review_count FROM reviews r JOIN customers c ON r.customer_id = c.customer_id WHERE c.country = 'USA' AND r.review_date >= '2026-01-01' AND r.review_date < '2027-01-01' | medium |
What was the average order value for orders placed in the last 7 days? | SELECT AVG(total) FROM (SELECT o.order_id, SUM(oi.quantity * oi.unit_price) AS total FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.order_date >= date('2026-10-01', '-7 days') AND o.order_date < '2026-10-01' AND o.status != 'cancelled' GROUP BY o.order_id) AS order_totals | medium |
How many new customers signed up in Canada this year? | SELECT COUNT(*) FROM customers WHERE signup_date >= '2026-01-01' AND signup_date < '2027-01-01' AND country = 'Canada' | easy |
Count of business segment customers who signed up in Q3 2026 | SELECT COUNT(*) FROM customers WHERE segment = 'business' AND signup_date >= '2026-07-01' AND signup_date <= '2026-09-30' | easy |
What is the average revenue per order for orders placed in the last quarter (2026-07-01 to 2026-09-30)? | SELECT AVG(order_value) AS average_order_value FROM (SELECT o.order_id, SUM(oi.quantity * oi.unit_price) AS order_value FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.order_date >= '2026-07-01' AND o.order_date <= '2026-09-30' AND o.status <> 'cancelled' GROUP BY o.order_id) | easy |
total revenue from delivered orders | SELECT SUM(oi.quantity * oi.unit_price) AS total_revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status = 'delivered' | easy |
What was the total revenue generated by business customers in the last quarter of 2026? | SELECT SUM(oi.quantity * oi.unit_price) AS revenue FROM order_items oi JOIN orders o ON oi.order_id = o.order_id JOIN customers c ON o.customer_id = c.customer_id WHERE o.order_date >= '2026-07-01' AND o.order_date <= '2026-09-30' AND c.segment = 'business' AND o.status != 'cancelled' | medium |
total revenue from app channel orders this year | SELECT SUM(oi.quantity * oi.unit_price) AS revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status != 'cancelled' AND o.channel = 'app' AND o.order_date >= '2026-01-01' AND o.order_date < '2027-01-01' | easy |
number of delivered orders for customers in the USA | SELECT COUNT(*) AS delivered_order_count FROM orders o JOIN customers c ON o.customer_id = c.customer_id WHERE c.country = 'USA' AND o.status = 'delivered' | medium |
How many orders were placed in the last 30 days (from 2026-10-01) that have a status of 'placed'? | SELECT COUNT(*) AS order_count FROM orders WHERE order_date >= date('2026-10-01', '-30 days') AND order_date <= '2026-10-01' AND status = 'placed' | medium |
What's the average rating for the top products? Like the top 3 by rating. | SELECT p.name AS product_name, AVG(r.rating) AS avg_rating FROM reviews r JOIN products p ON r.product_id = p.product_id GROUP BY p.product_id, p.name ORDER BY avg_rating DESC LIMIT 3 | medium |
What is the average number of items per order for orders placed in the last 30 days (from 2026-10-01)? | SELECT SUM(oi.quantity) * 1.0 / COUNT(DISTINCT o.order_id) AS avg_items_per_order FROM orders o LEFT JOIN order_items oi ON o.order_id = oi.order_id WHERE o.order_date >= date('2026-10-01', '-30 days') | medium |
What is the total refund amount for returns due to wrong item? | SELECT SUM(refund_amount) AS wrong_item_refund FROM returns WHERE reason = 'wrong item' | easy |
What is the maximum refund amount given for a return of a product in the category with the highest total cost? | WITH category_cost AS (SELECT p.category_id, SUM(p.cost) AS total_cost FROM products p GROUP BY p.category_id), top_cat AS (SELECT category_id FROM category_cost ORDER BY total_cost DESC LIMIT 1) SELECT MAX(r.refund_amount) AS max_refund FROM returns r JOIN products p ON r.product_id = p.product_id WHERE p.category_id ... | hard |
How many repeat buyers do we have? | SELECT COUNT(*) AS repeat_buyer_count FROM (SELECT customer_id FROM orders GROUP BY customer_id HAVING COUNT(DISTINCT order_id) > 1) | medium |
How many 5-star reviews did product 1 get? | SELECT COUNT(*) AS five_star_count FROM reviews WHERE product_id = 1 AND rating = 5 | medium |
How many reviews did each product receive? | SELECT product_id, COUNT(*) AS review_count FROM reviews GROUP BY product_id | easy |
orders in the last 30 days | SELECT * FROM orders WHERE order_date >= date('2026-10-01', '-30 days') | easy |
What was the total revenue from orders that used a discount code last month? | SELECT SUM(oi.quantity * oi.unit_price) FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.order_date >= '2026-09-01' AND o.order_date <= '2026-09-30' AND o.status != 'cancelled' AND o.discount_code IS NOT NULL | easy |
What is the total revenue generated by orders that used a discount code in the last month (September 2026)? | SELECT SUM(oi.quantity * oi.unit_price) AS total_revenue FROM order_items oi JOIN orders o ON oi.order_id = o.order_id WHERE o.order_date >= '2026-09-01' AND o.order_date < '2026-10-01' AND o.status != 'cancelled' AND o.discount_code IS NOT NULL | hard |
customers who never ordered | SELECT c.customer_id, c.name, c.email FROM customers c WHERE NOT EXISTS (SELECT 1 FROM orders o WHERE o.customer_id = c.customer_id) | easy |
How many customers are from Australia? | SELECT COUNT(*) FROM customers WHERE country = 'Australia' | medium |
monthly revenue for month last month | SELECT COALESCE(SUM(oi.quantity * oi.unit_price), 0) AS monthly_revenue FROM orders AS o JOIN order_items AS oi ON o.order_id = oi.order_id WHERE o.status <> 'cancelled' AND o.order_date BETWEEN '2026-09-01' AND '2026-09-30' | medium |
What is the average rating of products that have been returned? | SELECT AVG(r.rating) AS avg_rating FROM reviews r WHERE r.product_id IN (SELECT DISTINCT product_id FROM returns) | hard |
How many new customers signed up in the last 7 days? | SELECT COUNT(*) AS new_customers FROM customers WHERE signup_date >= date('2026-10-01', '-7 days') | easy |
What are the customer counts by segment for customers in each country? | SELECT country, segment, COUNT(*) AS customer_count FROM customers GROUP BY country, segment ORDER BY country, segment | medium |
How many customers are from Canada? | SELECT COUNT(*) FROM customers WHERE country = 'Canada' | hard |
What is the average quantity of items ordered per order for delivered orders in September 2026? | SELECT AVG(total_qty) AS avg_items_per_order FROM (SELECT o.order_id, SUM(oi.quantity) AS total_qty FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status = 'delivered' AND o.order_date >= '2026-09-01' AND o.order_date < '2026-10-01' GROUP BY o.order_id) AS order_qty | easy |
count of products with price > 200 in category 'Audio'? | SELECT COUNT(*) FROM products p JOIN categories c ON p.category_id = c.category_id WHERE c.name = 'Audio' AND p.price > 200 | easy |
Which product has the highest refund amount from returns? | SELECT r.product_id, SUM(r.refund_amount) AS total_refund FROM returns r GROUP BY r.product_id ORDER BY total_refUND DESC LIMIT 1 | hard |
total revenue by month for 2026 | SELECT strftime('%Y-%m', o.order_date) AS month, SUM(oi.quantity * oi.unit_price) AS revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status != 'cancelled' AND o.order_date BETWEEN '2026-01-01' AND '2026-12-31' GROUP BY month ORDER BY month | easy |
What is the refund amount for the return with return_id 1? | SELECT refund_amount FROM returns WHERE return_id = 1 | easy |
How many customers are in the business segment from the UK? | SELECT COUNT(*) FROM customers WHERE segment = 'business' AND country = 'UK' | medium |
how many delivered orders were placed in last quarter | SELECT COUNT(*) FROM orders WHERE status = 'delivered' AND order_date >= '2026-07-01' AND order_date <= '2026-09-30' | hard |
How many returns have been made for product 4 in the last 30 days? | SELECT COUNT(*) FROM returns WHERE product_id = 4 AND return_date >= date('2026-10-01', '-30 days') | easy |
What is the total revenue from orders that were not cancelled? | SELECT SUM(oi.quantity * oi.unit_price) AS revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status <> 'cancelled' | hard |
How many customers from the USA placed orders that were never delivered? | SELECT COUNT(DISTINCT c.customer_id) FROM customers c JOIN orders o ON c.customer_id = o.customer_id WHERE c.country = 'USA' AND o.status != 'delivered' | hard |
What was the average order value for cancelled orders placed in September 2026? | SELECT AVG(order_value) AS average_order_value FROM (SELECT o.order_id, SUM(oi.quantity * oi.unit_price) AS order_value FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.order_date >= '2026-09-01' AND o.order_date <= '2026-09-30' AND o.status = 'cancelled' GROUP BY o.order_id) | easy |
How many distinct customers placed orders in the last 7 days (2026-10-01 to 2026-10-01)? | SELECT COUNT(DISTINCT customer_id) AS distinct_customers FROM orders WHERE order_date >= date('2026-10-01', '-7 days') | hard |
How many reviews does product 1 have? | SELECT COUNT(*) FROM reviews WHERE product_id = 1 | easy |
Which customer has the highest total spend this year? | SELECT c.customer_id, c.name, SUM(oi.quantity * oi.unit_price) AS total_spend FROM customers c JOIN orders o ON c.customer_id = o.customer_id JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status != 'cancelled' AND o.order_date BETWEEN '2026-01-01' AND '2026-12-31' GROUP BY c.customer_id, c.name ORDER BY total... | medium |
What is the worst rated product by average rating? | SELECT product_id, AVG(rating) AS avg_rating FROM reviews GROUP BY product_id ORDER BY avg_rating ASC LIMIT 1 | hard |
What's the total number of customers in the consumer segment? | SELECT COUNT(*) FROM customers WHERE segment = 'consumer' | medium |
How many customers are located in the city of Paris? | SELECT COUNT(*) FROM customers WHERE city = 'Paris' | easy |
What is the refund amount for returns due to not as described? | SELECT SUM(refund_amount) AS refund_amount FROM returns WHERE reason = 'not as described' | easy |
How many reviews were written for each product, and what is the average rating? | SELECT p.product_id, p.name, COUNT(r.review_id) AS review_count, AVG(r.rating) AS average_rating FROM products p JOIN reviews r ON p.product_id = r.product_id GROUP BY p.product_id, p.name ORDER BY p.product_id | easy |
What is the total revenue generated in 2026 so far this year? | SELECT SUM(o.quantity * o.unit_price) AS revenue FROM order_items o JOIN orders r ON o.order_id = r.order_id WHERE r.order_date BETWEEN '2026-01-01' AND '2026-10-01' AND r.status != 'cancelled' | medium |
What is the average rating of reviews for products launched in 2026? | SELECT AVG(r.rating) FROM reviews r JOIN products p ON r.product_id = p.product_id WHERE p.launched_on >= '2026-01-01' AND p.launched_on <= '2026-12-31' | easy |
What's the average rating for products reviewed this year? | SELECT AVG(r.rating) AS avg_rating FROM reviews r WHERE r.review_date >= '2026-01-01' | medium |
How many customers signed up in last month? | SELECT COUNT(*) FROM customers WHERE signup_date >= '2026-09-01' AND signup_date < '2026-10-01' | medium |
How many customers are in cities of Japan? | SELECT COUNT(*) AS customer_count FROM customers WHERE country = 'Japan' | medium |
How many products were launched in the last quarter of 2026 across all parent categories? | SELECT COUNT(*) FROM products WHERE launched_on >= '2026-07-01' AND launched_on < '2026-10-01' | medium |
How many delivered orders had the web channel last month? | SELECT COUNT(*) FROM orders WHERE channel = 'web' AND status = 'delivered' AND order_date >= '2026-09-01' AND order_date <= '2026-09-30' | easy |
How many customers signed up in 2025 from the USA | SELECT COUNT(*) FROM customers WHERE signup_date LIKE '2025-%' AND country = 'USA' | hard |
What is the average order value for orders placed by business customers in September 2026? | SELECT AVG(order_value) FROM (SELECT o.order_id, SUM(oi.quantity * oi.unit_price) AS order_value FROM orders o JOIN customers c ON o.customer_id = c.customer_id JOIN order_items oi ON o.order_id = oi.order_id WHERE c.segment = 'business' AND o.status <> 'cancelled' AND o.order_date BETWEEN '2026-09-01' AND '2026-09-30'... | medium |
how much revenue was generated in the last 7 days | SELECT SUM(oi.quantity * oi.unit_price) AS revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status != 'cancelled' AND o.order_date >= date('2026-10-01', '-7 days') AND o.order_date <= '2026-10-01' | easy |
Which product has the best average rating? | SELECT product_id, AVG(rating) AS avg_rating FROM reviews GROUP BY product_id ORDER BY avg_rating DESC LIMIT 1 | easy |
How many products have been reviewed at least once? | SELECT COUNT(DISTINCT product_id) AS product_count FROM reviews | medium |
How did the revenue from the store channel compare to the web channel for September 2026? | SELECT SUM(CASE WHEN o.channel = 'store' THEN oi.quantity * oi.unit_price ELSE 0 END) AS store_revenue, SUM(CASE WHEN o.channel = 'web' THEN oi.quantity * oi.unit_price ELSE 0 END) AS web_revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status != 'cancelled' AND o.order_date BETWEEN '2026-0... | medium |
How many customers are located in France and what is the total number of customers in the consumer segment there? | SELECT COUNT(customer_id) AS france_consumers FROM customers WHERE country = 'France' AND segment = 'consumer' | medium |
What is the total number of new customers who signed up in October 2026? | SELECT COUNT(*) AS total_new_customers FROM customers WHERE signup_date >= '2026-10-01' AND signup_date < '2026-11-01' | medium |
What are the counts of customers by country for the top 3 countries? | SELECT country, COUNT(*) AS customer_count FROM customers GROUP BY country ORDER BY customer_count DESC LIMIT 3 | easy |
Which customer spent the most money in total? | SELECT c.customer_id, c.name, SUM(oi.quantity * oi.unit_price) AS total_spent FROM orders o JOIN order_items oi ON o.order_id = oi.order_id JOIN customers c ON o.customer_id = c.customer_id WHERE o.status <> 'cancelled' GROUP BY c.customer_id, c.name ORDER BY total_spent DESC LIMIT 1 | hard |
How many customers from Canada placed their first-ever order in September 2026? | SELECT COUNT(*) AS customer_count FROM customers AS c WHERE c.country = 'Canada' AND c.customer_id IN ( SELECT customer_id FROM orders GROUP BY customer_id HAVING MIN(order_date) BETWEEN '2026-09-01' AND '2026-09-30' ) | medium |
Which sales channel had the highest revenue in September 2026? | SELECT o.channel, SUM(oi.quantity * oi.unit_price) AS revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status != 'cancelled' AND o.order_date BETWEEN '2026-09-01' AND '2026-09-30' GROUP BY o.channel ORDER BY revenue DESC LIMIT 1 | medium |
What is the average rating given by customers to each product they have reviewed? | SELECT product_id, AVG(rating) AS average_rating FROM reviews GROUP BY product_id | easy |
How many shipped orders had a discount code in the last quarter? | SELECT COUNT(*) FROM orders WHERE discount_code IS NOT NULL AND status = 'shipped' AND order_date >= '2026-07-01' AND order_date <= '2026-09-30' | medium |
top 3 customers by total spent in 2026? | SELECT c.customer_id, c.name, SUM(oi.quantity * oi.unit_price) AS total_spent FROM orders o JOIN order_items oi ON o.order_id = oi.order_id JOIN customers c ON o.customer_id = c.customer_id WHERE o.status != 'cancelled' AND o.order_date >= '2026-01-01' AND o.order_date < '2027-01-01' GROUP BY c.customer_id, c.name ORDE... | easy |
What is the customer count by segment? | SELECT segment, COUNT(customer_id) AS customer_count FROM customers GROUP BY segment | medium |
Show me the top 3 products by total revenue this year, excluding cancelled orders. | SELECT p.name, SUM(oi.quantity * oi.unit_price) AS total_revenue FROM order_items oi JOIN orders o ON oi.order_id = o.order_id JOIN products p ON oi.product_id = p.product_id WHERE o.status != 'cancelled' AND strftime('%Y', o.order_date) = '2026' GROUP BY p.product_id ORDER BY total_revenue DESC LIMIT 3 | hard |
What is the total refund amount for all returns? | SELECT SUM(refund_amount) AS total_refund_amount FROM returns | easy |
What is the refund amount for returns of products that were not returned within 30 days of delivery in September 2026? | SELECT COALESCE(SUM(r.refund_amount), 0) AS refund_amount FROM returns r JOIN orders o ON r.order_id = o.order_id WHERE r.return_date >= '2026-09-01' AND r.return_date < '2026-10-01' AND r.return_date > date(o.order_date, '+30 days') | hard |
average refund amount by return reason | SELECT reason, AVG(refund_amount) FROM returns GROUP BY reason | easy |
How many orders had to be cancelled last month? | SELECT COUNT(*) AS cancelled_orders FROM orders WHERE status = 'cancelled' AND order_date BETWEEN '2026-09-01' AND '2026-09-30' | easy |
Which product has the worst average rating? | SELECT product_id, AVG(rating) AS avg_rating FROM reviews GROUP BY product_id ORDER BY avg_rating ASC LIMIT 1 | easy |
What's the total revenue by week for delivered orders in September 2026? | SELECT strftime('%Y-%W', o.order_date) AS week, SUM(oi.quantity * oi.unit_price) AS revenue FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.status = 'delivered' AND o.order_date >= '2026-09-01' AND o.order_date < '2026-10-01' GROUP BY week ORDER BY week | medium |
Which customers spent the most money in September 2026? | SELECT c.customer_id, c.name, c.email, SUM(oi.quantity * oi.unit_price) AS total_spent FROM orders o JOIN order_items oi ON o.order_id = oi.order_id JOIN customers c ON o.customer_id = c.customer_id WHERE o.status <> 'cancelled' AND o.order_date >= '2026-09-01' AND o.order_date <= '2026-09-30' GROUP BY c.customer_id, c... | hard |
What is the total profit for all delivered orders in September 2026, calculated as SUM(quantity * unit_price) minus SUM(quantity * cost) per order item? | SELECT SUM(oi.quantity * oi.unit_price - oi.quantity * p.cost) AS total_profit FROM orders o JOIN order_items oi ON o.order_id = oi.order_id JOIN products p ON oi.product_id = p.product_id WHERE o.status = 'delivered' AND o.order_date >= '2026-09-01' AND o.order_date <= '2026-09-30' | hard |
What's the total revenue from orders with no discount code this year? | SELECT SUM(oi.quantity * oi.unit_price) AS revenue FROM order_items oi JOIN orders o ON oi.order_id = o.order_id WHERE o.discount_code IS NULL AND o.status IN ('placed', 'shipped', 'delivered') AND o.order_date >= '2026-01-01' AND o.order_date <= '2026-12-31' | medium |
What's the total quantity of products sold in the last 30 days from the start of October 2026? | SELECT SUM(oi.quantity) AS total_quantity FROM orders o JOIN order_items oi ON o.order_id = oi.order_id WHERE o.order_date >= date('2026-10-01', '-30 days') AND o.order_date <= '2026-10-01' AND o.status <> 'cancelled' | medium |
How many orders were placed in the last 30 days? | SELECT COUNT(*) FROM orders WHERE order_date >= date('2026-10-01', '-30 days') | hard |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.