Simple Question
I have a table that looks like this
I am looking to do is do a select so I can get a result as
Is this a PIVOTING issue? looking for suggestions to see how I can form a ‘Select’ query for this?
Advertisement
Answer
If you want to merge rows having the same values in the first three columns, then use aggregation:
select columna, columnb,columnc, max(columnd) columnd, max(columne) columne from mytable group by columna, columnb, columnc
Aggregate functions – such as max() – ignore null values, so max(columnd) gives you the non-null value across rows having the same (columna, columnb,columnc).

