Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

list all zip to zip permutations

Posted on 2011-09-12
4
Medium Priority
?
459 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 2000 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

721 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