sarpay
7/31/2015 - 3:33 PM

[sql] Merges and combines multiple rows into one while replacing NULL values with data from others.

[sql] Merges and combines multiple rows into one while replacing NULL values with data from others.

SELECT
  [Email], 
  max([FirstName]),
  max([LastName]),
  max(CAST([RegisteredVoter] AS INT)),
  max([ZipCode])
FROM [Contacts] 
GROUP BY [Email]
HAVING COUNT([Email]) > 1