Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have the following table:

id | value | data | v
1  | val1  | dat1 | 1
2  | val1  | dat2 | 2
3  | val1  | dat3 | 3
4  | val2  | dat4 | 1

What I do is grab the data, each value, which has higher v. No what I mean ..

Sql output I would like:

id | value | data | v
3  | val1  | dat3 | 3
4  | val2  | dat4 | 1
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
224 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to identify the max value in a subquery and then join against the constant element

Fiddle

select * 
from 
    Table1  
       join 
   (select max(v) MAXV, value from Table1 group by value) T 
         on T.MAXV = Table1.v and T.value=Table1.value

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...