Kom igångKom igång gratis

Working with personal info

A new table was added to your data warehouse, which includes user-specific information. However, this data in the personal_info column of the members table is in VARIANT format, and takes the form below. Your job is to filter and parse this data into a result set that is usable for planning special offers for each member.

{
      "age": "56",
      "gender": "Female",
      "name": {
        "first": "Chris",
        "last": "Wilson"
      }
}

Den här övningen är en del av kursen

Data Types and Functions in Snowflake

Visa kurs

Övningsinstruktioner

  • Use dot-notation to retrieve a member's age from the personal_info column, and pass the value to the TO_NUMBER function.
  • Use bracket-notation to retrieve a member's gender from personal_info.
  • Filter the result set to only include records for members at least 25 years old.

Interaktiv övning med praktiskt arbete

Testa den här övningen genom att slutföra den här exempelkoden.

SELECT
    personal_info,
	
    -- Use the TO_NUMBER function to convert the age to a NUMBER
    TO_NUMBER(___:___),
    
    -- Use bracket-notation to retrieve the member's gender
    ___

FROM CORE_GYM.members

-- Only retrieve members who are at least 25
___ TO_NUMBER(personal_info:age) >= ___;
Redigera och kör kod