4个语句怎么合并起来进行查询4个统计数据到一个表内:
全部合并用union all
去重合并用union
select xnxq , count(1) from ly_gkd_pyfa.v_t_xkgl_xqxkmd_all where xkzt = '1' and sfqr = '1' group by xnxq,统计人数xkrc
union all
select xnxq , count(1) from ly_gkd_pyfa.v_t_xkgl_xqxkmd_all where xkzt = '2'group by xnxq ,统计人数byrs
union all
select xnxq , count(1) from (
select case when substr(bypc,length(bypc)-1) <7 then substr(bypc,0,4 )|| '春季' else substr(bypc,0,4 )|| '秋季' end xnxq from ly_gkd_hxsj.t_bygl_xsbyjg
) group by xnxq 统计人数xjxgrs
union all
select sqxnxq xnxq , count(1) from T_XJGL_XJYDZL group by sqxnxq 统计人数xjrs
UNION和UNION ALL可以关联多个查询结果,详细可以参考下这个http://t.csdn.cn/ryIPx