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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Puneet KankarRank #446 · 5.6K reputationPosted Jul 17, 2017, 5:35 AM EDT
Puneet KankarRank #446 · 5.6K reputationPosted Jul 17, 2017, 12:25 AM EDT
priyankaRank #7,741 · 235 reputationPosted Jul 17, 2017, 5:13 AM EDT
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;