I have table in MS SQL as show below.

I want the Output like as show below image without using any temporary table in SQL server.so please help me.

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
Arjun SinghRank #2,192 · 643 reputationPosted Jun 29, 2016, 12:27 AM EDT
Rahul Verma22 reputationPosted Jun 29, 2016, 12:48 AM EDT
Nirav DaraniyaRank #593 · 4.1K reputationPosted Jun 29, 2016, 1:22 AM EDT
Arjun SinghRank #2,192 · 643 reputationPosted Jun 29, 2016, 1:39 AM EDT
Arjun SinghRank #2,192 · 643 reputationPosted Jun 29, 2016, 1:41 AM EDT
Arjun SinghRank #2,192 · 643 reputationPosted Jun 29, 2016, 2:24 AM EDT
Nirav DaraniyaRank #593 · 4.1K reputationPosted Jun 29, 2016, 2:27 AM EDT
Arjun SinghRank #2,192 · 643 reputationPosted Jun 29, 2016, 2:29 AM EDT
Arjun SinghRank #2,192 · 643 reputationPosted Jun 29, 2016, 2:51 AM EDT
Nirav DaraniyaRank #593 · 4.1K reputationPosted Jun 29, 2016, 2:58 AM EDT
Arjun SinghRank #2,192 · 643 reputationPosted Jun 29, 2016, 3:15 AM EDT