I have a table with the following structure ...
+--------+------+------+------+------+------+ | ID | colA | colB | colC | colD | colE | [...] etc. +--------+------+------+------+------+------+ | 100100 | 15 | 100 | 90 | 80 | 10 | +--------+------+------+------+------+------+ | 100200 | 10 | 80 | 90 | 100 | 10 | +--------+------+------+------+------+------+ | 100300 | 100 | 90 | 10 | 10 | 80 | +--------+------+------+------+------+------+ I need to return a concatenated value of column names which hold the maximum 3 values per row ...
+--------+----------------------------------+ | ID | maxCols | +--------+----------------------------------+ | 100100 | colB,colC,colD | +--------+------+------+------+------+------+ | 100200 | colD,colC,colB | +--------+------+------+------+------+------+ | 100300 | colA,colB,colE | +--------+------+------+------+------+------+ - It's okay to not concatenate the column names, and have
maxCol1 | maxCol2 | maxCol3if that's simpler - The order of the columns is important when concatenating them
- The number of columns is limited and not dynamic
- The number of rows is many