Select decode(a.Type,1,'ONE',2,'TWO',null ,'OTHER')||
Decode (b.Active, 1 ,'Yes',0,'NO', null ,'NO'),
count(*)
from TypeTable a,
Status b
where a.id=b.id
and a.type in(12,3,34,45,66);
现在的问题是,
我想计算那些有记录的类型1和其他的人 喜欢
Column1 | Column2
---------------+----------
One | 10
ONE
Other that ONE | 20
答案 0 :(得分:0)
我不确定你想要什么。也许你正在寻找类似于我的例子。
select decode(object_type,'SYNONYM','SYNONYM','OTHER THAN SYNONYM') column1, count(*) column2 from user_objects
group by decode(object_type,'SYNONYM','SYNONYM','OTHER THAN SYNONYM');