我本地通过,然后一直说我答案结果不对,我晕了,有大神
知道我这个哪里错了,附上代码~~谢谢啦 select aa.userid, round(aa.cnt_1d,1) as cnt_1d,round(aa.amt_1d,1) as amt_1d,round(bb.cnt_7d,1) as cnt_7d,round(bb.amt_7d,1) as amt_7d,round(cc.cnt_15d,1) as cnt_15d,round(cc.amt_15d,1) as amt_15d
from
(SELECT userid,count(*) as cnt_1d,sum(amount) as amt_1d
FROM edw_htl_order
where datediff('2020-07-16',orderdate)<= 1
group by userid
order by userid)aa
join
(SELECT userid,count(*) as cnt_7d,sum(amount) as amt_7d
FROM edw_htl_order
where datediff('2020-07-16',orderdate)<= 7
group by userid)bb
on aa.userid = bb.userid
join
(SELECT userid,count(*) as cnt_15d,sum(amount) as amt_15d
FROM edw_htl_order
where datediff('2020-07-16',orderdate)<= 15
group by userid)cc
on bb.userid = cc.userid
全部评论
(3) 回帖