摘要: 方法一: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 阅读(48) 评论(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 阅读(284) 评论(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)
摘要: 1、union和union all 将两个表直接纵向合并。 2、对于两个表中重复的行,union取其中一个,union all都会显示 3、union和union all直需要保证两个表的列数相同,列名可以不同。 with t as ( select requester_id,accepter_id 阅读全文
posted @ 2021-05-24 20:11 luckie 阅读(111) 评论(0) 推荐(0)