MYSQL group by month,year and get highest score for month -
please me?
i trying last 10 winners photo of month competition recent first excluding current month, here have far:-
select *, max(total_score) comp_images date_added between date_sub(curdate(),interval 10 month) , curdate() , concat(month(curdate()),'',year(curdate())) != concat(month(date_added),'',year(date_added)) , url != '' , hide = '0' group month(date_added) order total_score desc limit 10
any appreciated.
thanks
my guess getting images back, max total score. problem here separately selecting rows (with *) , max(total_score) have not bound them together.
what solve using having keyword of mysql. can give criteria select rows statement. example:
select * comp_images..... having max(total_score);
Comments
Post a Comment