select statement
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: select statement

  1. #1
    Join Date
    Oct 2016
    Posts
    2

    select statement

    Dear all,

    I like to find out how to write a query that will place a null on a particular column on duplicate records. For example, I have a complicated join statement that returns a set of data like the followings:

    UID ENTRY_TM DOC_NUM TYPE DSSN AMT IP_AMT
    &714104&74 28-Sep-16 DJTS16H475 E4 3801 828.25 451.5
    &714104&74 28-Sep-16 DJTS16H475 E4 3801 828.25 376.75

    Most of the columns are duplicated except the last one. So I am required to return a null value on one duplicated column such as the following:
    UID ENTRY_TM DOC_NUM TYPE DSSN AMT IP_AMT
    &714104&74 28-Sep-16 DJTS16H475 E4 3801 828.25 451.5
    &714104&74 28-Sep-16 DJTS16H475 E4 3801 null 376.75

    I know I can write a cursor to get to what I want; however, is there a way to get the same result in plain select query without function or cursor?


    Thanks,
    Tina

  2. #2
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,154
    But in 11g there is a lead lag function that will look at other rows as a part of analytics.
    Here is a link that might help.

    https://www.techonthenet.com/oracle/functions/lag.php
    this space intentionally left blank

  3. #3
    Join Date
    Oct 2016
    Posts
    2
    Thanks gandolf989!

    I am able to use lag function with decode to get what I need. Thanks again!

  4. #4
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,154
    Your welcome.
    this space intentionally left blank

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