Working out in the big city
Being one of the most popular data types in Snowflake, text data is often used within a query itself for things like CASE
statements, WHERE
clauses, and more!
You'll supplement a query that retrieves information about premium gym locations and classifies them as located in a major or non-major city. Keep a close eye on those text values!
This exercise is part of the course
Data Types and Functions in Snowflake
Exercise instructions
- In the
CASE
statement, update the first value in parentheses to beNew York
. - After the else keyword, add the string
Non-Major City
; this is the value that will be returned if the condition above does not match. - Update the
WHERE
clause to only return records with agym_type
of'Premium'
.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT
gym_id,
CASE
-- Update the locations classified as a Major City
WHEN location IN ('___', 'Los Angeles', 'Dallas')
THEN 'Major City'
-- Otherwise, it's a Non-Major City
ELSE '___'
END AS gym_city
FROM CORE_GYM.gyms
-- Complete the WHERE clause to only return Premium gym types
WHERE gym_type = '___';