SQL Recipes
A FREE cookbook for SQL queries and examples
Register FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 07-21-2008, 06:43 PM
PGT96drvr PGT96drvr is offline
Junior Member
 
Join Date: Jul 2008
Posts: 1
PGT96drvr is on a distinguished road
Default ANY dialect question:

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

ANSWER(S):

  #2 (permalink)  
Old 07-21-2008, 08:46 PM
Dimitar
 
Posts: n/a
Default ANY answer. Re: Need to eliminate dupes sharing first 10 digits

SELECT MAX(v) FROM ie GROUP BY SUBSTRING(v FROM 1 FOR 10);
?

I think this is valid SQL92, but I am not sure.
You may want to modify the substring if your engine does not support this syntax (the syntax itself is certainly valid)

HTH,
Dimitar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-30-2008, 10:50 AM
veena
 
Posts: n/a
Default ANY answer. Re: Need to eliminate dupes sharing first 10 digits

Select Ieno As Ie1 From
(select First1,max(ie) As Ieno From
(select Substr(char(ie),1,10) As First1,ie From Stdnt)a
Group By First1)b
Order By Ieno Desc;
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 10:37 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2008 SQL Recipes

1 2 3 4 5 6 7 8