Skip to content
Advertisement

Merge records that have at least one non-null element in a specific column – SQL Server

My data looks like as following:

I would like to merge records that have both NULL and a NON-NULL value in the [Class] column but at the same time to not affect rows that have only a NULL value (e.g. id 10013)

Following is the desired output:

I have tried using the COALESCE function but it expunges all the rows with NULL in [Class].

I’m sure there is a simple way of doing that but I’ve been stuck.

Thanks in advance.

Advertisement

Answer

Not sure if this is your intent

Example

Returns

enter image description here

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement