SELECT CASE WHEN Sample_size < 200 THEN 'Small' WHEN 200 <= Sample_size < 1000 THEN 'Medium' ELSE 'Large' END AS Sample_category FROM recent_grads
What I expected to happen:
Create a new Sample_category column and filter the result as condition
What actually happened:
Wrong answer. Checked and found that the new column only contains small and medium value. No 'Large' value.
The only difference between my answer and correct answer is the second WHEN clause. The correct answer is
WHEN Sample_size < 200 THEN ‘Small’
WHEN Sample_size < 1000 THEN ‘Medium’
END AS Sample_category
But why is that? I thought adding a 200<= Sample_size would not affect the answer.