Get 1column thrice time on diffrent cond. from same table.
i want to get one column three time on the based of diffrent condion in sql server.
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
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Dec 1, 2014, 1:57 AM EST
Hi Mukesh Kumar Tiwari,
User Case like following u will get ur output.
select studentName,Address,
case when Marks<=30 then GradC else null,
case when Marks >=30 and Marks<=60 then GradB else null end
same way u can use ur condusion.
Joginder BangerRank #360 · 7K reputationPosted Dec 1, 2014, 2:00 AM EST
select case when age=20 then Name else 'null',case when age=25 name else 'null',case when age=21 then name else 'null' from your_table_name
Mukesh Kumar TiwariRank #1,774 · 844 reputationPosted Dec 1, 2014, 2:33 AM EST
i tried but not succes using case and subqueries and union...
Joginder BangerRank #360 · 7K reputationPosted Dec 1, 2014, 2:42 AM EST
Mukesh Kumar TiwariRank #1,774 · 844 reputationPosted Dec 1, 2014, 3:05 AM EST
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Dec 1, 2014, 5:56 PM EST
Hi Mukesh Kumar Tiwari,
Read these links it helps u
http://www.mssqltips.com/sqlservertip/2783/script-to-create-dynamic-pivot-queries-in-sql-server/
http://stackoverflow.com/questions/14797691/dynamic-pivot-columns-in-sql-server
https://www.simple-talk.com/blogs/2007/09/14/pivots-with-dynamic-columns-in-sql-server-2005/