where和having

测试数据

1、where作用是将不符合where条件的行去掉,不能包含聚合函数

select * from accu where buss_month='202109'

 

2、having是用在分组之后过滤数据,筛选满足条件的组,条件中经常包含聚合函数

select day_code,buss_month,count(*) from accu where buss_month='202109'
group by day_code,buss_month

 

 

筛选数据

select day_code,buss_month,count(*) from accu where buss_month='202109'
group by day_code,buss_month
having count(*)>1

 

 

posted @ 2021-10-24 22:22  微风徐徐$  阅读(48)  评论(0编辑  收藏  举报