Assume I have a table like this:
col1 | col2 | col3 | col4 |
---|---|---|---|
commonrow | one | two | null |
commonrow | null | null | three |
How to produce a result to look like this:
col1 | col2 | col3 | col4 |
---|---|---|---|
commonrow | one | two | three |
Thanks
Advertisement
Answer
like this, you can group by col1 and get the maximum in each group:
select col1 , max(col2) col2 , max(col3) col3 , max(col4) col4 from table group by col1