PDA

View Full Version : Sleeper: Decode function



ijswalker
11-20-2007, 07:32 PM
Hi,

I am trying to write a decode function and I want to say "if the column 1 contains 100 in row 5 and the column 2 contains the word CAT then return the amount in column 6.

If I remember rightly the decode function would have a || in it somewhere but I can't remember. Can someone help. I am querying an Oracle database using SQL.

Thanks

Ian

XLGibbs
11-21-2007, 06:06 PM
I am not familiar with Oracle Syntax...(SQL Server doesn't have that function that I am familar with)

In SQL you could do a Case..When operation


Select Column6
FRom [Table]
Where COlumn 1 = 100 and column2 = 'CAT'

Or


Select (Case When Column1 = 100 and column2 = 'CAT' then Column6 else NULL end)
FROm [Table]