Skip to content
Advertisement

SQL with conditional where

Could someone please assist with the below query ?

I have a table like below :

And I want to retrieve the “Code” value by passing “alias” and “user” values, however when the “user” doesn’t match/exist, I’d need the row with the null user. Eg :

should return the 1st line code value (7305553) , as user “TEST” doesn’t exist. Is this kind of best-matching behavior possible with some kind of conditional “where” ? (with some kind of case statement?)

Advertisement

Answer

Try this:

Cheers!!

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement