列 aa bb cc dd 合计
3 0 0 0 3 查询结果如上
如何让查询出的数据结果为0 的列 不显示出来
如: aa 合计
3 3 select
count(case when 字段 like 'aa%' then 字段 else null end) aa,
count(case when 字段 like 'bb%' then 字段 else null end) bb,
count(case when 字段 like 'cc%' then 字段 else null end) cc,
.........
3 0 0 0 3 查询结果如上
如何让查询出的数据结果为0 的列 不显示出来
如: aa 合计
3 3 select
count(case when 字段 like 'aa%' then 字段 else null end) aa,
count(case when 字段 like 'bb%' then 字段 else null end) bb,
count(case when 字段 like 'cc%' then 字段 else null end) cc,
.........
select nullif(0,0),nullif(1,0) from dual
3 0 0 0 3
如何让查询出的数据结果为0 的列 不显示出来
想要的结果为: aa 合计
3 3
aa bb cc dd 合计
3 0 0 0 3
如何让查询出的数据结果为0 的列 不显示出来
想要的结果为:
aa 合计
3 3
这个应该是你前台显示部分来处理的吧,后台SQL中不应该处理这个的
substr(字段,1,2) col,
count(*) cnt
from table
group by substr(字段,1,2)
在前台用交叉表展现.应该能避免0数据的出现.