• The output you posted doesn't match with the output of my query using the sample data, but it does what you need.

    The articles mention numeric data but it's the same functionality I used on the code I posted. Be sure to understand it well to adapt it to strings as I did using MAX instead of SUM and to be able to do it dynamic if that is what you need.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2