I am a bit new at sql server and am trying to resolve a coding issue that I have come across.
I hope there is someone out there that might be able to assist me.
I am working with zip code +4 data and am trying to range the data to reduce the size of the database from the current ~65 million lines of data. The trick is that I need to range the data so that a single range created will include the same county and city. The problem as illustrated below is that the data jumps back and forth with city names and therefore a simple min/max script does not work.
I believe that a looped stored procedure script needs to be used to identify each instance of a city below so that for example 90001 0001-0004 would be identified as 1, 0005-0008 would be indentified as 2, 0009-0012 would be 3, and 0013-0015 would be 4 - then a min max script would be able to capture this. Any assistance would be terrific!
The data is currently arranged as such (example):
ZIP_CODE PLUS_FOUR COUNTY_NAME CITY_NAME
| 90001 |
0001 |
LOS ANGELES |
LOS ANGELES |
| 90001 |
0002 |
LOS ANGELES |
LOS ANGELES |
| 90001 |
0003 |
LOS ANGELES |
LOS ANGELES |
| 90001 |
0004 |
LOS ANGELES |
LOS ANGELES |
| 90001 |
0005 |
LOS ANGELES |
FONTAINE |
| 90001 |
0006 |
LOS ANGELES |
FONTAINE |
| 90001 |
0007 |
LOS ANGELES |
FONTAINE |
| 90001 |
0008 |
LOS ANGELES |
FONTAINE |
| 90001 |
0009 |
LOS ANGELES |
LOS ANGELES |
| 90001 |
0010 |
LOS ANGELES |
LOS ANGELES |
| 90001 |
0011 |
LOS ANGELES |
LOS ANGELES |
| 90001 |
0012 |
LOS ANGELES |
LOS ANGELES |
| 90001 |
0013 |
LOS ANGELES |
FONTAINE |
| 90001 |
0014 |
LOS ANGELES |
FONTAINE |
| 90001 |
0015 |
LOS ANGELES |
FONTAINE |