id是什么类型?字符串?整型?
Select *
From yourtable
Where id like '20020501%'
and right(id,2) = (Select right(Max(id),2)
From yourtable
Where id like '20020501%')
Select *
From yourtable
Where id like '20020501%'
and right(id,2) = (Select right(Max(id),2)
From yourtable
Where id like '20020501%')
from table where id like '20020501%'
试试这样
Select *
From yourtable
Where id like '20020501%'
and substring(id,9,2) = (Select substring(Max(id),9,2)
From yourtable
Where id like '20020501%')
--或者
Select * From yourtable where id=(select max(id) as id from yourtable where id>'20020501' and id<'20020502')
--建议用此语句,有索引的话可以用到
Select max(id) as id From tablename Where id like '20020501%'
是asa7数据库