Skip to content

Median hours from sign-up to first purchase

MediumFull bankFunnelsMedians and percentilesDates and time15 min2 hidden datasets

The task

Growth wants to know how long new users take to buy for the first time, by platform. A few slow buyers pull the average far above what a typical user does, so report both the median and the average.

For each user, take the time from users.signed_up_at to their first purchase event, in hours. Users who never purchased are left out. Measure only each user's first purchase, not later ones.

Return one row per platform that has at least one buyer:

  • platform
  • buyers: how many users made a purchase
  • median_hours: the median of those hours, rounded to 1 decimal place. With an even number of buyers, the median is the average of the two middle values.
  • avg_hours: the mean of those hours, rounded to 1 decimal place

Sort by platform.

Expected output

platformbuyersmedian_hoursavg_hours
  • Sorted by platform ascending.
  • Numbers rounded to 1 decimal place.
  • Checked on the sample and on 2 hidden datasets. How grading works

Tables Mobile shopping app · click a name to insert it

users360 rows in the sample

One row per user. Key: user_id.

intUnique id.
timestampSign-up time (UTC).
textTwo-letter country code.
textios, android or web.
textorganic, paid, referral or partner. NULL when unknown.
events7,616 rows in the sample

One row per tracked event. Key: event_id.

bigintUnique id.
intWho fired it.
textapp_open, search, view_item, add_to_cart, begin_checkout, purchase or share.
timestampWhen (UTC).
textSession the event belongs to. NULL for a few events sent from the background.
numeric(10,2)Order value for purchase events, NULL otherwise.
experiment_assignments349 rows in the sample

Which variant each user saw in each experiment. Key: user_id, experiment.

intThe user.
textnew_onboarding or one_tap_checkout.
textcontrol or treatment.
timestampWhen the user was assigned (UTC).

Related questions

Loading the editor and PostgreSQL