DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: help on query

  1. #1
    Join Date
    Mar 2001
    Location
    south africa
    Posts
    401

    help on query

    Hi guys ,

    How do i retrieve the following.Here is an example

    Table A

    col1 col2 col3
    391153 D17361031 2496852
    391153 D17463456 2530769
    391153 D17668492 2708237
    391153 D17668492 2708250
    391153 D17791393 2778256
    391153 D17791393 2813351

    395558 D17463878 2511176
    395558 D17463878 2511360
    395558 D17463878 2605292

    398940 D17912304 2836520
    398940 D17912304 2836579

    The Result should be some thing like this.if there are
    like differnet col2's for each col1 then i would like pull the oldest one based on sysdate
    if there are like same col2 for each col1 then i would like to display all of them.

    col1 col2 col3
    391153 D17361031 2496852

    395558 D17463878 2511176
    395558 D17463878 2511360
    395558 D17463878 2605292

    398940 D17912304 2836520
    398940 D17912304 2836579


    thank you

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Code:
    Select
       col1,
       col2,
       col3
    from
       (
       select
          col1,
          col2,
          col3,
          Min(col2) Over (Partition By col1) min_col2
       from
          table_a
       )
    Where
       col2 = min_col2
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #3
    Join Date
    Mar 2001
    Location
    south africa
    Posts
    401
    It worked .
    YOu are the best.
    Thank you for your help.Much appreciated.
    Last edited by prodadmin; 03-23-2004 at 05:34 PM.

Posting Permissions

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


Click Here to Expand Forum to Full Width