id是什么类型?字符串?整型?
Select * 
  From yourtable
 Where id like '20020501%'
   and right(id,2) = (Select right(Max(id),2) 
                        From yourtable
                       Where id like '20020501%')

解决方案 »

  1.   

    select max(convert(numeric(9,0),id))
    from table where id like '20020501%'
    试试这样
      

  2.   

    是MSSQL数据库吗?字符型(varchar还是char)
    Select * 
      From yourtable
     Where id like '20020501%'
       and substring(id,9,2) = (Select substring(Max(id),9,2) 
                            From yourtable
                           Where id like '20020501%')
      

  3.   

    Select * From yourtable where id=(select max(id) as id from yourtable where id like '20020501%')
    --或者
    Select * From yourtable where id=(select max(id) as id from yourtable where id>'20020501' and id<'20020502')
    --建议用此语句,有索引的话可以用到
      

  4.   

    有那么复杂吗?直接这样不行吗?
    Select max(id) as id From tablename Where id like '20020501%'
      

  5.   

    to: nichole() 不行, numeric(9,0)是什么意思?to:: qybao(阿宝) 
    是asa7数据库