oracle同一张表几个数据怎么一行显示,如下
selectsum(t.cyinj+t.cernj+t.csannj+t.csinj)fromxsrstwheret.lb='随迁子女'andt.jieduan='3'a...
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.lb='随迁子女'and t.jieduan='3'and t.hang='8';
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.lb='其中:外省迁入'and t.jieduan='3' and t.hang ='9';
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.lb='总计'and t.jieduan='3';
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.cxlb in ('111','112') and t.jieduan='3'and t.lb='总计';
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.cxlb in ('121','122','123') and t.jieduan='3'and t.lb='总计';
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.cxlb in ('210','220') and t.jieduan='3'and t.lb='总计';
怎么一行显示 展开
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.lb='其中:外省迁入'and t.jieduan='3' and t.hang ='9';
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.lb='总计'and t.jieduan='3';
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.cxlb in ('111','112') and t.jieduan='3'and t.lb='总计';
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.cxlb in ('121','122','123') and t.jieduan='3'and t.lb='总计';
select sum(t.cyinj+t.cernj+t.csannj+t.csinj) from xsrs t where t.cxlb in ('210','220') and t.jieduan='3'and t.lb='总计';
怎么一行显示 展开
1个回答
展开全部
select
sum(case when t.lb='随迁子女'and t.jieduan='3'and t.hang='8' then t.cyinj+t.cernj+t.csannj+t.csinj else 0 end) 一,
sum(case when t.lb='其中:外省迁入'and t.jieduan='3' and t.hang ='9' then t.cyinj+t.cernj+t.csannj+t.csinj else 0 end) 二,
sum(case when t.lb='总计' and t.jieduan='3' then t.cyinj+t.cernj+t.csannj+t.csinj else 0 end) 三,
sum(case when t.cxlb in ('111','112') and t.jieduan='3' and t.lb='总计' then t.cyinj+t.cernj+t.csannj+t.csinj else 0 end) 四,
sum(case when t.cxlb in ('121','122','123') and t.jieduan='3' and t.lb='总计' then t.cyinj+t.cernj+t.csannj+t.csinj else 0 end) 五,
sum(case when t.cxlb in ('210','220') and t.jieduan='3' and t.lb='总计' then t.cyinj+t.cernj+t.csannj+t.csinj else 0 end) 六
from xsrs t
先试试,有问题继续追问,别名我起的一,二,三……,你可以自己改下别名
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询