I am using following very simple query but the result is not proper. It is giving me wrong combination of highest (MAX(media.cnt_like + IFNULL(media.media_views ,0))
) and media
.media_id
SELECT `media`.`media_id`, `media`.`media_name`, MAX(media.cnt_like + IFNULL(media.media_views ,0)) as highest, `media`.`cnt_like`, `media`.`media_views`, `media`.`user_id` FROM `media` LEFT JOIN `users` ON users.user_id = media.user_id WHERE ( (`media`.`is_profile_img`=0) AND (`media`.`is_banner_img`=0) AND (`media`.`is_category_img`=0) AND (`media`.`deleted_at` IS NULL)) AND (`users`.`category_id` IN (2, 26) ) GROUP BY `media`.`user_id` ORDER BY MAX(media.cnt_like + IFNULL(media.media_views ,0)) DESC
The issue with GROUP_BY
clause.
MySQL version is 5.7.20 on Ubuntu 17.10 and i have checked this with MySQL version 5.5.58 on Ubuntu 14.04 too
Any help would be appreciable.