The document contains two SQL queries. The first query selects various metrics like total orders, total spent, average spending per order, and average purchase price for two specific buyer IDs from an order transactions table, grouping the results by product name. The second query selects the top 10 products from the same table based on total quantity sold, grouping products into tiers based on the number of orders per unique date and summing various metrics like total orders and total sales.
The document contains two SQL queries. The first query selects various metrics like total orders, total spent, average spending per order, and average purchase price for two specific buyer IDs from an order transactions table, grouping the results by product name. The second query selects the top 10 products from the same table based on total quantity sold, grouping products into tiers based on the number of orders per unique date and summing various metrics like total orders and total sales.
The document contains two SQL queries. The first query selects various metrics like total orders, total spent, average spending per order, and average purchase price for two specific buyer IDs from an order transactions table, grouping the results by product name. The second query selects the top 10 products from the same table based on total quantity sold, grouping products into tiers based on the number of orders per unique date and summing various metrics like total orders and total sales.
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