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


浙公网安备 33010602011771号