什么是前十条?
select sum(c1) from 
( select row_number() over ( order by c1 ) as no,c1 from table1 ) as temp
  where no < 11
这样行不?

解决方案 »

  1.   

    select sum(c1) from 
    (select top 10 * from table1 order by c1)
      

  2.   

    试一下这:
    select sum(table2.cl) from (select c1 from table1 fetch first 10 rows only)
    as table2
      

  3.   

    可以使用WITH语句with AA (amount)
    As (
    select c1 from table1 fetch first 10 rows only  )select sum(amount) from AA 
      

  4.   

    真是奇怪,以下两条语,第一个成功,加了fetch就不行了,为什么???
    第一个:
    select col_temp from
    (select * from temp ) temp1第二个:
    select col_temp from
    (select * from temp fetch first 10 rows only ) temp1出错信息为:
    SQL0104N  在 "rom (select * from a" 之后发现意外的记号
    "fetch"。期望的记号可能包括:")"。  SQLSTATE=42601
      

  5.   

    select sum(c1) from f_factinfo fetch first 10 rows only