SQL Flashcards
1
Q
syntax for creating a custom column called newcolumn in mytable, based on column a, which is ‘high’ when a > 100, ‘medium’ when 50 > a > 100, and ‘low’ when a < 50
A
SELECT a, CASE WHEN a > 100 THEN 'high', WHEN a > 50 AND a < 100 THEN 'medium' ELSE 'low' END AS newcolumn FROM mytable