如何才能使查询结果不出现null

select j1b.分公司 AS C,round(sum(金额万元),2) as total
from j1b
where exists ( select j1b.分公司 from j1b where j1b.分公司 is not null)#这行不起作用,没过滤掉null
group by j1b.分公司;
图片说明

select j1b.分公司 AS C,round(sum(金额万元),2) as total
from j1b
where j1b.分公司 is not null
group by j1b.分公司;

这样就可以,你的写法虽然里面判断了 j1b.分公司 不为空,但外面一层未加不为空的判断,因此出现那样的问题。

select j1b.分公司 AS C,round(sum(金额万元),2) as total
from j1b
where  j1b.分公司 is not null
group by j1b.分公司;

null 来自外部查询中的,所以你这里可以去掉子查询。在group by 后加个 having c is not null