0% found this document useful (0 votes)
48 views3 pages

Questions and Answers On E-Commerce Analytics

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views3 pages

Questions and Answers On E-Commerce Analytics

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

QUESTIONS AND ANSWERS ON

On E-Commerce Analytics
1.Rank Products by Total Sales Value?

select product_id,product_name,sum(price) as Total_Sales,

rank() over( order by sum(price) desc) as Rank_Products

from products

group by product_id,product_name;

2.Find Customers Who Made Orders in Consecutive Months?

SELECT c.customer_id,c.customer_name,

LAG(MONTH(order_date), 1) OVER (PARTITION BY c.customer_id ORDER BY order_date) AS


prev_month,

MONTH(order_date) AS current_month

FROM Customers c

JOIN Orders o ON c.customer_id = o.customer_id

HAVING current_month - prev_month = 1;

3.Find Top 3 Customers by Total Order Value?

select c.customer_id,c.customer_name,sum(o.total_amount) as Total_Order_Value

FROM Customers c

JOIN Orders o ON c.customer_id = o.customer_id

group by c.customer_id,c.customer_name

order by Total_Order_Value desc

limit 3;
4.Calculate Cumulative Revenue Over Time?

select order_date,

sum(total_amount) over(order by order_date ) as Cumulative_Revenue

from orders;

5.Products with the Highest Average Review Rating?

select p.product_name,avg(r.rating) as Avg_Rating

from products P join reviews r on p.product_id=r.product_id

group by p.product_name;

6.Find Customers Who Have Never Reviewed a Product?

SELECT customer_name

FROM Customers c

LEFT JOIN Reviews r ON c.customer_id = r.customer_id

WHERE r.review_id IS NULL;

7. Find the Most Expensive Product Sold by Category?

select category,product_name,price as Most_Expensive_Product FROM products

WHERE (category, price) IN (

SELECT category, MAX(price)

FROM Products

GROUP BY category);

8.Calculate the average number of products ordered per month?

SELECT MONTH(order_date) AS order_month, AVG(quantity) AS avg_quantity

FROM Orders

GROUP BY order_month;
9.Find the number of orders placed by customers from each country?

SELECT country, COUNT(order_id) AS total_orders

FROM Customers c

JOIN Orders o ON c.customer_id = o.customer_id

GROUP BY country;

10.Find products that have been ordered by more than one customer?

SELECT product_name

FROM Products p

JOIN Orders o ON p.product_id = o.product_id

GROUP BY product_name

HAVING COUNT(DISTINCT customer_id) > 1;

You might also like