Gnaniyar Zubair
Gnaniyar Zubair

Reputation: 8166

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":

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

version      title           
1.7           article1
1.6           article2
1.8           article3

how to achieve this?

Upvotes: 0

Views: 161

Answers (2)

Bassam Mehanni
Bassam Mehanni

Reputation: 14944

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

Upvotes: 3

JonH
JonH

Reputation: 33173

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

Upvotes: 4

Related Questions