Results 1 to 4 of 4

Thread: Help needed in retrieving a tricky data!!

  1. #1
    Join Date
    Nov 2010
    Posts
    2

    Help needed in retrieving a tricky data!!

    Now i have a table which has some 25 fields.
    My concern is about two fields. One is a City field and the other one is Postal code field.
    What i want my query to do is, It should help me retrieve records that have Distinct cities with same Postal code.

    Any help would be greatly appreciated!
    Thanks!

  2. #2
    Join Date
    Apr 2009
    Posts
    86
    vetri08, I am not sure if I understand what you want. I think you want to find where different city names have the same postal code. If that is the case, this should work:
    Code:
    SELECT A.CITY_NAME, B.CITY_NAME, A.POSTAL_CODE
    FROM TABLE A
       , TABLE B
    WHERE A.CITY_NAME <> B.CITY_NAME
      AND A.POSTAL_CODE = B.POSTAL_CODE

  3. #3
    Join Date
    Nov 2010
    Posts
    2
    Hi Sdas,

    Thanks for the help buddy. The scenario i face is different. I have to search within a table. Can i assign same table to two different variables?

  4. #4
    Join Date
    Apr 2009
    Posts
    86
    Yes. The SQL I posted is joining the table to itself. There is only 1 table involved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •