select type,max(sign_step) from @table group by type

解决方案 »

  1.   

    select *,maxsign_step=(select max(sign_step) from @table where type=t.type) from @table t这样?
      

  2.   


     select * from @table a where exists( select 1 from
           (select type,max(sign_step) sign_step from @table group by type)T where a.Type=T.Type and a.sign_step = T.sign_step)
      

  3.   

    select signid,[type],max(rank) from
    (
     select *,row_Number() over(partition by [type] order by signid desc) rank from @table
    )T group by signid,[type]
      

  4.   

    或者:select * from @table t where not exists(select 1 from @table where type=t.type and sign_step>t.sign_step)
      

  5.   

    select * from @table t where not exists(select 1 from @table type=t.type and sign_step>t.sign_step)
      

  6.   

    select
      *
    from 
      @table t
    where
      sign_step in(select top 1 sign_step from @table where type=t.type order by sign_step desc)
      

  7.   

    我用嵌套查询实现了。
    就是
    select a.signid 
    from @table a,(select type,max(sign_step) as sign_step from @table group by type) b
    where a.type=b.type
       and a.sign_step = b.sign_step
    谢谢各位!结贴给分了