06 2021 档案

摘要:理解题目意思很重要,化繁为简的能力很重要。 题目意思中暗含Customer表中的product_key来自于Product表中的product_key。 注意:Customer表中同一个customer_id,product_key可以重复。Product表中的product_key也可以重复。因为 阅读全文
posted @ 2021-06-29 21:23 luckie 阅读(503) 评论(0) 推荐(0)
摘要:这道题很数学,需要转个弯。 方法一:使用case when后,如果学生人数是奇数,则改变了最后一个同学的座位。这时我们需要使用窗口函数重新进行一次排序。 select row_number() over (order by new_id) id,student from ( select case 阅读全文
posted @ 2021-06-29 20:58 luckie 阅读(268) 评论(0) 推荐(0)
摘要:做这道题,我的感受是,大体思路是对的,但是由于对于题目意识的理解不够清楚,细节上容易出错。 select round(avg(average)*100,2) average_daily_percent from ( select a.action_date,ifnull(part_count,0)/ 阅读全文
posted @ 2021-06-29 20:11 luckie 阅读(488) 评论(0) 推荐(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 阅读全文
posted @ 2021-06-27 21:30 luckie 阅读(106) 评论(0) 推荐(0)
摘要:方法一: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 阅读全文
posted @ 2021-06-27 21:11 luckie 阅读(46) 评论(0) 推荐(0)
摘要:方法一: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 阅读全文
posted @ 2021-06-27 19:52 luckie 阅读(283) 评论(0) 推荐(0)
摘要:#这里要去重 select a.follower,count(distinct(b.follower)) num from follow a inner join follow b on a.follower=b.followee group by a.follower; 阅读全文
posted @ 2021-06-02 14:53 luckie 阅读(51) 评论(0) 推荐(0)