如何将三个结果集进行合并显示

finaljia 发布于 2014/03/13 11:14

select sbkjdate,count(1) from sbgreen
where gzdmqsw between '0001' and '3099'
group by sbkjdate

select sbkjdate, count(1) from sbgreen
where gzdmzjlw between '01' and '40' and gzdmqsw between '0001' and '3099'
group by sbkjdate

select sbkjdate,count(1) from sbgreen
where gzdmzjlw between '70' and '99' and gzdmqsw between '0001' and '3099'
group by sbkjdate

0

0
f
select t1.sbkjdate sbkjdate,num,jx,dq,t4.sbkjnum sbkjnum from (
(select sbkjdate,count(1) num from sbgreen
where gzdmqsw between '0001' and '3099'
group by sbkjdate) t1 join
(select sbkjdate, count(1) jx from sbgreen
where gzdmzjlw between '01' and '40' and gzdmqsw between '0001' and '3099'
group by sbkjdate) t2 on t1.sbkjdate=t2.sbkjdate join
(select sbkjdate,count(1) dq from sbgreen
where gzdmzjlw between '70' and '99' and gzdmqsw between '0001' and '3099'
group by sbkjdate) t3 on t1.sbkjdate=t3.sbkjdate join
(select CAST(lx410a as int)+CAST(lx410c as int)+CAST(lxdfm15 as int)+CAST(lxdfm12 as int)
+CAST(lxdfm9 as int)+CAST(lxdfm6 as int)+CAST(lx602 as int)+CAST(lx402 as int)+CAST(lxwr as int)
+CAST(lxdof as int)+CAST(lxcrxf as int)+CAST(slsde as int)+CAST(sltb4 as int)+CAST(slcr as int)
+CAST(hsddx as int)+CAST(hszlj as int)+CAST(hszsrcl as int)+CAST(hsdlj as int)+CAST(hsdlycl as int) sbkjnum,
sbkjdate from sbkjdetail) t4 on t1.sbkjdate=t4.sbkjdate
) where t1.sbkjdate >= '2014-03-05' and t1.sbkjdate <= '2014-03-09'
order by sbkjdate asc
f