A           B
530630      CC
530635      EE   
530639      DD--需要显示A列中最大值(530639)所对应的B列的名称(EE),只需要得出以下形式结果:
B
DD--请教高手是否可写自定义函数或其他什么之类的,谢谢...

解决方案 »

  1.   

    select B from 表 a where not exists(select 1 from 表 where A > a.A)
      

  2.   

    Select TOP 1 B From 表 Order By A Desc
      

  3.   

    select B from 表 where A = (select max(A) from 表)
      

  4.   

    簡潔沒用,論效率,這個應該是更高。select B from 表 where A = (select max(A) from 表)
      

  5.   

    declare @t table(A int ,B nvarchar(200))
    insert into @t select 530630,'CC'
    insert into @t select 530635,'EE'
    insert into @t select 530639,'DD'select B
    from @t
    where A in(select max(A) from @t)
      

  6.   

    select B from table_name where A=(select max(A) from table_name)