日期:2014-05-17  浏览次数:21070 次

求一个查询语句,在线等...
w表结构:
cid           output     base       base2           base3            
1                   15             22       50.09             -5                    
2                   99           20.01         9               44.89              
希望一次得到这样的结果
对cid=1这条记录而言:
1           15             67.09
即查询是这条样的
select   cid,output,sum(base1+base2+base3)   from   w   where   cid= '1 '
可这样写是不对的,请大家帮忙,谢谢.....




------解决方案--------------------
select cid,output,sum(base1+base2+base3) OVER(ORDER BY CID) from where cid= '1 '
------解决方案--------------------
应该是你的
where cid= '1 '
有多个纪录,就需要group by 了
或者select cid,sum(base1+base2+base3) from w
where cid= '1 '
group by cid