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.
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.
Manish Kumar ChoudharyPosted Dec 1, 2014, 10:56 PM
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/
Mukesh Kumar TiwariPosted Dec 1, 2014, 8:05 AM
Joginder BangerPosted Dec 1, 2014, 7:42 AM
Mukesh Kumar TiwariPosted Dec 1, 2014, 7:33 AM
i tried but not succes using case and subqueries and union...
Joginder BangerPosted Dec 1, 2014, 7:00 AM
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
Manish Kumar ChoudharyPosted Dec 1, 2014, 6:57 AM
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.