Reputation: 910
I have a table like below:
ID Value1 Value2 Value3
1 abc null null
1 null def null
1 null null ghi
I want to select only the not null values that too in single row, i.e. the output should be as below:
ID Value1 Value2 Value3
1 abc def ghi
Is it possible to achieve the same using sql?
Upvotes: 0
Views: 700
Reputation: 175556
SELECT ID,
MAX(Value1) AS Value1,
MAX(Value2) AS Value2,
MAX(Value3) AS Value3
FROM your_table
GROUP BY ID
Upvotes: 1
Reputation: 13700
Try this
select id,
max(value1) as value1,
max(value2) as value2,
max(value3) as value3
from table
group by id
Upvotes: 1