Monday, 19 August 2013

Select Top n Values Across Columns and Average

Select Top n Values Across Columns and Average

I have a table that has 13 columns, 1 column holds the identifier field
(varchar, 25) and the other 12 hold int values (one for each month of the
year). For each row, I would like to pick the top 6 int values from the 12
columns and calculate the average of those values. I know how to select
the top n from a given column, but how do you do it across multiple
columns? Is it even possible?

No comments:

Post a Comment