I know how the answer is correct but can someone tell me where the problem is with my code?

Screen Link:

My Code:

SELECT CASE
       WHEN Sample_size < 200 THEN 'Small'
       WHEN Sample_size >= 200 AND < 1000 THEN 'Medium'
       WHEN Sample_size >= 1000 THEN 'Large'
       ELSE NULL
       END AS Sample_category
  FROM recent_grads;

What I expected to happen:
[173 rows x 1 columns]

What actually happened:

(sqlite3.OperationalError) near ">=": syntax error
[SQL: SELECT CASE        WHEN Sample_size < 200 THEN 'Small'        WHEN Sample_size (>= 200 AND < 1000) THEN 'Medium'        WHEN Sample_size >= 1000 THEN 'Large'        ELSE NULL        END AS Sample_category   FROM recent_grads;]
(Background on this error at: http://sqlalche.me/e/13/e3q8)

The answer:
SELECT CASE
WHEN Sample_size < 200 THEN ‘Small’
WHEN Sample_size < 1000 THEN ‘Medium’
ELSE ‘Large’
END AS Sample_category
FROM recent_grads;

Hi peichek

Welcome to the community!
The issue is with line #3.

The correct syntax would be
WHEN Sample_size >= 200 AND Sample_size < 1000 THEN 'Medium

Hope this helps.
Thanks.

1 Like

It’s all cleared up now! Thanks a ton!