question

ljhopkins avatar image
ljhopkins asked

How to merge one column from one row to another

![alt text][1] [1]: /storage/temp/3253-dataset.jpg I have the results returned from below (top half). AS you can see i have seperate lines for releaseversion and dbvernumber for each current location. I need to combine them in to one row as in the (bottom half) with changing the dbversion to VersionMatch. what is the best way to do this the query is from a view. select * where dateentered > getdate() -1
mergerow-comparison
dataset.jpg (109.4 KiB)
2 comments
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Do you want to actually update the table or just combine them in a query so they appear that way?
0 Likes 0 ·
just combine in the results
0 Likes 0 ·

1 Answer

· Write an Answer
David Wimbush avatar image
David Wimbush answered
I reckon this is about right: select a.CurrentLOCATION , a.CheckVal , a.DBVERSNUMBER , case when a.CheckVal = 'DBVERSNUMBER' then isnull(b.RELEASEVERSION, '') else '' end as RELEASEVERSION , a.DATEENTERED from table a left join table b on b.CurrentLOCATION = a.CurrentLOCATION and b.CheckVal = 'RELEASEVERSION' where a.CheckVal 'RELEASEVERSION' order by a.CurrentLOCATION , a.CheckVal;
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.