.net - Displaying all the rows from different columns into one single row and single column in sql -


i have table in database consists of name, maths, science, history columns wherein each persons marks displayed of each subject. need write query wherein need display in 1 single row as: anthony:30,70,60 $ raghav:25,30,45 , on.. can tell me how can that?

declare @result varchar(max)  select @result = coalesce(@result + '$','')+[name] + ':' + cast(maths varchar(3)) + ',' + cast(science varchar(3))  + ',' + cast(history varchar(3))   tablename 

@result variable contains concatenated string can return by

select @result 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -