Differences

This shows you the differences between two versions of the page.

oracle-to-sql-server:decode [February 09, 2013 3:35 pm]
sqlines
oracle-to-sql-server:decode [February 09, 2013 3:43 pm] (current)
sqlines
Line 77: Line 77:
     
   -- CASE without NULL condition    -- CASE without NULL condition
-   SELECT CASE name WHEN 'San Francisco' THEN 'SFO'  +   SELECT name, 
-                                 WHEN 'Los Angeles' THEN 'LAX'  END+               CASE name  
 +                 WHEN 'San Francisco' THEN 'SFO'  
 +                 WHEN 'Los Angeles' THEN 'LAX'  END decoded
   FROM cities;    FROM cities;
</code> </code>
-The queries results:+The results of the queries:
{{:oracle-to-sql-server:oracle_decode3.jpg|}} {{:oracle-to-sql-server:oracle_decode3.jpg|}}
Line 94: Line 96:
<code sql> <code sql>
   -- IS NULL condition is now correct    -- IS NULL condition is now correct
-   SELECT CASE WHEN name IS NULL THEN 'N/A' ELSE name END FROM cities;+   SELECT name, 
 +                 CASE  
 +                   WHEN name IS NULL THEN 'N/A'  
 +                   WHEN name = 'Unknown' THEN 'N/A'  
 +                   ELSE name END decoded 
 +   FROM cities;
</code> </code>