简体   繁体   English

SQL查询以获取最大重复字段数

[英]SQL query to fetch maximum number of the repeated field

I need to write the sql query to fetch the maximum "version" of the row of "title": 我需要编写sql查询来获取“标题”行的最大“版本”:

version      title           
1.1           article1
1.3           article3
1.1           article2
1.7           article1
1.8           article3
1.6           article2

output should be: maximum version of article 1 ,2 3 are respectievly, 1.7,1.6,1.8 输出应为:第1条,第2条,第3条的最高版本分别为1.7、1.6、1.8

version      title           
1.7           article1
1.6           article2
1.8           article3

how to achieve this? 如何做到这一点?

SELECT 
      MAX(varsion),
      Title
FROM 
      MyTable 
GROUP BY Title
SELECT title, MAX(Version)
FROM MyTable
GROUP BY title

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM