今天在做Portal中的Dashboard展现的时候,需要对多个统计字段做展现,根据我现在的掌握水平,我只能在sql调用构建器中实现一种sql语句返回的resultSet做展现。没有办法,只能从数据库的sql中入手,看看能不能实现在同一个sql语句中如何写不同条件的count数量。
终于在高手的指点下,写出了下面的成果
select
sum(case when (t.条件字段='00') then 1 else 0 end) "描述名称1",
sum(case when (t.条件字段='01') then 1 else 0 end) "描述名称2"
from 表名 t
sql知识的参考网站
http://sql.1keydata.com/cn/sql-syntax.php
终于在高手的指点下,写出了下面的成果
select
sum(case when (t.条件字段='00') then 1 else 0 end) "描述名称1",
sum(case when (t.条件字段='01') then 1 else 0 end) "描述名称2"
from 表名 t
sql知识的参考网站
http://sql.1keydata.com/cn/sql-syntax.php