本帖最后由 zhoumengkang 于 2013-05-31 10:45:07 编辑

解决方案 »

  1.   

    select * from tt a where not exists(select 1 from tt
    where a.mydate=mydate and a.flag<flag
    or
    a.mydate=mydate and a.flag=flag and a.price<price
    )
      

  2.   

    你的SQL语句本来就不是标准的SQL语句,用EXISTS解决
      

  3.   

    SELECT * 
    FROM (
    SELECT * 
    FROM t
    ORDER BY flag DESC , price DESC
    )tt
    GROUP BY mydate
    这个没有问题。
      

  4.   

    这样写的时候order by后面的语句起不到效果,是不是因为先执行的group by 而,group by 只会拿mydate相同的第一条;
    GROUP BY对非聚合列,则由MYSQL随意取一条,一般是取第一条。所以要先ORDER再GROUP