我需要帮助mysql顺序,我有这个查询
SELECT
videos_views.videos_views_id,
videos_views.videos_views_date,
SUM(IF(MONTH(videos_views.videos_views_date) = 2, videos_views.videos_views_total, 0)) AS total_view,
videos.videos_id,
videos.videos_title,
videos.videos_description,
videos.videos_author_list_id,
author_list.author_list_name,
author_list.author_list_id
FROM videos
LEFT OUTER JOIN author_list
ON videos.videos_author_list_id = author_list.author_list_id
LEFT OUTER JOIN videos_views
ON videos.videos_id = videos_views.videos_views_id
WHERE author_list.author_list_video_type = 1
AND videos.videos_id >= 51108
GROUP BY videos_views.videos_views_id,
videos.videos_id
ORDER BY CASE WHEN MONTH(videos_views.videos_views_date) = 2 THEN SUM(videos_views.videos_views_total) END DESC,
CASE WHEN MONTH(videos_views.videos_views_date) <> 2 THEN videos.videos_id END DESC
LIMIT 11
它返回以下结果
如果我使用DESC或ASC使用第一个订单返回上面相同的结果。
我使用ASC使用第二个顺序返回结果:
我需要查询以下列顺序返回值
请帮帮我
答案 0 :(得分:2)
您的结果表明您想要:
order by total_views desc, videos_id desc
您可以在order by
。