|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Select highest version
Hello,
I have the following problem. I have three Columns name / version / package I want to create a select query, that shows me all names and their actuall package. The actual Package is the record with the highest version number. For Example my Database has the following entries : name / version / package name1 / 1 / package1 name2 / 1 / package1 name2 / 2 / package3 name3 / 1 / package2 The output should look like this : name1 / 1 / package1 name2 / 2 / package3 name3 / 1 / package2 Has anyone a idea and can help me ? Thanks in Advance Mirco |
|
#2
|
|||
|
|||
|
are there going to be names that don't have a version 1? if not, then you could just do a simple
select name,from Table_namewhere version = 1 |
|
#3
|
|||
|
|||
|
Hi, thanks for your answer, but i would have the names and packages with the highest version for each name
In my Example the name2 has two versions. Mirco |
|
#4
|
|||
|
|||
|
Code:
select name,version,package from t as q where version in (select max(version) from t where t.name = q.name) |
|
#5
|
|||
|
|||
|
Thanks thatīs it
Mirco |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Select highest version |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|