-
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
-
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
-
Thanks gandolf989!
I am able to use lag function with decode to get what I need. Thanks again!
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|