Results 1 to 3 of 3

Thread: Sorting

  1. #1
    Join Date
    Dec 2003
    Location
    India
    Posts
    12

    Unanswered: Sorting

    Hi All,
    I have table say TAB the columns and data in this table are as follows

    ALK STATUS POSTCODE
    2 C CF116LR
    2 D CF116LR
    1 D CF116LR
    3 C CF116LR

    If i query from this table i want the result should be sorted on the basis of the following priority
    Priority 1) If in the result set for the same alk both C and D address are present then they should be dispalyed first
    Priority 2) If no C and D combination exists for the same alk then the addresses having only C records should be dispalyed
    Priority 3)If no C addreses are there then addresses having only D status should be dispalyed.
    For example
    if i give select * from tab where postcode='CF116LR';
    the result set should be in the following manner
    2 C CF116LR
    2 D CF116LR
    3 C CF116LR
    1 D CF116LR

    If alk 2 were not preset in the table the result set should be
    3 C CF116LR
    1 D CF116LR

    Thanks in advance
    Sbdash

  2. #2
    Join Date
    Jul 2003
    Posts
    2,296
    Lookup UNION and UNION ALL in the oracle docs.
    This will solve your ordering problem.
    - The_Duck
    you can lead someone to something but they will never learn anything ...

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Sorting

    What is the difference between this question and the one you asked and got answered last week? :-

    http://www.dbforums.com/t975204.html

Posting Permissions

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