I have a table like this:
+--+---------+---------+
|id|str_value|int_value|
+--+---------+---------+
| 1| 'abc' | |
| 1| | 1 |
| 2| 'abcd' | |
| 2| | 2 |
+--+---------+---------+
I need to get this:
+--+---------+---------+
|id|str_value|int_value|
+--+---------+---------+
| 1| 'abc' | 1 |
| 2| 'abcd' | 2 |
+--+---------+---------+
It seems to me that I need something like:
select id, first_not_null(str_value), first_not_null(int_value)
from table
group by id
Is there any acceptable way to do this? I use Postgresql 9.0.1.
Update: this should work with uuid types as well