日期:2014-05-19  浏览次数:20452 次

简单问题,请教高手,搞定马上结贴

Select   sum(InMoney)   as   系统总充值额   from   einOutMoney   where   Kind   in   (100,105,107,201,101)   and   UseType   <> 7
union   all
select   sum(saveMoney)   as   补助总额   from   eSaveMoney   where   UseType=7
union   all
Select   sum(COnsumeMOney)   as   系统消费总额   from   eCOnsumeData
union   all
Select   sum(CardValue)   as   系统卡余总额   from   cCard  
union   all
select   sum(OutMoney)   as   退款总额   from   eInOutMoney   where   kind   in(102,106,156)
union   all
Select   sum(InMoney)   as   收押金总额   from   einOutMoney   where   Kind=50
union   all
Select   sum(OutMoney)   as   退押金总额   from   eInOutMoney   where   Kind=52

我这样得到的记录是一个字段,N多行,我现在想要的是1行,包含N个字段
要怎么改,请指教

------解决方案--------------------
select * from (
Select sum(InMoney) as 系统总充值额 from einOutMoney where Kind in (100,105,107,201,101) and UseType <> 7)a
cross join (
select sum(saveMoney) as 补助总额 from eSaveMoney where UseType=7)b
cross join (
Select sum(COnsumeMOney) as 系统消费总额 from eCOnsumeData)c
cross join (
Select sum(CardValue) as 系统卡余总额 from cCard )d
cross join (
select sum(OutMoney) as 退款总额 from eInOutMoney where kind in(102,106,156))e
cross join (
Select sum(InMoney) as 收押金总额 from einOutMoney where Kind=50)f
cross join (
Select sum(OutMoney) as 退押金总额 from eInOutMoney where Kind=52)g
------解决方案--------------------
union all不对啊,呵呵 !这样只会有一列
cross join 可以产生多列(笛卡尔集合)
但是我看这个查询怎么这么别扭啊!