2021-03-02
閱讀量:
1605
sql題: 查詢2019年1月1日至今,每天的注冊用戶數(shù),下單用戶數(shù),以及注冊當(dāng)天即下單的用戶數(shù)
問:
sql題:
查詢2019年1月1日至今,每天的注冊用戶數(shù),下單用戶數(shù),以及注冊當(dāng)天即下單的用戶數(shù)
答:
參考答案:
selecttable_date.reg_tm,ifnull(count( distincttable_user.user_id), 0) 注冊用戶數(shù),ifnull(count( distincttable_order.user_id), 0) 下單用戶數(shù),ifnull(count( distinctif(table_user.reg_time=table_order.order_timeand table_user.user_id=table_order.user_id,table_user.user_id,null)), 0) 下單用戶數(shù) from( selectreg_tm fromtable_user union selectorder_tm fromtable_order) astable_date left jointable_user ontable_date.reg_tm=table_user.reg_tm left jointable_order ontable_date.reg_tm=table_order.order_tm wheretable_date.reg_tm>= "2019-01-01" groupbytable_date.reg_tm;
參考文章:https://www.sohu.com/a/331210295_178408






評論(0)


暫無數(shù)據(jù)
推薦帖子
0條評論
0條評論
0條評論