我有这个查询
select movie_name, user_name
from movie natural join movie_queue natural join users
group by (movie_name, user_name)
order by movie_name;
这会删除一个类似于下面的列表:
MOVIE_NAME USER_NAME
------------------------------------------------------- ------------------------
E.T. the Extra-Terrestrial Cris
E.T. the Extra-Terrestrial Elizabeth
E.T. the Extra-Terrestrial John
E.T. the Extra-Terrestrial Mary
E.T. the Extra-Terrestrial Peter
Indiana Jones and the Kingdom of the Crystal Skull Elizabeth
Indiana Jones and the Kingdom of the Crystal Skull John
Indiana Jones and the Kingdom of the Crystal Skull Mary
Jurassic Park Elizabeth
Jurassic Park John
Jurassic Park Mary
Jurassic Park Peter
Signs Elizabeth
The Sixth Sense Mary
Unbreakable John
Unbreakable Mary
Unbreakable Peter
War of the Worlds Elizabeth
War of the Worlds John
War of the Worlds Mary
War of the Worlds Peter
问题是如何按行流行度和 movie_name 排序?
我目前正在按电影名称对列表进行排序,但我也想将它们从最受欢迎的电影排序到不太受欢迎的电影。
期望的结果:
因此,“ET the Extra-Terrestrial”行应该首先出现,因为它在桌子上出现的次数更多,而“The Sixth Sense”应该最后出现,就在“Signs”之后。因为最后两部电影只出现了 1 次,但 S 在 T 之前。
我尝试添加:按计数排序(电影名称),电影名称;
但我仍然没有得到我想要的结果。最后电影应该这样组织
这就是我希望它们的组织方式:从更受欢迎到不太受欢迎,并按字母顺序排列
MOVIE_NAME USER_NAME
------------------------------------------------------- ------------------------
E.T. the Extra-Terrestrial Cris
E.T. the Extra-Terrestrial Elizabeth
E.T. the Extra-Terrestrial John
E.T. the Extra-Terrestrial Mary
E.T. the Extra-Terrestrial Peter
Jurassic Park Elizabeth
Jurassic Park John
Jurassic Park Mary
Jurassic Park Peter
War of the Worlds Elizabeth
War of the Worlds John
War of the Worlds Mary
War of the Worlds Peter
Indiana Jones and the Kingdom of the Crystal Skull Elizabeth
Indiana Jones and the Kingdom of the Crystal Skull John
Indiana Jones and the Kingdom of the Crystal Skull Mary
Unbreakable John
Unbreakable Mary
Unbreakable Peter
Signs Elizabeth
The Sixth Sense Mary
提前致谢