Riddhi Valecha

Riddhi Valecha

  • 420
  • 3.3k
  • 412.9k

Dynamic Columns in SQL Query

Dec 11 2013 12:33 AM
Hi all.. I need help in forming a SQL Query.

My requirement is - I have the table as follows-

ID Date Status Count Company Location
 1 1-1-2010Clear  D
 2 2-3-2010 Clear 2 C F
 31-1-2010  Rejected 3 B G
 4 2-3-2010Rejected  4 A H

Now, I want the output as follows in the sql query -

 IDDate  Jan-2010ClearJan-2010Rejected Feb-20101Clear Feb-2010 Rejected Total 
 1
 1 3 2 4 10
 2





 3






Total  3 2 4 10

I am not able to create dynamic columns in query.

Please Help..

Thanks a lot in advance....

Answers (22)