0

I have tried getting this working but haven't had any success. I am trying to get this this working on SQL Server where the rows are converted to columns. Here is the SQL:

 select *
   (
    select foldername, prcIncidentManagement.CallCategory
    from prcIncidentManagement
   )
   pivot
   (
    count(foldername)
    for prcIncidentManagement.CallCategory in ('Software','Hardware'.etc..)
   )

The actual CallCategory field had more than 20 values. Is there any way of dynamically selecting all *, without predefining it if a new value gets added.

Thank you.

jarlh
  • 42,561
  • 8
  • 45
  • 63
abs786123
  • 581
  • 2
  • 11
  • 24
  • lot of dynamic pivots examples are there in stack over flow ..just do the perfect search – mohan111 Oct 14 '15 at 12:41
  • 1
    There are lot of answers... There are at least 4 answers where I have posted about dynamic pivot: http://stackoverflow.com/questions/32346362/t-sql-pivot-table-selecting-for-in or http://stackoverflow.com/questions/30612546/flip-sql-result or http://stackoverflow.com/questions/29430138/dynamic-sql-pivot-with-convert-datefield or http://stackoverflow.com/questions/32755751/pivot-dynamic-row-to-column-with-output-parameter – Stanislovas Kalašnikovas Oct 14 '15 at 12:43
  • Which dbms are you using? Pivot support can be very different for some of them. – jarlh Oct 14 '15 at 12:58
  • @jarlh as OP said `I am trying to get this this working on SQL Server ` – Stanislovas Kalašnikovas Oct 14 '15 at 13:22

0 Answers0