My table structure is like this
Option Ans
A 8
B 10
C 12
D 14
I want to display this in this format
A) 8 B) 10 C) 12 D) 14
Plz suggest me,how i can achieve this.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Puneet KankarPosted Jul 17, 2017, 9:35 AM
priyankaPosted Jul 17, 2017, 9:13 AM
from
(
select Qid, Answer,
'Option' + CAST(ROW_NUMBER()over (Partition by Qid order by Qid)as varchar(10)) as columnname
from Answer) d
pivot
(
max(Answer)
for columnname in (Ans1,Ans2,Ans3,Ans4)
) piv;
Puneet KankarPosted Jul 17, 2017, 4:25 AM