• Hi - based on the dates of the other comments, I'm coming to the party a little late.  But thanks for a very clearly-explained (and with two examples) piece of code.  I too have wondered - I've been on SQL since v6.x - how to do a crosstab when the column number is variable.  I'll be interested to see PIVOT and UNPIVOT on 2005.