Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Concatenating rows where some rows are NULL

$
0
0

How do I combine the comments based on each unique Tag_ID and code_page?

It is sorted  by timestamp and hence code_page. I need to combine the comments for code_page 1 and those comments with NULL code_page below it ( until Code_page is changed to 2) as one text field . Then combine comments for Code 2 and all comments with NULL Code_page after/below it.  THANK YOU!

Tag_IDcode_page     timestampComment
N12313/13/2014 13:54:38textual comment
N12313/13/2014 18:00:12textual comment
N123NULL3/13/2014 18:00:14textual comment
N123NULL3/13/2014 18:00:15textual comment
N123NULL3/13/2014 18:01:31textual comment
N123NULL3/13/2014 19:55:58textual comment
N123NULL3/13/2014 19:56:00textual comment
N123NULL3/13/2014 19:56:13textual comment
N123NULL3/13/2014 20:26:20textual comment
N123NULL3/13/2014 20:26:22textual comment
N12323/13/2014 12:45:04textual comment
N123NULL3/13/2014 12:45:20textual comment
N123NULL3/13/2014 20:26:33textual comment
N123NULL3/13/2014 20:26:34textual comment

When done it will look something like this:

N1231textual comment // textual comment // textual comment // textual comment // textual comment // textual comment // textual comment // textual comment // textual comment // textual comment // 
N1232textual comment // textual comment // textual comment // textual comment // 


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>