Conditional values

From SQLZoo
Jump to navigation Jump to search

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
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects