SQL to drop last four digits from a 9 digit zip code

Database
Enthusiast

SQL to drop last four digits from a 9 digit zip code

Hello everyone,

I need some help figuring out how to drop the last four digits of a 9 digit zip code. If I have a list of subscribers with a couple hundred thousand that have zip codes withe the following format...."27751-9099". Is there anyway that I can remove the last four digits so that we can compare zip codes based on a 5 digit basis?

2 REPLIES
Junior Contributor

Re: SQL to drop last four digits from a 9 digit zip code

It's not dropping the last four digits, it's extracting the first five?

Good old "substring(zip_code from 1 for 5)"?

Dieter

Enthusiast

Re: SQL to drop last four digits from a 9 digit zip code

I never thought of it that way. Brilliant!!