日期:2014-05-17 浏览次数:21035 次
select a,count(b) c_b from tb1 group by a
------解决方案--------------------
1楼正解!!!
------解决方案--------------------
用一个外连接即可搞定,思路:先找到要显示的a,再用a左外连接你的group语句,找到最终结果
SELECT t2.rn, NVL (t1.acount, 0) acount
FROM ( SELECT a, COUNT (a) acount
FROM tb1
GROUP BY a) t1,
( SELECT ROWNUM rn
FROM DUAL
CONNECT BY ROWNUM <= 3) t2
WHERE t1.a(+) = t2.rn