user1854438 user1854438 - 4 months ago 6x
SQL Question

SQL select max values

I have for example values 'X','Y','Z',' ' in column myValue

and want to do something like select max(myValue)

so I want one value, the one with the highest value where X=1, Y=2 and Z=0

select max(
    case myValue
        when 'X' then 1
        when 'Y' then 2
        when 'Z' then 0
    end) myValue
from myTable