Solved

list all zip to zip permutations

Posted on 2011-09-12
4
434 Views
Last Modified: 2012-05-12
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?
0
Comment
Question by:k1ng87
4 Comments
 
LVL 17

Expert Comment

by:Garry-G
ID: 36523879
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 ...
0
 
LVL 18

Accepted Solution

by:
deighton earned 500 total points
ID: 36523887
SELECT t1.zip, t2.zip FROM YourTable t1 JOIN YourTable t2 ON T1.zip <>T2.zip
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 36526728
And that is going to be a big table, with somewhere around 2.5 billion rows.
0
 
LVL 1

Author Comment

by:k1ng87
ID: 36531869
yeah...i dont think this is going to be practical as the row count will be insane...but the solution did work!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question