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'
可这样写是不对的,请大家帮忙,谢谢.....

解决方案 »

  1.   

    select cid,output,sum(base1+base2+base3) as fff from w where cid='1' group by fff
    也不对,提示,未发现列名,经确认是“fff”不能作为列名用
      

  2.   

    不用加sum()试试看
    select cid,output, (base1+base2+base3) as fff from w where cid='1'
      

  3.   

    select cid,output,sum(base1+base2+base3) OVER(ORDER BY CID) from where cid='1'
      

  4.   

    应该是你的
    where cid='1'
    有多个纪录,就需要group by 了
    或者select cid,sum(base1+base2+base3) from w 
        where cid='1'
        group by cid
      

  5.   

    可以這樣寫
    select cid,max(output),sum(base1+base2+base3) from w where cid='1'