I have the following query:
SELECT
[Rate],
[RateMon],
[RateTue],
[RateWed],
[RateThu],
[RateFri],
[RateSat],
[RateSun]
FROM
[Room]
WHERE
Id=@Id
Instead of returning all the columns, I just want to return Rate
and the Maximum value between RateMon, RateTue, RateWed, RateThu, RateFri, RateSat, and RateSun, but I am having a hard time because the column names are different.
An example result return now is:
100, 400, 400, 400, 400, 600, 600, 600
where 100 is the Rate and the other values correspond to Mon - Sun, but I want to return just 100 and 600 in this case.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With