LoslegenKostenlos loslegen

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!

Diese Übung ist Teil des Kurses

Data Types and Functions in Snowflake

Kurs anzeigen

Anleitung zur Übung

  • In the CASE statement, update the first value in parentheses to be New 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 a gym_type of 'Premium'.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

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 = '___';
Code bearbeiten und ausführen