CODE WORKSPACE

Pacific daily active users

Return pacific_event_day and active_users (distinct users) bucketed into a Pacific-style reporting day. Order by pacific_event_day.

Bucket with date(datetime(event_time, '-8 hours')), then COUNT(DISTINCT user_id).

Sample input

eventsevent_time is UTC; shift -8h before truncating. Events at 03:30 and 04:10 UTC fall on the previous Pacific day.
event_iduser_idevent_time
112026-01-01 03:30:00
212026-01-01 04:10:00
322026-01-01 22:15:00
422026-01-02 00:30:00
532026-01-02 05:00:00
612026-01-03 18:00:00

Expected output

Expected outputDistinct users per Pacific-style day. 2026-01-01 has users 2 and 3 (events 3, 4, 5).
pacific_event_dayactive_users
2025-12-311
2026-01-012
2026-01-031

Constraints

Shift event_time by a fixed -8 hours before truncating: date(datetime(event_time, '-8 hours')). GROUP BY that day with COUNT(DISTINCT user_id). Order by pacific_event_day.

Expected skills

Timezone shifting before truncation and distinct active-user counts.

SQL
Loading...

AI evaluation

Run the SQL query to inspect preview rows.