• What happens if there are more than three groups?  Do you need to add more and more columns if there are?

    Is this for a report?  I would recommend that you just return the data from SQL Server and let your front end handle the pivoting.

    John