SQL中怎么先对一个字段进行分组,在分组的情况下选择条件。

有两个字段A,B。先对A进行分组,在对A进行分组的条件下,将B字段都不为空的数据筛选出来。这个的语句怎么写,求大佬指点迷津一下。

不太明白你的意思,你想要的是不是
SELECT A AS A,B AS B WHERE B IS NOT NULL GROUP BY A

group by A having B is not null

select t.a from a_ppb_d t group by t.a having t.b is not null 提示不是group by 的表达方式

在只对A进行分组的情况下,无法对B进行筛选,因为查询出来的数据是不包括B的。

可以先把B为空的记录过滤掉然后再进行分组:

select * from (select * from table t where t.B is not null) tt group by tt.A;

select * from [table] wp where not exists(select 0 from [table] where [a]=wp.[a] and [b] is null)