Nulls Behaving Badly
Ever wondered how Snowflake decides where to place NULL values when you sort your data? 🤔 Let’s dive into the DEFAULT_NULL_ORDERING parameter and see how it influences the ordering of NULLs in your queries.
Challenge Overview
Your task is to:
- Set the DEFAULT_NULL_ORDERING parameter to both ‘FIRST’ and ‘LAST’ in your session.
- Create a sample table with a mix of NULL and non-NULL values.
- Observe the ordering of NULLs in your query results under different settings.
- Override the default behavior using explicit NULLS FIRST or NULLS LAST in your ORDER BY clause.
- Bonus: Retrieve the current setting of DEFAULT_NULL_ORDERING using a SQL query.
Good luck, and stay frosty! ❄️
️️️ I think chili peppers are a great way to illustrate NULL ordering behavior!
https://github.com/marioveld/frosty_friday/blob/main/ffw138/ffw138.sql