题解 | #统计2021年10月每个退货率不大于0.5的商品各项指标#

统计2021年10月每个退货率不大于0.5的商品各项指标

http://www.nowcoder.com/practice/cbf582d28b794722becfc680847327be

SELECT a.product_id, 
	  if( show_cnt=0,0,round(sum(if_click)/show_cnt,3 )) as ctr,
	  if( sum(if_click)=0,0,round(sum(if_cart)/sum(if_click),3) )   as cart_rate,
	  if( sum(if_cart)=0,0,round(sum(if_payment)/sum(if_cart),3 ) ) as payment_rate,
	  if( sum(if_payment)=0,0,round(sum(if_refund)/sum(if_payment),3) ) as refund_rate
from tb_user_event tb 
JOIN 
	(select product_id,count(uid) show_cnt from tb_user_event 
     where date_format(event_time,"%Y-%m")='2021-10' 
     GROUP BY product_id 
     )a
on tb.product_id=a.product_id
where date_format(event_time,"%Y-%m")='2021-10'
GROUP BY a.product_id
having refund_rate<=0.5 
ORDER BY product_id asc;



全部评论

相关推荐

缒梦&独舞:这家公司是这样的,去年给我实习offer了,不过也是面着玩儿的,他周六还要去做公益志愿活动
点赞 评论 收藏
分享
今天 15:12
门头沟学院 运营
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务