Solved

list all zip to zip permutations

Posted on 2011-09-12
4
454 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 18

Expert Comment

by:Garry Glendown
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Azure Functions is a solution for easily running small pieces of code, or "functions," in the cloud. This article shows how to create one of these functions to write directly to Azure Table Storage.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

627 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