Skip to content

Weekend vs weekday revenue per calendar day

MediumFull bankDates and timeGroup and aggregateRatios and percentages14 min2 hidden datasets

The task

The shopping app team wants to know whether weekends earn more than weekdays in May 2025.

Use purchase events from 2025-05-01 00:00:00 up to, not including, 2025-06-01 00:00:00. Sum their revenue. Saturday and Sunday are 'weekend'; Monday to Friday are 'weekday'.

Return exactly two rows:

  • day_type: 'weekday' or 'weekend'
  • days: how many calendar days of May 2025 are of that type, whether or not anything was bought that day
  • revenue: total revenue of the purchases on those days (0 if none)
  • avg_revenue_per_day: revenue divided by days, rounded to 2 decimal places

Sort by day_type.

Expected output

day_typedaysrevenueavg_revenue_per_day
  • Sorted by day_type ascending.
  • Numbers rounded to 2 decimal places.
  • 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