具体SQL如下,表名table,查询列名Age varchar2类型 有什么区别呢 数据量百万时哪个运行效率快一点
select
count(decode(t.Age,'20',1,null) ) as Age等于20数量count,
sum(decode(t.Age,'20',1,null)) as Age等于20数量sum,
count(case when t.Age='20' then 1 else 0 end) as Age等于20的数量casecount,
sum(case when t.Age='20' then 1 else 0 end) as Age等于20的数量casesum
from table t;