1

Imagine I have a table like this:

---------------------------------------------
Name | Property_1 | Property_2 | Property_3  |
---------------------------------------------
jimi | tall       | null       | null        |
---------------------------------------------
jimi | null       | black      | null        |
---------------------------------------------
jimi | null       | null       |  African    |
----------------------------------------------

I want to convert that to this table:

------------------------------------------------
Name | Property_1  |  property_2   | Property_3 |
------------------------------------------------
jimi | tall        | black         |African     |
-------------------------------------------------

how can I achieve that in MSSQL database?

3

while other values of a column are NULL, easily you can use this query:

SELECT Name,MAX(property_1),MAX(property_2),MAX(property_3)
FROM YourTable
GROUP BY Name
| improve this answer | |
  • @el.ham, you forgot to add Name in the SELECT list. – Biju jose Nov 4 '18 at 5:22
  • @Bijujose Yess thaanks – El.Hum Nov 4 '18 at 8:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.