how to sort columns

  • Hi, i've the next table:

    sect peter mark david 1st who 2nd who2 3th who3

    1 274 39 15 274 peter 39 mark 15 david

    2 211 320 6

    3 281 67 18

    4 323 690 7

    5 234 40 8

    for each row I need to know which of the columns of peter, mark and david, has the highest value and who. So for the sect=1 the highest value is peter with 274, also who are the 2nd and the 3rd with their respective values.

    I'm doing that using select ..unpivot and select ....pivot , any other ideas?

    thanks.

  • For a discussion of this subject, with sample code and tests for two other methods, look at this link:

    MIN/MAX Across Multiple Columns

    http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86906

  • thanks, for not only I've to register the max value, also who has it.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply