Mysql:选择all而不重复列

时间:2018-01-17 15:11:03

标签: mysql distinct

我希望选择所有列但不重复列存储(抱歉我的英文不好) 代码mysql:

SELECT * FROM store order by views DESC

enter image description here

这就是我想要的结果

enter image description here

1 个答案:

答案 0 :(得分:1)

目前还不清楚你想要什么,但请尝试以下方法:

select * from store s1 join (
    SELECT store, max(views) as views FROM store group by store ) s2 on s1.store = s2.store and s1.views = s2.views 
order by s1.views DESC