0

I have a query that returns data like below from multiple databases. CoursesTaken is dynamic and can change with time with new courses added/removed.

 ====== ======= ============ ============= ======= ========= 
 Name      ID     Courses          Col1     Col2    Taken   
 ====== ======= ============ ============= ======= ========= 
 John      23    math                 x        y       yes  
 John      23    Chemistry        t            u       yes  
 Mary      40    math                  x       u       yes  

====== ======= ============ ============= ======= =========

I want to pivot this on Courses so that it looks like below

Name  ID Math Chemistry Col1 Col 2 and so on
John  23 yes   yes
Mary  40 yes   no

I think for ssrs this can only be done from matrix so any changes to sql won't really help as courses are dynamic so how do I achieve the above?

EDIT Dynamic pivot or any pivot outside ssrs matrix won't help as any pivot needs to be done from within ssrs.

Thanks

Tex
  • 11
  • 1
  • 5
  • Have you tried a dynamic pivot in tsql? – Mazhar Mar 27 '18 at 17:20
  • Possible duplicate of [SQL Server dynamic PIVOT query?](https://stackoverflow.com/questions/10404348/sql-server-dynamic-pivot-query) – Tab Alleman Mar 27 '18 at 18:04
  • I don't think any pivot outside ssrs would help as I don't know the numbers of columns which requires the use of matrix or atleast from what i know, – Tex Mar 27 '18 at 18:11
  • Yes, matrix and column groups. Then columns outside the column group... that should all work out nicely. – Jesse Mar 27 '18 at 21:18

0 Answers0