Get startedGet started for free

Filtering with session variables

Session variables in Snowflake let you store a value once and reference it in any query for the rest of your session using a $ prefix. They are a Snowflake-specific feature — useful for parameterising queries without hardcoding values.

The session variable $min_fee has been set to 49.99 (equivalent to running SET min_fee = 49.99). The snowy_peak.subscriptions table has columns subscription_id, user_email, plan, status, start_date, and monthly_fee.

This exercise is part of the course

Snowflake Architecture

View Course

Exercise instructions

  • Query snowy_peak.subscriptions to return plan and monthly_fee for all subscriptions where monthly_fee is greater than or equal to the session variable $min_fee.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- Return plan and monthly_fee for subscriptions at or above $min_fee
SELECT plan, monthly_fee
FROM snowy_peak.subscriptions
WHERE monthly_fee >= ___;
Edit and Run Code