SQL where 子句 哪裡出错了?该如何解决

SQL where 子句 哪裡出错了?
Select  a.AA , a.BB    
From  a  left  join  b  on a.CC = b.CC  and a.BB = b.BB
where b.BB  is  not  NULL
group  by  a.AA ,  a.BB 

Select  a.AA , a.BB    
From  a  left  join  b  on a.CC = b.CC  and a.BB = b.BB
where  b.BB  is   NULL
group  by  a.AA , a.BB 

Select  a.AA , a.BB    
From  a  left  join  b  on a.CC = b.CC  and a.BB = b.BB

group  by  a.AA , a.BB 

為什麼前两个查询语句的结果总和不等於第三个查询语句??
------解决方案--------------------
left join引出了null值,到时你在group by,在你这个例子中实际上是distinct出现非预期的数据
------解决方案--------------------
如果 你的  a.BB 有 NULL 的话,你的结果肯定不相等。这是必然的。

因为你在


-- 使用了a.BB = b.BB , 
From  a  left  join  b  on a.CC = b.CC  and a.BB = b.BB


你查一下, select * from a where BB is null , 看看是不是有数据。。 ,必须有。。