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 July 21st, 2008, 02:46 PM
PGT96drvr PGT96drvr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 1 PGT96drvr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 8 sec
Reputation Power: 0
Need to eliminate dupes sharing first 10 digits

Need to eliminate dupes sharing first 10 digits, but keep the highest valued entry.

IE:

8001234567
800123456701
800123456702
900345678901
900345678903
....

From just these 5 entries, I would like to just get these results:

800123456702
900345678903

Thanks, and I appreciate any help/information

Reply With Quote
  #2  
Old July 22nd, 2008, 04:26 AM
NimirRamon NimirRamon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 21 NimirRamon User rank is Sergeant (500 - 2000 Reputation Level)NimirRamon User rank is Sergeant (500 - 2000 Reputation Level)NimirRamon User rank is Sergeant (500 - 2000 Reputation Level)NimirRamon User rank is Sergeant (500 - 2000 Reputation Level)NimirRamon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 17 h 27 m 18 sec
Reputation Power: 0
Quote:
Originally Posted by PGT96drvr
Need to eliminate dupes sharing first 10 digits, but keep the highest valued entry.

IE:

8001234567
800123456701
800123456702
900345678901
900345678903
....

From just these 5 entries, I would like to just get these results:

800123456702
900345678903

Thanks, and I appreciate any help/information


This seems a little contrived..... homework assignment perchance?

Given my suspicions Ill just give a few clues as to how Id approach this.

Look at the MAX and substring functions and group by clause.

The simplest way I can think of would return two rows, the shared 10 digits, and the full maximum value

You could put the two row returning query inside another to return just the part you want.

Reply With Quote
  #3  
Old July 22nd, 2008, 07:38 AM
pdreyer pdreyer is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2007
Posts: 45 pdreyer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 54 m 17 sec
Reputation Power: 1
select max group by left(col1,10)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Need to eliminate dupes sharing first 10 digits


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 6 hosted by Hostway
Stay green...Green IT