Solved

list all zip to zip permutations

Posted on 2011-09-12
4
409 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
Comment Utility
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
Comment Utility
SELECT t1.zip, t2.zip FROM YourTable t1 JOIN YourTable t2 ON T1.zip <>T2.zip
0
 
LVL 75

Expert Comment

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

Author Comment

by:k1ng87
Comment Utility
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now