select max(mtime)
from tableName
where mtime like '2004%';

解决方案 »

  1.   

    不好意思
    刚没看清你的意思
    应该这样写:
    select left(mtime,6),max(mtime)
    from tableName
    group by left(mtime,6);
      

  2.   

    我现在想查询指定一年里面所有的月份id最大一条记录
    ===> id 是會麼意思?
      

  3.   

    SELECT MAX(substring(left(mtime,6),4))
    FROM tbl_name
    WHERE left(mtime)= 指定年;是这个意思吗?
      

  4.   

    查2004年所有月份的最大mtime
    select left(mtime,6),max(mtime)
    from tableName
    where left(mtime,4) = '2004'
    group by left(mtime,6);
      

  5.   

    select * from table where mtime like '2004%' order by mtime desc limit 1;