MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 21st, 2004, 06:08 PM
else50 else50 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 5 else50 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old September 21st, 2004, 06:49 PM
funky_G funky_G is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: nyc
Posts: 232 funky_G User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 32 m 52 sec
Reputation Power: 5
Send a message via AIM to funky_G
are there going to be names that don't have a version 1? if not, then you could just do a simple

select
name,
version,
package
from
Table_name
where
version = 1

Reply With Quote
  #3  
Old September 22nd, 2004, 02:40 AM
else50 else50 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 5 else50 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #4  
Old September 22nd, 2004, 05:59 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,784 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 21 h 42 m 49 sec
Reputation Power: 37
Code:
select name,version,package
from t as q
where version in (select max(version) from t
where t.name = q.name)

Reply With Quote
  #5  
Old September 24th, 2004, 03:37 PM
else50 else50 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 5 else50 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks thatīs it

Mirco

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Select highest version


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT