没有好方法,指能先distinct再排序了。

解决方案 »

  1.   

    SELECT id, pid, max( date ) 
    FROM test
    GROUP BY pid ASC 
      

  2.   

    select max(id),p_id from 表名
    group by p_id
    order by p_id 排序你可以自由更改
      

  3.   

    执行结果如你所愿.
    哪里错了?
    SELECT max(id),p_id 
    FROM   test
    GROUP BY  p_id
    ORDER BY  p_id ========================
    1,2
    3,3
    4,4
      

  4.   

    PostgreSQL 数据库 不能用max
      

  5.   

    SELECT id, pid, max( date ) a  FROM test GROUP BY pid order by a desc
      

  6.   

    原来是PS,
    子查询中用max应该可行
      

  7.   

    如果不能用子查询,就得用分组统计,
    如果不能用max,基本上就不用想了