06 2021 档案
摘要:理解题目意思很重要,化繁为简的能力很重要。 题目意思中暗含Customer表中的product_key来自于Product表中的product_key。 注意:Customer表中同一个customer_id,product_key可以重复。Product表中的product_key也可以重复。因为
阅读全文
摘要:这道题很数学,需要转个弯。 方法一:使用case when后,如果学生人数是奇数,则改变了最后一个同学的座位。这时我们需要使用窗口函数重新进行一次排序。 select row_number() over (order by new_id) id,student from ( select case
阅读全文
摘要:做这道题,我的感受是,大体思路是对的,但是由于对于题目意识的理解不够清楚,细节上容易出错。 select round(avg(average)*100,2) average_daily_percent from ( select a.action_date,ifnull(part_count,0)/
阅读全文
摘要:方法一: select product_id,product_name from ( select a.product_id,product_name, case when sale_date<='2019-03-31' and sale_date>='2019-01-01' then 0 else
阅读全文
摘要:方法一:case when语句 select buyer_id from ( select buyer_id, case product_name when 'S8' then 0 else 1 end as r from Sales a left join Product b on a.produ
阅读全文
摘要:方法一:dense_rank()结合group by一起使用 select seller_id from ( select seller_id, dense_rank() over (order by sum(price) desc) r from Sales group by seller_id
阅读全文
摘要:#这里要去重 select a.follower,count(distinct(b.follower)) num from follow a inner join follow b on a.follower=b.followee group by a.follower;
阅读全文

浙公网安备 33010602011771号