SELECT *,max(time) as max_time FROM t_table_1 where time>'1285862400' and time<'1293724800' group by name HAVING time=max_time order by max_time descgroup by 先分组,去重,然后时间,或者等级,或者名字排序,头疼啊

解决方案 »

  1.   

    没看懂。估计你想要这个。参考下贴中的多种方法http://topic.csdn.net/u/20091231/16/2f268740-391e-40f2-a15e-f243b2c925ab.html
    [征集]分组取最大N条记录方法征集,及散分....
      

  2.   

    http://blog.csdn.net/microji/archive/2009/02/12/3880975.aspx这帖子不错
      

  3.   

     (不要高估你的汉语表达能力或者我的汉语理解能力)
       建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
       4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
       
       这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。   
      

  4.   


    SELECT * FROM (SELECT * FROM t_table_1 where create_time>'1285862400' and create_time<'1293724800' ORDER BY record_time DESC,create_time desc) AS NEW  where create_time>'1285862400' and create_time<'1293724800' GROUP BY  name order by record_time desc,create_time desc limit 0,10这样就对了   嘎嘎
      

  5.   

    不能select * from table group by id吧,应该select id from table group by id,分组的时候前面不能出去*的吧