自己表达太差了所以一面挂吧。。。问用户流失相关的问题,比如说应该给哪些人发放优惠券来确保他们不流失,怎么确保这类人不流失SQL:一个用户直播打赏表 user_author_live_amt,记录每天用户给每个主播打赏的金额,包含字段(p_date, user_id, author_id, total_cost_amt),分别为:格式为yyyymmdd的日期,打赏用户ID,被打赏主播ID,打赏金额)问题:查询累计打赏超过10万元的用户中,每个用户打赏总金额排名前3的主播ID和其被打赏总金额我的答案是:with total as(selectuser_id,sum(total_cost_amt) as total_sumfrom user_author_live_amtgroup by user_idhaving total_sum > 1000000),author as (selectuser_id,author_id,sum(total_cost_amt) as author_totalfrom user_author_live_amtgroup by user_id,author_id)select user_id,author_id, author_totalfrom (selecta.user_id,a.author_id,a.author_totalrow_number()over(partition by a.user_id order by a.author_total desc) rankingfrom author ajoin total t on a.user_id = t.user_id)swhere ranking <= 3;