--用Union all 啊select top 3 COUNT(*) as DD from 。
union all
select 'x','其它',sum(A.DD) from 
(
select top 3 COUNT(*) as DD from 。
) A

解决方案 »

  1.   

    select identity(int,1,) id,
           COUNT(*) as DD 
    into #
    from 。--查询
    select top 3 DD from # order by id
    union all
    select 'x','其他',sum(DD) from # where id>3
      

  2.   

    我想你的大概意思应该是这样的吧!declare @t table
    (id int,xueke varchar(20),fenshu int)
    insert @t values (1,     'a',      90)
    insert @t values (4,     'aa',     85)
    insert @t values (2,     'aaa',    80)
    insert @t values (3,     'aaa',    73)
    insert @t values (5,     'abc',    72)
    select * from
    (
    select top 3 id=cast(id as varchar),xueke,fenshu from @t order by fenshu desc
    ) a
    union all
    (select 'x','其他',(select sum(fenshu) from @t)-
    (select sum(fenshu) from 
    (
    select top 3 * from @t order by fenshu desc
    ) b) as fenshu)id                             xueke                fenshu      
    ------------------------------ -------------------- ----------- 
    1                              a                    90
    4                              aa                   85
    2                              aaa                  80
    x                              其他                   145(所影响的行数为 4 行)