0

I have a table that looks like this:

 iD PhoneNumber EmailAddress 1 06543635463 NULL 1 NULL [email protected] 2 NULL [email protected] 2 0298754355 NULL 3 0543280545 NULL 

And I'm tryong to concatenate the rows so they look like this:

id PhoneNumber EmailAddress 1 06543635463 [email protected] 2 0298754355 [email protected] 3 0543280545 NULL 

Any help would be appreciated. Thanks so much.

3
  • So which data type do you want? Commented Nov 9, 2016 at 15:35
  • That would be deduplication, not concatenation. Commented Nov 9, 2016 at 15:36
  • I guess you inserted records instead of update for same ID. Commented Nov 9, 2016 at 15:38

1 Answer 1

7

That's not a concatenation, it's a simple aggregation. Sounds like you could use MIN or MAX:

SELECT id, MAX(PhoneNumber) PhoneNumber, MAX(EmailAddress) EmailAddress FROM dbo.YourTable GROUP BY id; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.