Get startedGet started for free

Determining buyer intent

You've determined that a few things go into a customer buying a song. These include things like the genre and length of a song, as well as its price. Now, you're going to translate these into actionable data by writing a query to measure buyer intent.

This exercise is part of the course

Data Manipulation in Snowflake

View Course

Exercise instructions

  • Create a CASE statement; if songs have a unit_price of 0.99 and are either Rock and Roll or Pop (genre 5 and 9), classify as 'High' buyer intent.
  • If a song is shorter than 5 minutes (300000 milliseconds) and isn't Electronic Dance Music (genre 15), it should have 'Neutral' buyer intent.
  • All other songs should have 'Low' buyer intent.

Hands-on interactive exercise

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

SELECT
    name,
    unit_price,
    CASE
        -- Inexpensive Rock and Pop songs are always high-intent
        WHEN ___ = ___ AND genre_id IN (___, ___) THEN '___'
        -- Shorter, non-EDM tracks have neutral buyer intent
        ___ milliseconds < ___ ___ ___ != ___ ___ '___'
		-- Everything else is low
        ___ '___'
    END AS buyer_intent
FROM store.track;
Edit and Run Code