DECODE Function

Previous Next

The DECODE function is supported on a SQL Server database. When using SQL Server, the DECODE function is converted to the CASE function. For example, the following statement:

SELECT DECODE(type, 'popular_comp', 'Popular Computing', 'mod_cook', 'Modern Cooking',  'business' , 'Business', 'psychology', 'Psychology', 'trad_cook', Traditional Cooking',  'Not yet categorized')

from titles


will be internally transformed to:


        WHEN 'popular_comp' THEN 'Popular Computing'

        WHEN 'mod_cook' THEN 'Modern Cooking'

        WHEN 'business' THEN 'Business'

        WHEN 'psychology' THEN 'Psychology'

        WHEN 'trad_cook' THEN 'Traditional Cooking'

        ELSE 'Not yet categorized'


FROM titles


and this will be the statement that will be sent to the database.