99999久久久久久亚洲,欧美人与禽猛交狂配,高清日韩av在线影院,一个人在线高清免费观看,啦啦啦在线视频免费观看www

熱線電話:13121318867

登錄
2022-08-16 閱讀量: 838
shein面試題 查詢每個(gè)月不同收貨國(guó)家購(gòu)買金額排名前300名的新用戶信息,購(gòu)買金額相同則排名相同(但排名不連續(xù))。

問(wèn)題:

1

{)}LJQD_9XEID)KSM(7S46G.jpg

2

答案:

第2題:

select *
from
(select date_format(min(pay_dt),'%Y-%m') as 月份,country as 國(guó)家,'新用戶' as 用戶類型,user_id as 用戶id,sum(pay_dt=首次購(gòu)買時(shí)間) as 新用戶訂單數(shù),sum((pay_dt=首次購(gòu)買時(shí)間)*cost_amt) as 新用戶訂單金額,rank() over(partition by date_format(min(pay_dt),'%Y-%m'),country order by sum((pay_dt=首次購(gòu)買時(shí)間)*cost_amt) desc) as 排名
from
(select *,min(pay_dt) over(partition by user_id) as 首次購(gòu)買時(shí)間 from dw_shein_pay_order_da) as t1
group by country,user_id) as t2
where 排名<=300;


第3題:

select
date_format(首次購(gòu)買時(shí)間,'%Y-%m') as 月份,
country as 國(guó)家,
count(distinct if(pay_dt=首次購(gòu)買時(shí)間,user_id,null)) as 新用戶數(shù),
count(distinct if(timestampdiff(day,首次購(gòu)買時(shí)間,pay_dt)<=30),user_id,null) as 30日復(fù)購(gòu)用戶數(shù),
sum(if(timestampdiff(day,首次購(gòu)買時(shí)間,pay_dt)<=30),pay_amt,null) as 30日復(fù)購(gòu)金額,
count(distinct if(timestampdiff(day,首次購(gòu)買時(shí)間,pay_dt)<=30),user_id,null)/count(distinct if(pay_dt=首次購(gòu)買時(shí)間,user_id,null)) as 30日復(fù)購(gòu)率
from
(select * ,min(pay_dt) over(partition by user_id) as 首次購(gòu)買時(shí)間 from dw_shein_pay_order_da) as t
group by date_format(首次購(gòu)買時(shí)間,'%Y-%m'),country;


0.0000
0
關(guān)注作者
收藏
評(píng)論(0)

發(fā)表評(píng)論

暫無(wú)數(shù)據(jù)
推薦帖子