如何并列显示出SQL查询结果 5
SELECTbb.dwmc,SUM(je4),count(*),ygxzfromjz2014aa,dwdmbbgroupbyaa.kmdm,aa.ygxzwhereaa....
SELECT bb.dwmc,SUM(je4),count(*),ygxz from jz2014 aa,dwdm bb group by aa.kmdm,aa.ygxz where aa.kmdm=bb.kmdm and je4>0 and ygxz='劳'
+
SELECT bb.dwmc,SUM(je4),count(*),ygxz from jz2014 aa,dwdm bb group by aa.kmdm,aa.ygxz where aa.kmdm=bb.kmdm and je4>0 and ygxz='合'
如何让结果并列显示出来,例如放炮队,合的25人,劳的23人,合的金额100,劳的金额120这种结果 展开
+
SELECT bb.dwmc,SUM(je4),count(*),ygxz from jz2014 aa,dwdm bb group by aa.kmdm,aa.ygxz where aa.kmdm=bb.kmdm and je4>0 and ygxz='合'
如何让结果并列显示出来,例如放炮队,合的25人,劳的23人,合的金额100,劳的金额120这种结果 展开
1个回答
展开全部
select a.dwmc,a.ygxz,sum(a.合) 合, sum(a.合人) 合人,sum(a.劳) 劳,sum(a.劳人) 劳人 from(
SELECT bb.dwmc,ygxz,SUM(je4) 合,count(*) 合人, 0 劳,0 劳人 from jz2014 aa,dwdm bb group by aa.kmdm,aa.ygxz where aa.kmdm=bb.kmdm and je4>0 and ygxz='劳'
union all
SELECT bb.dwmc,ygxz,0 合,0 合人,SUM(je4) 劳,count(*) 劳人 from jz2014 aa,dwdm bb group by aa.kmdm,aa.ygxz where aa.kmdm=bb.kmdm and je4>0 and ygxz='合'
) a group by a.dwmc,a.ygxz
SELECT bb.dwmc,ygxz,SUM(je4) 合,count(*) 合人, 0 劳,0 劳人 from jz2014 aa,dwdm bb group by aa.kmdm,aa.ygxz where aa.kmdm=bb.kmdm and je4>0 and ygxz='劳'
union all
SELECT bb.dwmc,ygxz,0 合,0 合人,SUM(je4) 劳,count(*) 劳人 from jz2014 aa,dwdm bb group by aa.kmdm,aa.ygxz where aa.kmdm=bb.kmdm and je4>0 and ygxz='合'
) a group by a.dwmc,a.ygxz
追问
谢谢你的回答,但是你的回答没有运行起来,很郁闷。有QQ吗?我加一下你。我的10417837
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询