devnumbertwo - $h!t for developers

View Original

ms sql server equivalent of oracle’s decode

oracle’s DECODE function:

See this content in the original post

exp1 is an expression
val1 is a matching expression to compare with exp1
if val1 is = exp1, then ret1 is returned
otherwise, additional matching expressions (val2, val3, val4, and so on) is returned
if no match is found and the default expression default is included, then default is returned

ms sql server the equivalent of oracle’s DECODE function, the CASE function:

See this content in the original post