I have a table1 and want to insert values into a table2 in postgres. Table1 is looking like this:
Table1:
z a b c
q1 x 10 5
q1 y null 20
q1 y null null
q2 x 20 10
q2 y null 15
q2 y null 25
Values of Table1 should be inserted in a table2 like this:
Table2:
z b c1 c2
q1 10 20 null
q2 20 15 25
Thus differnt values in table1.z should be one row in table 2. (table2.b = table1.b WHERE table1.a = x) (table2.c = table1.c WHERE table1.a = y)
I tried my best to keep it understandable
table2beq2 20 25 15instead ofq2 20 15 15?