An SQL query to derive data from one to many rows based on another field I have an issue I can't get my head around. This is the table:

Table1

c1      c2      c3
1       A
2       A       DD
3       A       DD
4       B       HH
5       B     
6       B


This is the desired outcome:

c1      c2      c3
1       A       DD
2       A       DD
3       A       DD
4       B       HH
5       B       HH
6       B       HH


I'm running PostgreSQL 9.4. Basically I want to use the non-null values in c3 to fill c3 based on the common data the rows have in c2.

Thanks for the help!
As far as I can tell, you want the "first" non-null value for the c3 column for the "group" that is defined through the c2 column.

This can be done with a window function:

select c1, 
       c2, 
       first_value(c3) over (partition by c2 order by c3 nulls last) as c3
from table_1


This does return the result you showed us.

Edit (after the question was changed)

To update the existing values you can use this:

update t1
  set c3 = tu.c3
from (
  select c1, c2, first_value(c3) over (partition by c2 order by c3 nulls last) as c3
  from t1
) tu
where t1.c1 = tu.c1
  and t1.c3 is null;