Difference between revisions of "Conditional values"

From SQLZOO
Jump to: navigation, search
 
Line 34: Line 34:
 
         ELSE 'OK'
 
         ELSE 'OK'
 
   END
 
   END
   FROM gisq.movie
+
   FROM movie
 
   WHERE 10>id</source>
 
   WHERE 10>id</source>
  

Latest revision as of 15:59, 17 July 2012

Conditional values

schema:gisq

The SQL Standard is the CASE statement

 
 
SELECT title, 
       score,
       IIF(score>8.5,'Excellent','OK')
   FROM movie
   WHERE 10>id
SELECT title, score,
  CASE
    WHEN score>8.5 THEN 'Excellent'
    ELSE 'OK'
  END
FROM movie
WHERE 10>id
SELECT
   title, 
   score,
   CASE WHEN score>8.5 THEN 'Excellent'
        ELSE 'OK'
   END
   FROM gisq.movie
   WHERE 10>id
SELECT
   title, 
   score,
   CASE WHEN score>8.5 THEN 'Excellent'
        ELSE 'OK'
   END
   FROM movie
   WHERE 10>id
Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense