How to I modify this t-sql query to return the maximum value for different column names?

后端 未结 3 1892
感动是毒
感动是毒 2020-12-30 14:53

I have the following query:

SELECT
        [Rate],
        [RateMon],
        [RateTue],
        [RateWed],
        [RateThu],
        [RateFri],
        [Ra         


        
3条回答
  •  感动是毒
    2020-12-30 15:15

    SELECT  [Rate],
            (SELECT MAX(T.[Rate])
             FROM (VALUES([RateMon]),
                         ([RateTue]),
                         ([RateWed]),
                         ([RateThu]),
                         ([RateFri]),
                         ([RateSat]),
                         ([RateSun])) AS T([Rate])
            ) AS MaxRate
    FROM [Room]
    WHERE Id=@Id
    

提交回复
热议问题