Using Oracle 11. Trying to write some simple code for a conceptual demo. To illustrate what I'm trying to achieve, imagine I have SOMETABLE
that has two columns: ID and NAME, like so:
ID NAME
---------
1 Tom
2 Larry
3 David
4 Steve
I'm trying to compute a third column that is true if the second column matches one of two hard-coded values. Something like this (which of course doesn't work.)
Select ID,
NAME,
(NAME in ('Larry', 'David')) as IS_FAVORITE
from SOMETABLE
and hoping to get this output...
ID NAME IS_FAVORITE
----------------------
1 Tom FALSE
2 Larry True
3 David True
4 Steve FALSE
Much to my surprise, I'm being told Oracle doesn't have the concept of booleans and I should be using 'numeric strings' or something like that, so this too is fine...
ID NAME IS_FAVORITE
----------------------
1 Tom 'N'
2 Larry 'Y'
3 David 'Y'
4 Steve 'N'
So can you use the IN
operator in a column expression like this? If not, how would one compute the column that I am after?