Español Practice SQL

Snowflake basics: QUALIFY, IFF and ILIKE

Snowflake accepts standard SQL and adds shortcuts that save a lot of typing.

Dialects · Snowflake

Practice this now

Free. No sign up. Your progress stays in this browser.

What you will learn

Snowflake is a cloud data warehouse used by many analytics teams.

QUALIFY alone removes a whole CTE from the top row per group pattern.

The basics

Snowflake accepts most standard SQL and adds a few shortcuts that analysts love.

SELECT region, customer, amount
FROM invoices
QUALIFY ROW_NUMBER() OVER (PARTITION BY region ORDER BY amount DESC) = 1

QUALIFY filters on a window function, like HAVING filters on a group, so the top row per group needs no CTE.

SELECT customer, IFF(amount >= 10000, 'Large', 'Small') AS size
FROM invoices
WHERE customer ILIKE 'a%'

IFF is a one line CASE. ILIKE ignores case, because LIKE in Snowflake is case sensitive. Both TOP and LIMIT work; NVL, IFNULL and COALESCE all fill NULL values.

Worked examples

Example 1

The largest deal per rep.

SELECT rep, account, amount
FROM deals
QUALIFY ROW_NUMBER() OVER (PARTITION BY rep ORDER BY amount DESC) = 1

No CTE needed.

Reading helps, typing makes it stick. Every task gives you a fresh table, and your query is checked by a real database.

Try a task

Common mistakes

  • Using LIKE and missing rows because of capital letters.
  • Putting a window function in WHERE instead of QUALIFY.
  • Forgetting the third argument of IFF.

Where you will use it at work

  • Analytics engineering and dashboards.
  • Marketing and product data in a warehouse.
  • Finance models built on dbt.

Questions people ask

TOP or LIMIT?

Both work in Snowflake.

NVL or COALESCE?

Both, plus IFNULL.

Is Snowflake LIKE case sensitive?

Yes; ILIKE is not.

Ready to write it yourself?

Practice QUALIFY, IFF and ILIKE

Further reading

Related guides

SQL Practice is independent and not affiliated with the maker of this database. The exercises run on SQLite in your browser and imitate this dialect’s syntax for practice.