只要后三条记录?
select top 3 * from table  order by A desc

解决方案 »

  1.   

    select top 3 *
    from talbename
    order by A DESC,B
      

  2.   

    select * into # from 表
    set rowcount 1
    delete from #
    set rowcount 0
    select * from #
    drop table #
      

  3.   

    select top 3 *
    from talbename
    order by A DESC,B
      

  4.   

    select top 3 *
    from talbename
    order by A DESC,B DESC
      

  5.   

    select distinct a,b from 表 where b=1
    union all
    select a,b from 表 t1 where not EXISTS (select 1 from 表 where a=t1.a and b=1)
      

  6.   

    如果是样呢
    表ABC
    A      B     C
    0001   0     100
    0001   1     50
    0002   0     100
    0002   0     100
    (上表中0未结算清,1表示已结算清)
    如果要统计所有项目(A)是否应该是这下表的内容
    A      B        C
    0001   结清     150
    0002   未结清   200如果是怎么写
    不是怎么写
      

  7.   

    select top 3 * from table  order by A desc , B asc 我想可以这样写啊
      

  8.   

    --测试数据---
    create table #ABC
    (A varchar(50) , B bit,C int)
    go
    insert into #ABC(A,B,C)
    select '0001',0,100
    union all 
    select '0001',1,50
    union all
    select '0002',0,100
    union all 
    select '0002',0,100
    select A,case B when 0 then '未结清' when 1 then '结清'  end as B,sum(C)  from #ABC
    group by A,B order by A---输出结果:------
      A        B        C
    0001 未结清 100
    0001 结清 50
    0002     未结清 200---应该是想要这样的结果吧!不知道有没有理解错你的意思!
      

  9.   

    开始问的明白了;后面的是我没说明白
    我是想按统计
    实际情况是这样的
    A是产品
    B是结算情况
    C是金额