• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 471
  • Last Modified:

list all zip to zip permutations

I have a zip code listing and need to create a zip to zip listing. The order of the zips do matter so if I have 01001 to 17325, i still would need the reverse too, 17325 to 01001. I don't think I can do this in excel because of the 1 million row limit but can I do this in sql?
1 Solution
Garry GlendownConsulting and Network/Security SpecialistCommented:
Pretty simple code ...

select a.zipcode FromZip, b.zipcode ToZip from zip a, zip b where a.zipcode!=b.zipcode;

Open in new window

Drop the "where" if you also want same zipcodes listed as from and to ...
SELECT t1.zip, t2.zip FROM YourTable t1 JOIN YourTable t2 ON T1.zip <>T2.zip
Anthony PerkinsCommented:
And that is going to be a big table, with somewhere around 2.5 billion rows.
k1ng87Author Commented:
yeah...i dont think this is going to be practical as the row count will be insane...but the solution did work!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now