Please forgive me if this has been answered before.
I’m looking for some advice on how to build a pivot or cross tab query.
I have a table that looks likes this
Vessel Date Inspector
A 02/05/10 Morris
B 05/20/10 Clouseau
A 07/25/10 Gadget
I need the results to be look like this
Vessel Jan Feb Mar April May June July Aug Sept Oct Nov Dec
A Morris Gadget
B Clouseau
Hopefully that makes sense. I’m hoping someone can give me some advice or help to get me started on this.
Thanks
You have to statically declare the columns. It should be noted that this will only work for a single year. If what you are seeking is dynamic column (month) generation, then trying to do it in T-SQL is not the right approach as you can only do it with some fugly dynamic SQL. Instead, you should use a report generator or middle-tier component to build the result set.