• Well, I'm glad it does approximately what you need, but it does not work properly in case where for the same siteID and month you have several rows - in that case it simply chooses the row with highest value of string (i.e. P would win over LC).

    And there is one more thing... in the sample data, you have value 'B' in FEB column ... isn't that a mistake? As I understood it, the motnh columns should only have values 1 or 0...?