Oracle SQL - Keep null value if it's the only one, else avoid null value

Viewed 257

I have this table :

Table1
-----------------
ID         VAL       
-----------------
1          A
1          B
1          null
2          null
3          B
3          null
4          B
4          C
5          null   

I want to get this result :

If the only value is null then return null, else return non null values

Table1
-----------------
ID         VAL       
-----------------
1          A
1          B
2          null
3          B
4          B
4          C  
5          null

I tried using Over Partition By with a Case but my statement became too complicated with several subqueries, if think there should be a simple way to do this.

2 Answers
Related