Eric Klaus
Eric Klaus

Reputation: 955

Selecting rows with max attribute value

I've the following table enter image description here

and I want to come up with the following table enter image description here

What I want is to select rows with largest version of each client. Tahnks in advance.

Upvotes: 0

Views: 537

Answers (2)

vhadalgi
vhadalgi

Reputation: 7189

select * from 
(
select *,rn=Dense_rank()over(partition by Clientid order by version desc) from table
)x
where x.rn=1

FIDDLE DEMO

Upvotes: 0

Vignesh Kumar A
Vignesh Kumar A

Reputation: 28413

Try this

SELECT * From Table1 T
         JOIN (SELECT clientid,Max(version) As MVer 
               From Table1 Group By clientid) S
         ON T.clientid = S.clientid And T.version  = S.MVer

Fiddle Demo

Upvotes: 4

Related Questions