You are on page 1of 1

Select buyer_id as “Userid”, l1_cat as “Main Category”, COUNT(order_id) as “Total Orders”,

SUM(gmv) as “Total Spent(RM)”, product_name as “Unique Items Bought”, order_date, AVG(gmv)


as “Avg Spending per Order (RM)”, AVG(price) as “Avg Purchase Price (RM)”

FROM my_order_trans

WHERE buyer_id = “576123” AND buyer_id = “123152”

GROUP BY product_name;

b)

Select TOP 10 from (

Select product_id as Item ID, product_name as Item Name, l1_cat as “category”,


IF(COUNT(order_id)/UNIQUE(order_date) > 20, “short tail”,
IF(IF(COUNT(order_id)/UNIQUE(order_date) > 10, “mid tail”, “long tail”)) as Tier,
SUM(COUNT(order_id)) as “Total Qty Sold”, SUM(gmv) as Total GMV, SUM(COUNT(order_id)) as
Total Orders

FROM my_order_trans

ORDER BY SUM(COUNT(order_id)) DESC

You might also like