1 Replies - 232 Views - Last Post: 26 October 2017 - 07:21 AM Rate Topic: -----

#1 ikhlas06  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 178
  • Joined: 20-May 16

how to get latest non-null value in oracle sql?

Posted 26 October 2017 - 07:17 AM

how to get latest non-null value in oracle sql?


I have a table:
|--------|-----|-------|----|----------|----| 
| Date   | IA  | TEST  | OC | Comment  | yn |
|--------|-----|-------|----|----------|----| 
| 1/1/17 | INC | TEST1 | O  |          |    |
| 1/1/16 | ALL | TEST2 | O  | Comment1 |    |
| 1/1/15 | INC | TEST3 | C  |          | NO |
| 1/1/14 | ALL | TEST4 | C  | Comment2 |    |
| 1/1/13 | ALL | TEST5 | O  |          |    |  
|--------|-----|-------|----|----------|----| 



I want out put to be:
|--------|-------|----|----------|----| 
| Date   | TEST  | OC | Comment  | yn |
|--------|-------|----|----------|----| 
| 1/1/17 | TEST1 | O  | Comment1 | NO |
|--------|-------|----|----------|----| 


so I want the:
latest 'date' col (this col can not be null)
latest 'Test' Col (this col can not be null)
latest non-null 'Comment' col (this col can be null)
latest non-null 'yn' col (this col can be null)

This post has been edited by ikhlas06: 26 October 2017 - 07:18 AM


Is This A Good Question/Topic? 0
  • +

Replies To: how to get latest non-null value in oracle sql?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13488
  • View blog
  • Posts: 53,864
  • Joined: 12-June 08

Re: how to get latest non-null value in oracle sql?

Posted 26 October 2017 - 07:21 AM

Join a bunch of subqueries that use 'MAX' or 'is not null' to get each.. though it makes little sense to fabricate a row of data made up of different columns of different rows.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1