#统计2021年10月每个退货率不大于0.5的商品各项指标#
统计2021年10月每个退货率不大于0.5的商品各项指标
https://www.nowcoder.com/practice/cbf582d28b794722becfc680847327be
SELECT product_id, FORMAT(IFNULL(SUM(if_click)/NULLIF(COUNT(*),0),0),3) as ctr, FORMAT(IFNULL(SUM(if_cart)/NULLIF(SUM(if_click),0),0),3) as cart_rate, FORMAT(IFNULL(SUM(if_payment)/NULLIF(SUM(if_cart),0),0),3) as payment_rate, FORMAT(IFNULL(SUM(if_refund)/NULLIF(SUM(if_payment),0),0),3) as refund_rate FROM tb_user_event WHERE DATE_FORMAT(event_time,"%Y-%m")='2021-10' GROUP BY product_id HAVING refund_rate<=0.5 ORDER BY product_id