Welcome to Dream.In.Code
Become an Expert!

Join 150,132 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,175 people online right now. Registration is fast and FREE... Join Now!




Zipcode + 4 ranging

 
Reply to this topicStart new topic

Zipcode + 4 ranging, Help on ranging of zipcodes + 4

captruth
6 Aug, 2008 - 01:55 PM
Post #1

New D.I.C Head
*

Joined: 6 Aug, 2008
Posts: 1

Hey all;

I'm having a tough time getting my head around the following issues. I have a table with over 67 millions rows of data based upon Zipcodes + 4; i.e. 5-digits zipcode in one column and 4-digit suffix in another; for the entire us.

I need to range the sucker to reduce file sizes for export files. My problem is ranging the zipcode based upon the 4-digit +4 column.

I am using SQL Server 2005; I have tried the all the sorting and grouping options I know of along with DISTINCT MIN and MAX to no avail.

Everytime the 4-digit +4 changes cities (i.e. CITY_NAME) I need to group that as a specific range; if the same city picks up after that I need that to be a separate range. Here's the input and output;

Input:
90001 1125 06037 0624477 FLORENCE-GRAHAM
90001 1126 06037 0624477 FLORENCE-GRAHAM
90001 1127 06037 0644000 LOS ANGELES
90001 1128 06037 0644000 LOS ANGELES
90001 1129 06037 0624477 FLORENCE-GRAHAM
90001 1130 06037 0644000 LOS ANGELES
90001 1131 06037 0624477 FLORENCE-GRAHAM
90001 1132 06037 0644000 LOS ANGELES
90001 1133 06037 0624477 FLORENCE-GRAHAM
90001 1134 06037 0624477 FLORENCE-GRAHAM

Output:
90001 0001 1000 FLORENCE-GRAHAM 1
90001 1001 1098 LOS ANGELES 2
90001 1100 1126 FLORENCE-GRAHAM 3
90001 1127 1128 LOS ANGELES 4
90001 1129 1129 FLORENCE-GRAHAM 5
90001 1130 1130 LOS ANGELES 6
90001 1131 1131 FLORENCE-GRAHAM 7
90001 1132 1132 LOS ANGELES 8
90001 1133 1166 FLORENCE-GRAHAM 9
90001 1167 1168 LOS ANGELES 10

This is just a sample dataset I manipulated for 1 zipcode; dude I can't do that for the entire US!

Any help is appreciated

Mark
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 01:49AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month