Repository: PostHog/posthog
Pull request: feat: recordings ordering
## Problem

Order replays!

Randomly choose replays! (closes https://github.com/PostHog/posthog/issues/8182)

## Changes

- Add ordering back to replay filtering
- Add more options to filter by (activity mainly)
- Remove ability to customise "duration shown" (it uses the ordering duration or the total duration now)
- Rewrite query such that it doesn't need to be parsed
  - Curious if this has any performance impact
- Removed some legacy stuff about changing the search period (we should always respect the date range filter first and foremost)

![ordering](https://github.com/user-attachments/assets/cefdf3cf-aa5e-4478-9fcd-78ff679aff3b)


## Does this work well for both Cloud and self-hosted?

Yes

## How did you test this code?

Added a test

Problem statement:
Stratified Recordings
## Is your feature request related to a problem?

When I watch recordings, I don't just want to see what people did in the last few hours, I'd like to see a sample of people over the last few days / weeks. So I'm not affected by any biases in that smaller time period (e.g. specific region awake at this time, a single user is very active so represents most recordings)

## Describe the solution you'd like

I'd like a way to stratify recordings, e.g. "Show me 2 recordings with this event in, from each day in the last 7 days"

## Describe alternatives you've considered

Lots of scrolling and pagination

## Additional context


#### *Thank you* for your feature request – we love each and every one!

Hints from issue discussion:
This is really interesting!

Technically, it's pretty easy to do, but I think the trick would be in how we describe what's happening to a user.

It's almost like "shuffle" on a playlist.

@clarkus curious if you have any thoughts here.
I like this idea. I think this feels like a natural evolution of the filtering capabilities for recordings. We knew we were going to have to circle back to improve filtering, so this is a good example that will help us know how to structure the updated filter. 

This is a particularly interesting case because we're sampling in uniform sizes, across a time range, in set units of time. It's a very specific scenario compared to our current filtering structure. 
This issue hasn't seen activity in two years! If you want to keep it open, post a comment or remove the `stale` label – otherwise this will be closed in two weeks.
cc @daibhin  as another form of clustering we could do

Commit message: Update query snapshots

Patch to review:
diff --git a/ee/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr b/ee/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr
index fd0b7d5358f5f..decc4844d5185 100644
--- a/ee/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr
+++ b/ee/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr
@@ -8,9 +8,9 @@
          max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,
          dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -23,7 +23,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                        WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, %(hogql_val_6)s), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, %(hogql_val_7)s), now64(6, %(hogql_val_8)s)), greaterOrEquals(toTimeZone(events.timestamp, %(hogql_val_9)s), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, %(hogql_val_10)s), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_rgInternal, ''), 'null'), %(hogql_val_11)s), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                                                        GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                                                        HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 50000
@@ -38,9 +38,9 @@
          max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,
          dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -62,7 +62,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                           GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                           HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, %(hogql_val_7)s), person.version), plus(now64(6, %(hogql_val_8)s), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                                                        WHERE ifNull(equals(person_distinct_ids__person.properties___rgInternal, %(hogql_val_9)s), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 50000
@@ -77,9 +77,9 @@
          max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,
          dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -101,7 +101,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                           GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                           HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, %(hogql_val_7)s), person.version), plus(now64(6, %(hogql_val_8)s), toIntervalDay(1))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                                                        WHERE ifNull(equals(person_distinct_ids__person.properties___rgInternal, %(hogql_val_9)s), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 50000
@@ -116,9 +116,9 @@
          max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,
          dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -131,7 +131,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                        WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, %(hogql_val_6)s), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, %(hogql_val_7)s), now64(6, %(hogql_val_8)s)), greaterOrEquals(toTimeZone(events.timestamp, %(hogql_val_9)s), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, %(hogql_val_10)s), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_rgInternal, ''), 'null'), %(hogql_val_11)s), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                                                        GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                                                        HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 50000
@@ -146,9 +146,9 @@
          max(toTimeZone(s.max_last_timestamp, %(hogql_val_1)s)) AS end_time,
          dateDiff(%(hogql_val_2)s, start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -161,7 +161,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                        WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, %(hogql_val_6)s), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, %(hogql_val_7)s), now64(6, %(hogql_val_8)s)), greaterOrEquals(toTimeZone(events.timestamp, %(hogql_val_9)s), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, %(hogql_val_10)s), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_rgInternal, ''), 'null'), %(hogql_val_11)s), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                                                        GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                                                        HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 50000
@@ -176,9 +176,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -186,7 +186,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -208,9 +208,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -223,7 +223,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_email, ''), 'null'), 'bla'), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -245,9 +245,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -255,7 +255,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -277,9 +277,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -292,7 +292,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_email, ''), 'null'), 'bla'), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -314,9 +314,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -324,7 +324,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -346,9 +346,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -361,7 +361,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_email, ''), 'null'), 'bla'), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -383,9 +383,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -393,7 +393,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -415,9 +415,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -430,7 +430,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_email, ''), 'null'), 'bla'), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -452,9 +452,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -462,7 +462,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -484,9 +484,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -511,7 +511,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -533,9 +533,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -543,7 +543,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -565,9 +565,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -592,7 +592,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -614,9 +614,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -624,7 +624,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -646,9 +646,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -673,7 +673,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -695,9 +695,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -705,7 +705,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -727,9 +727,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -754,7 +754,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -776,9 +776,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -786,7 +786,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -808,9 +808,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -823,7 +823,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_email, ''), 'null'), 'bla'), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -845,9 +845,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -855,7 +855,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -877,9 +877,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -892,7 +892,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_email, ''), 'null'), 'bla'), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -914,9 +914,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -924,7 +924,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -946,9 +946,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -961,7 +961,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_email, ''), 'null'), 'bla'), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -983,9 +983,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -993,7 +993,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1015,9 +1015,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1030,7 +1030,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), ifNull(equals(nullIf(nullIf(mat_pp_email, ''), 'null'), 'bla'), 0))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1052,20 +1052,20 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(session_id,
                                                                                                                                                                    (SELECT DISTINCT events.`$session_id` AS `$session_id`
                                                                                                                                                                     FROM events
                                                                                                                                                                     WHERE and(equals(events.team_id, 2), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), notEmpty(events.`$session_id`)))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1087,20 +1087,20 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(session_id,
                                                                                                                                                                    (SELECT DISTINCT events.`$session_id` AS `$session_id`
                                                                                                                                                                     FROM events
                                                                                                                                                                     WHERE and(equals(events.team_id, 2), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), notEmpty(events.`$session_id`)))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1122,20 +1122,20 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(session_id,
                                                                                                                                                                    (SELECT DISTINCT events.`$session_id` AS `$session_id`
                                                                                                                                                                     FROM events
                                                                                                                                                                     WHERE and(equals(events.team_id, 2), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), notEmpty(events.`$session_id`)))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1157,20 +1157,20 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(session_id,
                                                                                                                                                                    (SELECT DISTINCT events.`$session_id` AS `$session_id`
                                                                                                                                                                     FROM events
                                                                                                                                                                     WHERE and(equals(events.team_id, 2), equals(events.person_id, '00000000-0000-0000-0000-000000000000'), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), notEmpty(events.`$session_id`)))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1192,9 +1192,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1210,7 +1210,7 @@
                                                                                                                                                                        GROUP BY person_distinct_id2.distinct_id
                                                                                                                                                                        HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids
                                                                                                                                                                     WHERE ifNull(equals(person_distinct_ids.person_id, '00000000-0000-0000-0000-000000000000'), 0))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1232,9 +1232,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1250,7 +1250,7 @@
                                                                                                                                                                        GROUP BY person_distinct_id2.distinct_id
                                                                                                                                                                        HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids
                                                                                                                                                                     WHERE ifNull(equals(person_distinct_ids.person_id, '00000000-0000-0000-0000-000000000000'), 0))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1272,9 +1272,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1290,7 +1290,7 @@
                                                                                                                                                                        GROUP BY person_distinct_id2.distinct_id
                                                                                                                                                                        HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids
                                                                                                                                                                     WHERE ifNull(equals(person_distinct_ids.person_id, '00000000-0000-0000-0000-000000000000'), 0))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1312,9 +1312,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1330,7 +1330,7 @@
                                                                                                                                                                        GROUP BY person_distinct_id2.distinct_id
                                                                                                                                                                        HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids
                                                                                                                                                                     WHERE ifNull(equals(person_distinct_ids.person_id, '00000000-0000-0000-0000-000000000000'), 0))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1352,16 +1352,16 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(session_id,
                                                                                                                                                                    (SELECT DISTINCT events.`$session_id` AS `$session_id`
                                                                                                                                                                     FROM events
                                                                                                                                                                     LEFT OUTER JOIN
@@ -1371,7 +1371,7 @@
                                                                                                                                                                        GROUP BY person_distinct_id_overrides.distinct_id
                                                                                                                                                                        HAVING ifNull(equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
                                                                                                                                                                     WHERE and(equals(events.team_id, 2), ifNull(equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), 0), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), notEmpty(events.`$session_id`)))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1393,16 +1393,16 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(session_id,
                                                                                                                                                                    (SELECT DISTINCT events.`$session_id` AS `$session_id`
                                                                                                                                                                     FROM events
                                                                                                                                                                     LEFT OUTER JOIN
@@ -1412,7 +1412,7 @@
                                                                                                                                                                        GROUP BY person_distinct_id_overrides.distinct_id
                                                                                                                                                                        HAVING ifNull(equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
                                                                                                                                                                     WHERE and(equals(events.team_id, 2), ifNull(equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), 0), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), notEmpty(events.`$session_id`)))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1434,16 +1434,16 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(session_id,
                                                                                                                                                                    (SELECT DISTINCT events.`$session_id` AS `$session_id`
                                                                                                                                                                     FROM events
                                                                                                                                                                     LEFT OUTER JOIN
@@ -1453,7 +1453,7 @@
                                                                                                                                                                        GROUP BY person_distinct_id_overrides.distinct_id
                                                                                                                                                                        HAVING ifNull(equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
                                                                                                                                                                     WHERE and(equals(events.team_id, 2), ifNull(equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), 0), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), notEmpty(events.`$session_id`)))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1475,16 +1475,16 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(session_id,
                                                                                                                                                                    (SELECT DISTINCT events.`$session_id` AS `$session_id`
                                                                                                                                                                     FROM events
                                                                                                                                                                     LEFT OUTER JOIN
@@ -1494,7 +1494,7 @@
                                                                                                                                                                        GROUP BY person_distinct_id_overrides.distinct_id
                                                                                                                                                                        HAVING ifNull(equals(argMax(person_distinct_id_overrides.is_deleted, person_distinct_id_overrides.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)
                                                                                                                                                                     WHERE and(equals(events.team_id, 2), ifNull(equals(if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id), '00000000-0000-0000-0000-000000000000'), 0), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), notEmpty(events.`$session_id`)))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 09bcdf2f44af1..755dbecfab0b3 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -8852,6 +8852,22 @@
                         {
                             "const": "console_error_count",
                             "type": "string"
+                        },
+                        {
+                            "const": "click_count",
+                            "type": "string"
+                        },
+                        {
+                            "const": "keypress_count",
+                            "type": "string"
+                        },
+                        {
+                            "const": "mouse_activity_count",
+                            "type": "string"
+                        },
+                        {
+                            "const": "random_sample",
+                            "type": "string"
                         }
                     ]
                 },
diff --git a/frontend/src/queries/schema.ts b/frontend/src/queries/schema.ts
index 66439691f7a80..71d66a33a5956 100644
--- a/frontend/src/queries/schema.ts
+++ b/frontend/src/queries/schema.ts
@@ -294,7 +294,14 @@ export interface RecordingsQuery extends DataNode<RecordingsQueryResponse> {
     operand?: FilterLogicalOperator
     session_ids?: string[]
     person_uuid?: string
-    order: DurationType | 'start_time' | 'console_error_count'
+    order:
+        | DurationType
+        | 'start_time'
+        | 'console_error_count'
+        | 'click_count'
+        | 'keypress_count'
+        | 'mouse_activity_count'
+        | 'random_sample'
     limit?: integer
     offset?: integer
 }
diff --git a/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts b/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts
index 96021bb74ba16..e882a25f25b6e 100644
--- a/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/playerSettingsLogic.ts
@@ -2,7 +2,7 @@ import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea
 import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
 import { teamLogic } from 'scenes/teamLogic'
 
-import { AutoplayDirection, DurationType, SessionRecordingPlayerTab } from '~/types'
+import { AutoplayDirection, SessionRecordingPlayerTab } from '~/types'
 
 import type { playerSettingsLogicType } from './playerSettingsLogicType'
 
@@ -197,7 +197,6 @@ export const playerSettingsLogic = kea<playerSettingsLogicType>([
         setTab: (tab: SessionRecordingPlayerTab) => ({ tab }),
         setMiniFilter: (key: string, enabled: boolean) => ({ key, enabled }),
         setSearchQuery: (search: string) => ({ search }),
-        setDurationTypeToShow: (type: DurationType) => ({ type }),
         setShowFilters: (showFilters: boolean) => ({ showFilters }),
         setQuickFilterProperties: (properties: string[]) => ({ properties }),
         setTimestampFormat: (format: TimestampFormat) => ({ format }),
@@ -242,13 +241,6 @@ export const playerSettingsLogic = kea<playerSettingsLogicType>([
                 setQuickFilterProperties: (_, { properties }) => properties,
             },
         ],
-        durationTypeToShow: [
-            'duration' as DurationType,
-            { persist: true },
-            {
-                setDurationTypeToShow: (_, { type }) => type,
-            },
-        ],
         speed: [
             1,
             { persist: true },
diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx
index 2618cb4a52ce6..66cc946460a9a 100644
--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx
+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingPreview.tsx
@@ -16,10 +16,10 @@ import { useState } from 'react'
 import { countryCodeToName } from 'scenes/insights/views/WorldMap'
 import { DraggableToNotebook } from 'scenes/notebooks/AddToNotebook/DraggableToNotebook'
 import { asDisplay } from 'scenes/persons/person-utils'
-import { playerSettingsLogic } from 'scenes/session-recordings/player/playerSettingsLogic'
 import { urls } from 'scenes/urls'
 
-import { DurationType, SessionRecordingType } from '~/types'
+import { RecordingsQuery } from '~/queries/schema'
+import { SessionRecordingType } from '~/types'
 
 import { sessionRecordingsListPropertiesLogic } from './sessionRecordingsListPropertiesLogic'
 import { sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'
@@ -161,12 +161,12 @@ function ViewedIndicator(): JSX.Element {
     )
 }
 
-function durationToShow(recording: SessionRecordingType, durationType: DurationType | undefined): number | undefined {
-    return {
-        duration: recording.recording_duration,
-        active_seconds: recording.active_seconds,
-        inactive_seconds: recording.inactive_seconds,
-    }[durationType || 'duration']
+function durationToShow(recording: SessionRecordingType, order: RecordingsQuery['order']): number | undefined {
+    return order === 'active_seconds'
+        ? recording.active_seconds
+        : order === 'inactive_seconds'
+        ? recording.inactive_seconds
+        : recording.recording_duration
 }
 
 export function SessionRecordingPreview({
@@ -178,7 +178,6 @@ export function SessionRecordingPreview({
     sessionSummaryLoading,
 }: SessionRecordingPreviewProps): JSX.Element {
     const { orderBy } = useValues(sessionRecordingsPlaylistLogic)
-    const { durationTypeToShow } = useValues(playerSettingsLogic)
 
     const { recordingPropertiesById, recordingPropertiesLoading } = useValues(sessionRecordingsListPropertiesLogic)
     const recordingProperties = recordingPropertiesById[recording.id]
@@ -278,12 +277,7 @@ export function SessionRecordingPreview({
                         {orderBy === 'console_error_count' ? (
                             <ErrorCount iconClassNames={iconClassNames} errorCount={recording.console_error_count} />
                         ) : (
-                            <RecordingDuration
-                                recordingDuration={durationToShow(
-                                    recording,
-                                    orderBy === 'start_time' ? durationTypeToShow : orderBy
-                                )}
-                            />
+                            <RecordingDuration recordingDuration={durationToShow(recording, orderBy)} />
                         )}
                     </div>
 
diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx
index 4c2e0c2ee8e65..3118557c0071c 100644
--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx
+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylist.tsx
@@ -49,19 +49,11 @@ export function SessionRecordingsPlaylist(props: SessionRecordingPlaylistLogicPr
     const notebookNode = useNotebookNode()
 
     const sections: PlaylistSection<SessionRecordingType>[] = []
-    const headerActions = []
 
     const onSummarizeClick = (recording: SessionRecordingType): void => {
         summarizeSession(recording.id)
     }
 
-    headerActions.push({
-        key: 'settings',
-        tooltip: 'Playlist settings',
-        content: <SessionRecordingsPlaylistSettings />,
-        icon: <IconGear />,
-    })
-
     if (pinnedRecordings.length) {
         sections.push({
             key: 'pinned',
@@ -116,7 +108,14 @@ export function SessionRecordingsPlaylist(props: SessionRecordingPlaylistLogicPr
                     title="Recordings"
                     embedded={!!notebookNode}
                     sections={sections}
-                    headerActions={headerActions}
+                    headerActions={[
+                        {
+                            key: 'settings',
+                            tooltip: 'Playlist settings',
+                            content: <SessionRecordingsPlaylistSettings />,
+                            icon: <IconGear />,
+                        },
+                    ]}
                     loading={sessionRecordingsResponseLoading}
                     onScrollListEdge={(edge) => {
                         if (edge === 'top') {
diff --git a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistSettings.tsx b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistSettings.tsx
index 007319a686f45..0cfef0da10c4a 100644
--- a/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistSettings.tsx
+++ b/frontend/src/scenes/session-recordings/playlist/SessionRecordingsPlaylistSettings.tsx
@@ -1,14 +1,14 @@
-import { LemonSwitch } from '@posthog/lemon-ui'
+import { LemonSelect, LemonSwitch } from '@posthog/lemon-ui'
 import { useActions, useValues } from 'kea'
-import { DurationTypeSelect } from 'scenes/session-recordings/filters/DurationTypeSelect'
 
 import { playerSettingsLogic } from '../player/playerSettingsLogic'
 import { sessionRecordingsPlaylistLogic } from './sessionRecordingsPlaylistLogic'
 
 export function SessionRecordingsPlaylistSettings(): JSX.Element {
-    const { durationTypeToShow, hideViewedRecordings } = useValues(playerSettingsLogic)
-    const { setDurationTypeToShow, setHideViewedRecordings } = useActions(playerSettingsLogic)
+    const { hideViewedRecordings } = useValues(playerSettingsLogic)
+    const { setHideViewedRecordings } = useActions(playerSettingsLogic)
     const { orderBy } = useValues(sessionRecordingsPlaylistLogic)
+    const { setOrderBy } = useActions(sessionRecordingsPlaylistLogic)
 
     return (
         <div className="relative flex flex-col gap-2 p-3 border-b">
@@ -20,16 +20,62 @@ export function SessionRecordingsPlaylistSettings(): JSX.Element {
                     onChange={() => setHideViewedRecordings(!hideViewedRecordings)}
                 />
             </div>
-            {orderBy === 'start_time' && (
-                <div className="flex flex-row items-center justify-between space-x-2">
-                    <span className="text-black font-medium">Show</span>
-                    <DurationTypeSelect
-                        value={durationTypeToShow}
-                        onChange={(value) => setDurationTypeToShow(value)}
-                        onChangeEventDescription="session recording list duration type to show selected"
-                    />
-                </div>
-            )}
+            <div className="flex flex-row items-center justify-between space-x-2">
+                <span className="text-black font-medium">Order by</span>
+                <LemonSelect
+                    options={[
+                        {
+                            value: 'start_time',
+                            label: 'Latest',
+                        },
+                        {
+                            label: 'Longest',
+                            options: [
+                                {
+                                    value: 'duration',
+                                    label: 'Total duration',
+                                },
+                                {
+                                    value: 'active_seconds',
+                                    label: 'Active duration',
+                                },
+                                {
+                                    value: 'inactive_seconds',
+                                    label: 'Inactive duration',
+                                },
+                            ],
+                        },
+                        {
+                            label: 'Most active',
+                            options: [
+                                {
+                                    value: 'click_count',
+                                    label: 'Clicks',
+                                },
+                                {
+                                    value: 'keypress_count',
+                                    label: 'Keypresses',
+                                },
+                                {
+                                    value: 'mouse_activity_count',
+                                    label: 'Mouse activity',
+                                },
+                            ],
+                        },
+                        {
+                            value: 'console_error_count',
+                            label: 'Most errors',
+                        },
+                        {
+                            value: 'random_sample',
+                            label: 'Random sample',
+                        },
+                    ]}
+                    size="small"
+                    value={orderBy}
+                    onChange={setOrderBy}
+                />
+            </div>
         </div>
     )
 }
diff --git a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.test.ts b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.test.ts
index 695db20866757..b79c7f805a7cb 100644
--- a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.test.ts
+++ b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.test.ts
@@ -15,9 +15,28 @@ import {
 
 describe('sessionRecordingsPlaylistLogic', () => {
     let logic: ReturnType<typeof sessionRecordingsPlaylistLogic.build>
-    const aRecording = { id: 'abc', viewed: false, recording_duration: 10, console_error_count: 50 }
-    const bRecording = { id: 'def', viewed: false, recording_duration: 10, console_error_count: 100 }
+    const aRecording = {
+        id: 'abc',
+        viewed: false,
+        recording_duration: 10,
+        start_time: '2023-10-12T16:55:36.404000Z',
+        console_error_count: 50,
+    }
+    const bRecording = {
+        id: 'def',
+        viewed: false,
+        recording_duration: 10,
+        start_time: '2023-05-12T16:55:36.404000Z',
+        console_error_count: 100,
+    }
     const listOfSessionRecordings = [aRecording, bRecording]
+    const offsetRecording = {
+        id: `recording_offset_by_${listOfSessionRecordings.length}`,
+        viewed: false,
+        recording_duration: 10,
+        start_time: '2023-08-12T16:55:36.404000Z',
+        console_error_count: 75,
+    }
 
     beforeEach(() => {
         useMocks({
@@ -54,7 +73,7 @@ describe('sessionRecordingsPlaylistLogic', () => {
                         return [
                             200,
                             {
-                                results: [`List of recordings offset by ${listOfSessionRecordings.length}`],
+                                results: [offsetRecording],
                             },
                         ]
                     } else if (
@@ -167,6 +186,11 @@ describe('sessionRecordingsPlaylistLogic', () => {
         })
 
         describe('ordering', () => {
+            afterEach(() => {
+                logic.actions.setOrderBy('start_time')
+                logic.actions.loadSessionRecordings()
+            })
+
             it('is set by setOrderBy, loads filtered results and orders the non pinned recordings', async () => {
                 await expectLogic(logic, () => {
                     logic.actions.setOrderBy('console_error_count')
@@ -179,21 +203,22 @@ describe('sessionRecordingsPlaylistLogic', () => {
                 expect(logic.values.otherRecordings.map((r) => r.console_error_count)).toEqual([100, 50])
             })
 
-            it('adds an offset when not using latest ordering', async () => {
+            it('adds an offset', async () => {
                 await expectLogic(logic, () => {
-                    logic.actions.setOrderBy('console_error_count')
+                    logic.actions.loadSessionRecordings()
                 })
-                    .toDispatchActionsInAnyOrder(['loadSessionRecordingsSuccess'])
+                    .toDispatchActions(['loadSessionRecordingsSuccess'])
                     .toMatchValues({
                         sessionRecordings: listOfSessionRecordings,
                     })
 
                 await expectLogic(logic, () => {
-                    logic.actions.maybeLoadSessionRecordings('newer')
+                    logic.actions.loadSessionRecordings('older')
                 })
                     .toDispatchActions(['loadSessionRecordingsSuccess'])
                     .toMatchValues({
-                        sessionRecordings: [...listOfSessionRecordings, 'List of recordings offset by 2'],
+                        // reorganises recordings based on start_time
+                        sessionRecordings: [aRecording, offsetRecording, bRecording],
                     })
             })
         })
@@ -306,6 +331,7 @@ describe('sessionRecordingsPlaylistLogic', () => {
                 expect(router.values.searchParams.filters).toHaveProperty('date_to', '2021-10-20')
             })
         })
+
         describe('duration filter', () => {
             it('is set by setFilters and fetches results from server and sets the url', async () => {
                 await expectLogic(logic, () => {
@@ -370,8 +396,9 @@ describe('sessionRecordingsPlaylistLogic', () => {
                     .toFinishAllListeners()
                     .toMatchValues({
                         sessionRecordingsResponse: {
-                            results: listOfSessionRecordings,
+                            order: 'start_time',
                             has_next: undefined,
+                            results: listOfSessionRecordings,
                         },
                         sessionRecordings: listOfSessionRecordings,
                     })
@@ -382,6 +409,8 @@ describe('sessionRecordingsPlaylistLogic', () => {
                     .toFinishAllListeners()
                     .toMatchValues({
                         sessionRecordingsResponse: {
+                            has_next: undefined,
+                            order: 'start_time',
                             results: [
                                 {
                                     ...aRecording,
diff --git a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts
index 12336da783084..1c064ff9d2cf8 100644
--- a/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts
+++ b/frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts
@@ -234,6 +234,25 @@ function combineLegacyRecordingFilters(
     }
 }
 
+function sortRecordings(recordings: SessionRecordingType[], order: RecordingsQuery['order']): SessionRecordingType[] {
+    const orderKey:
+        | 'recording_duration'
+        | 'active_seconds'
+        | 'inactive_seconds'
+        | 'console_error_count'
+        | 'click_count'
+        | 'keypress_count'
+        | 'mouse_activity_count'
+        | 'start_time' = order === 'duration' ? 'recording_duration' : order === 'random_sample' ? 'start_time' : order
+
+    return recordings.sort((a, b) => {
+        const orderA = a[orderKey]
+        const orderB = b[orderKey]
+        const incomparible = orderA === undefined || orderB === undefined
+        return incomparible ? 0 : orderA > orderB ? -1 : 1
+    })
+}
+
 export interface SessionRecordingPlaylistLogicProps {
     logicKey?: string
     personUUID?: PersonUUID
@@ -333,7 +352,8 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogic
             {
                 results: [],
                 has_next: false,
-            } as RecordingsQueryResponse,
+                order: 'start_time',
+            } as RecordingsQueryResponse & { order: RecordingsQuery['order'] },
             {
                 loadSessionRecordings: async ({ direction }, breakpoint) => {
                     const params: RecordingsQuery = {
@@ -343,22 +363,12 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogic
                         limit: RECORDINGS_LIMIT,
                     }
 
-                    if (values.orderBy === 'start_time') {
-                        if (direction === 'older') {
-                            params.date_to = values.sessionRecordings[values.sessionRecordings.length - 1]?.start_time
-                        }
-
-                        if (direction === 'newer') {
-                            params.date_from = values.sessionRecordings[0]?.start_time
-                        }
-                    } else {
-                        if (direction === 'older') {
-                            params.offset = values.sessionRecordings.length
-                        }
+                    if (direction === 'older') {
+                        params.offset = values.sessionRecordings.length
+                    }
 
-                        if (direction === 'newer') {
-                            params.offset = 0
-                        }
+                    if (direction === 'newer') {
+                        params.offset = 0
                     }
 
                     await breakpoint(400) // Debounce for lots of quick filter changes
@@ -377,6 +387,7 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogic
                                 ? values.sessionRecordingsResponse?.has_next ?? true
                                 : response.has_next,
                         results: response.results,
+                        order: values.orderBy,
                     }
                 },
             },
@@ -496,9 +507,7 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogic
                         }
                     })
 
-                    mergedResults.sort((a, b) => (a.start_time > b.start_time ? -1 : 1))
-
-                    return mergedResults
+                    return sortRecordings(mergedResults, sessionRecordingsResponse.order)
                 },
 
                 setSelectedRecordingId: (state, { id }) =>
@@ -691,19 +700,19 @@ export const sessionRecordingsPlaylistLogic = kea<sessionRecordingsPlaylistLogic
                 selectedRecordingId,
                 orderBy
             ): SessionRecordingType[] => {
-                return sessionRecordings
-                    .filter((rec) => {
-                        if (pinnedRecordings.find((pinned) => pinned.id === rec.id)) {
-                            return false
-                        }
+                const filteredRecordings = sessionRecordings.filter((rec) => {
+                    if (pinnedRecordings.find((pinned) => pinned.id === rec.id)) {
+                        return false
+                    }
 
-                        if (hideViewedRecordings && rec.viewed && rec.id !== selectedRecordingId) {
-                            return false
-                        }
+                    if (hideViewedRecordings && rec.viewed && rec.id !== selectedRecordingId) {
+                        return false
+                    }
 
-                        return true
-                    })
-                    .sort((a, b) => (a[orderBy] > b[orderBy] ? -1 : 1))
+                    return true
+                })
+
+                return sortRecordings(filteredRecordings, orderBy)
             },
         ],
 
diff --git a/posthog/hogql/functions/mapping.py b/posthog/hogql/functions/mapping.py
index 232e99e7a064e..1bfed5ae8daa9 100644
--- a/posthog/hogql/functions/mapping.py
+++ b/posthog/hogql/functions/mapping.py
@@ -597,6 +597,8 @@ def compare_types(arg_types: list[ConstantType], sig_arg_types: tuple[ConstantTy
     # conditional
     "if": HogQLFunctionMeta("if", 3, 3, case_sensitive=False),
     "multiIf": HogQLFunctionMeta("multiIf", 3, None),
+    # hashing
+    "sipHash64": HogQLFunctionMeta("sipHash64", 1, 1),
     # mathematical
     "e": HogQLFunctionMeta("e"),
     "pi": HogQLFunctionMeta("pi"),
diff --git a/posthog/session_recordings/queries/session_recording_list_from_filters.py b/posthog/session_recordings/queries/session_recording_list_from_filters.py
index 3cba03d260500..6c56750e7254e 100644
--- a/posthog/session_recordings/queries/session_recording_list_from_filters.py
+++ b/posthog/session_recordings/queries/session_recording_list_from_filters.py
@@ -36,29 +36,6 @@ class SessionRecordingListFromFilters:
     _team: Team
     _filter: SessionRecordingsFilter
 
-    BASE_QUERY: str = """
-        SELECT s.session_id,
-            any(s.team_id),
-            any(s.distinct_id),
-            min(s.min_first_timestamp) as start_time,
-            max(s.max_last_timestamp) as end_time,
-            dateDiff('SECOND', start_time, end_time) as duration,
-            argMinMerge(s.first_url) as first_url,
-            sum(s.click_count),
-            sum(s.keypress_count),
-            sum(s.mouse_activity_count),
-            sum(s.active_milliseconds)/1000 as active_seconds,
-            (duration - active_seconds) as inactive_seconds,
-            sum(s.console_log_count) as console_log_count,
-            sum(s.console_warn_count) as console_warn_count,
-            sum(s.console_error_count) as console_error_count
-        FROM raw_session_replay_events s
-        WHERE {where_predicates}
-        GROUP BY session_id
-        HAVING {having_predicates}
-        ORDER BY {order_by} DESC
-        """
-
     @staticmethod
     def _data_to_return(results: list[Any] | None) -> list[dict[str, Any]]:
         default_columns = [
@@ -122,17 +99,86 @@ def run(self) -> SessionRecordingQueryResult:
         )
 
     def get_query(self):
-        return parse_select(
-            self.BASE_QUERY,
-            {
-                "order_by": self._order_by_clause(),
-                "where_predicates": self._where_predicates(),
-                "having_predicates": self._having_predicates(),
-            },
+        return ast.SelectQuery(
+            select=self._select(),
+            select_from=ast.JoinExpr(table=ast.Field(chain=["raw_session_replay_events"]), alias="s"),
+            where=self._where_predicates(),
+            order_by=[self._order_by_clause()],
+            group_by=[ast.Field(chain=["session_id"])],
+            having=self._having_predicates(),
         )
 
-    def _order_by_clause(self) -> ast.Field:
-        return ast.Field(chain=[self._filter.order])
+    def _select(self) -> list[ast.Expr]:
+        return [
+            ast.Alias(alias="session_id", expr=ast.Field(chain=["s", "session_id"])),
+            ast.Call(name="any", args=[ast.Field(chain=["s", "team_id"])]),
+            ast.Call(name="any", args=[ast.Field(chain=["s", "distinct_id"])]),
+            ast.Alias(
+                alias="start_time",
+                expr=ast.Call(name="min", args=[ast.Field(chain=["s", "min_first_timestamp"])]),
+            ),
+            ast.Alias(
+                alias="end_time",
+                expr=ast.Call(name="max", args=[ast.Field(chain=["s", "max_last_timestamp"])]),
+            ),
+            ast.Alias(
+                alias="duration",
+                expr=ast.Call(
+                    name="dateDiff",
+                    args=[ast.Constant(value="SECOND"), ast.Field(chain=["start_time"]), ast.Field(chain=["end_time"])],
+                ),
+            ),
+            ast.Alias(
+                alias="first_url",
+                expr=ast.Call(name="argMinMerge", args=[ast.Field(chain=["s", "first_url"])]),
+            ),
+            ast.Alias(
+                alias="click_count",
+                expr=ast.Call(name="sum", args=[ast.Field(chain=["s", "click_count"])]),
+            ),
+            ast.Alias(
+                alias="keypress_count",
+                expr=ast.Call(name="sum", args=[ast.Field(chain=["s", "keypress_count"])]),
+            ),
+            ast.Alias(
+                alias="mouse_activity_count",
+                expr=ast.Call(name="sum", args=[ast.Field(chain=["s", "mouse_activity_count"])]),
+            ),
+            ast.Alias(
+                alias="active_seconds",
+                expr=ast.Call(
+                    name="divide",
+                    args=[
+                        ast.Call(name="sum", args=[ast.Field(chain=["s", "active_milliseconds"])]),
+                        ast.Constant(value=1000),
+                    ],
+                ),
+            ),
+            ast.Alias(
+                alias="inactive_seconds",
+                expr=ast.Call(name="minus", args=[ast.Field(chain=["duration"]), ast.Field(chain=["active_seconds"])]),
+            ),
+            ast.Alias(
+                alias="console_log_count",
+                expr=ast.Call(name="sum", args=[ast.Field(chain=["s", "console_log_count"])]),
+            ),
+            ast.Alias(
+                alias="console_warn_count",
+                expr=ast.Call(name="sum", args=[ast.Field(chain=["s", "console_warn_count"])]),
+            ),
+            ast.Alias(
+                alias="console_error_count",
+                expr=ast.Call(name="sum", args=[ast.Field(chain=["s", "console_error_count"])]),
+            ),
+        ]
+
+    def _order_by_clause(self) -> ast.OrderExpr:
+        expr = (
+            ast.Call(name="sipHash64", args=[ast.Field(chain=["session_id"])])
+            if self._filter.order == "random_sample"
+            else ast.Field(chain=[self._filter.order])
+        )
+        return ast.OrderExpr(expr=expr, order="DESC")
 
     def _where_predicates(self) -> Union[ast.And, ast.Or]:
         exprs: list[ast.Expr] = [
diff --git a/posthog/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr b/posthog/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr
index bcd56921df145..73319138243d3 100644
--- a/posthog/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr
+++ b/posthog/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_filters.ambr
@@ -8,9 +8,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -23,7 +23,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2022-12-14 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2022-12-27 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0), ifNull(equals(nullIf(nullIf(events.`$session_id`, ''), 'null'), 'test_action_filter-session-one'), 0), ifNull(equals(nullIf(nullIf(events.`$window_id`, ''), 'null'), 'test_action_filter-window-id'), 0))), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['custom-event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -45,9 +45,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -60,7 +60,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2022-12-14 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2022-12-27 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(ifNull(equals(nullIf(nullIf(events.`$session_id`, ''), 'null'), 'test_action_filter-session-one'), 0), ifNull(equals(nullIf(nullIf(events.`$window_id`, ''), 'null'), 'test_action_filter-window-id'), 0))), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['custom-event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -82,9 +82,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -97,7 +97,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2022-12-14 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2022-12-27 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(ifNull(equals(nullIf(nullIf(events.`$session_id`, ''), 'null'), 'test_action_filter-session-one'), 0), ifNull(equals(nullIf(nullIf(events.`$window_id`, ''), 'null'), 'test_action_filter-window-id'), 0))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['custom-event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -119,9 +119,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -134,7 +134,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2022-12-14 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2022-12-27 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2023-01-04 00:00:00.000000', 6, 'UTC')), and(and(equals(events.event, 'custom-event'), and(ifNull(equals(nullIf(nullIf(events.`$session_id`, ''), 'null'), 'test_action_filter-session-one'), 0), ifNull(equals(nullIf(nullIf(events.`$window_id`, ''), 'null'), 'test_action_filter-window-id'), 0))), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['custom-event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -156,9 +156,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -179,7 +179,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-21 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-04 23:59:59.999999', 6, 'UTC')), or(and(equals(events.event, '$pageview'), 1), and(equals(events.event, 'custom-event'), 1)))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  HAVING hasAll(groupUniqArray(events.event), ['$pageview', 'custom-event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -201,9 +201,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -216,7 +216,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(1, 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -238,9 +238,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -253,7 +253,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(1, ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -275,9 +275,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -290,7 +290,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(1, ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -312,9 +312,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -327,7 +327,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(1, 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -349,9 +349,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -364,7 +364,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(1, ifNull(equals(nullIf(nullIf(events.`mat_$browser`, ''), 'null'), 'Chrome'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -386,9 +386,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -401,7 +401,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(1, ifNull(equals(nullIf(nullIf(events.`mat_$browser`, ''), 'null'), 'Firefox'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING 1)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -423,9 +423,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -433,7 +433,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -455,9 +455,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -465,7 +465,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING ifNull(greater(duration, 60), 0)
   ORDER BY start_time DESC
   LIMIT 51
@@ -487,9 +487,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -497,7 +497,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING ifNull(greater(active_seconds, '60'), 0)
   ORDER BY start_time DESC
   LIMIT 51
@@ -519,9 +519,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -529,7 +529,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING ifNull(greater(inactive_seconds, '60'), 0)
   ORDER BY start_time DESC
   LIMIT 51
@@ -551,9 +551,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -561,7 +561,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY active_seconds DESC
   LIMIT 4
@@ -583,9 +583,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -593,7 +593,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY console_error_count DESC
   LIMIT 4
@@ -615,9 +615,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -625,7 +625,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 4
@@ -647,9 +647,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -657,7 +657,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 2
@@ -679,9 +679,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -689,7 +689,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 2
@@ -711,9 +711,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -721,7 +721,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 2
@@ -743,9 +743,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -753,7 +753,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -775,9 +775,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -785,7 +785,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-30 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -807,9 +807,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -817,7 +817,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 12:46:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-12 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 12:46:00.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -839,9 +839,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -849,7 +849,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 12:46:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 12:46:00.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -871,9 +871,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -881,7 +881,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 12:46:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-10 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 12:46:00.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -903,9 +903,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -913,7 +913,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-28 23:59:59.999999', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -935,9 +935,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -945,7 +945,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-29 23:59:59.999999', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -967,9 +967,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -977,7 +977,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING ifNull(greater(duration, 60), 0)
   ORDER BY start_time DESC
   LIMIT 51
@@ -999,9 +999,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1009,7 +1009,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING ifNull(less(duration, 60), 0)
   ORDER BY start_time DESC
   LIMIT 51
@@ -1031,9 +1031,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1046,7 +1046,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1068,9 +1068,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1083,7 +1083,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$autocapture'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$autocapture']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1105,9 +1105,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1120,7 +1120,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1142,9 +1142,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1152,7 +1152,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1174,9 +1174,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1189,7 +1189,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING ifNull(greater(duration, 60), 0)
   ORDER BY start_time DESC
   LIMIT 51
@@ -1211,9 +1211,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1226,7 +1226,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING ifNull(greater(active_seconds, 60), 0)
   ORDER BY start_time DESC
   LIMIT 51
@@ -1248,9 +1248,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1268,7 +1268,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__group_1.properties___name, 'org one'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1290,9 +1290,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1305,7 +1305,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1327,9 +1327,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1374,7 +1374,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0)))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1396,9 +1396,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1428,7 +1428,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                              WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))), ifNull(equals(s__events.`properties___$browser`, 'Chrome'), 0)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1450,9 +1450,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1465,7 +1465,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1487,9 +1487,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1534,7 +1534,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0)))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1556,9 +1556,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1588,7 +1588,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                              WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))), ifNull(equals(s__events.`properties___$browser`, 'Chrome'), 0)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1610,9 +1610,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1640,7 +1640,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__pdi__person.properties___email, 'bla'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1662,9 +1662,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1692,7 +1692,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(events__pdi__person.properties___email, 'something else'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1714,9 +1714,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1729,7 +1729,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1751,9 +1751,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1766,7 +1766,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1788,9 +1788,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1803,7 +1803,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(nullIf(nullIf(events.`mat_$browser`, ''), 'null'), 'Chrome'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1825,9 +1825,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1840,7 +1840,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(nullIf(nullIf(events.`mat_$browser`, ''), 'null'), 'Firefox'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1862,9 +1862,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1877,7 +1877,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1899,9 +1899,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1914,7 +1914,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$autocapture'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$autocapture']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1936,9 +1936,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1951,7 +1951,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -1973,9 +1973,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -1988,7 +1988,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Firefox'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2010,9 +2010,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2025,7 +2025,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Chrome'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['a_different_event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2047,9 +2047,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2062,7 +2062,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, '$browser'), ''), 'null'), '^"|"$', ''), 'Safari'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['a_different_event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2084,9 +2084,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2099,7 +2099,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(nullIf(nullIf(events.`mat_$browser`, ''), 'null'), 'Chrome'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2121,9 +2121,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2136,7 +2136,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), ifNull(equals(nullIf(nullIf(events.`mat_$browser`, ''), 'null'), 'Firefox'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2158,9 +2158,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2173,7 +2173,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(nullIf(nullIf(events.`mat_$browser`, ''), 'null'), 'Chrome'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['a_different_event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2195,9 +2195,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2210,7 +2210,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, 'a_different_event'), ifNull(equals(nullIf(nullIf(events.`mat_$browser`, ''), 'null'), 'Safari'), 0)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['a_different_event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2232,9 +2232,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2285,7 +2285,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  WHERE ifNull(notILike(person_distinct_ids__person.properties___email, '%@posthog.com%'), 1))), and(ifNull(equals(s__events.properties___is_internal_user, 'false'), 0), ifNull(equals(s__events.`properties___$browser`, 'Chrome'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2307,9 +2307,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2322,7 +2322,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2344,9 +2344,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2397,7 +2397,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  WHERE ifNull(notILike(person_distinct_ids__person.properties___email, '%@posthog.com%'), 1))), and(ifNull(equals(s__events.properties___is_internal_user, 'false'), 0), ifNull(equals(s__events.`properties___$browser`, 'Chrome'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2419,9 +2419,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2434,7 +2434,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2456,9 +2456,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2471,7 +2471,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), or(and(equals(events.event, '$pageview'), 1), and(equals(events.event, '$pageleave'), 1)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageleave', '$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2493,23 +2493,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(or(or(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.level, 'error'), 0)), ifNull(equals(console_logs_log_entries.message, 'message 4'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(or(or(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.level, 'error'), 0)), ifNull(equals(console_logs_log_entries.message, 'message 4'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2531,23 +2531,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(and(or(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.level, 'error'), 0)), ifNull(ilike(console_logs_log_entries.message, '%message 5%'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(and(or(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.level, 'error'), 0)), ifNull(ilike(console_logs_log_entries.message, '%message 5%'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2569,23 +2569,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(ilike(console_logs_log_entries.message, '%message 5%'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(ilike(console_logs_log_entries.message, '%message 5%'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2607,9 +2607,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2617,7 +2617,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING ifNull(equals(argMinMerge(s.snapshot_source), 'web'), 0)
   ORDER BY start_time DESC
   LIMIT 51
@@ -2639,9 +2639,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -2649,7 +2649,7 @@
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING ifNull(equals(argMinMerge(s.snapshot_source), 'mobile'), 0)
   ORDER BY start_time DESC
   LIMIT 51
@@ -2671,23 +2671,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(ifNull(equals(console_logs_log_entries.level, 'error'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(ifNull(equals(console_logs_log_entries.level, 'error'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2709,23 +2709,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2747,23 +2747,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2785,23 +2785,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2823,23 +2823,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2861,23 +2861,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2899,23 +2899,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(or(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.level, 'error'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(or(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.level, 'error'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2937,23 +2937,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(ifNull(equals(console_logs_log_entries.level, 'info'), 0), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -2975,22 +2975,17 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2),
-            ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0),
-            in(s.session_id,
-               ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],
-               ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0),
-               ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(in(session_id, ['3fa32102-80af-47bf-8ec2-2528f7411564']), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3012,22 +3007,17 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2),
-            ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0),
-            in(s.session_id,
-               ['00000000-0000-0000-0000-000000000000', '00000000-0000-0000-0000-000000000001' /* ... */],
-               ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0),
-               ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(in(session_id, ['3fa32102-80af-47bf-8ec2-2528f7411564', 'b49fcdd2-d2de-45a5-b735-a094409274a6']), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3069,9 +3059,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3089,7 +3079,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                (SELECT cohortpeople.person_id AS person_id
                                                                                                                                                                                                                                                                                                                                                                                                                                 FROM cohortpeople
                                                                                                                                                                                                                                                                                                                                                                                                                                 WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 2), equals(cohortpeople.version, 0)))), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3131,9 +3121,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3156,7 +3146,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT cohortpeople.person_id AS person_id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         FROM cohortpeople
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 2), equals(cohortpeople.version, 0)))), 0)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3178,9 +3168,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3203,7 +3193,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT cohortpeople.person_id AS person_id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            FROM cohortpeople
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, 2), equals(cohortpeople.version, 0)))), 0)))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3225,9 +3215,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3252,7 +3242,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla@gmail.com'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3274,9 +3264,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3301,7 +3291,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(notILike(person_distinct_ids__person.properties___email, '%gmail.com%'), 1))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3323,9 +3313,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3338,7 +3328,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), or(and(equals(events.event, '$pageview'), 1), and(equals(events.event, 'new-event'), 1)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview', 'new-event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3360,9 +3350,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3375,7 +3365,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), or(and(equals(events.event, '$pageview'), 1), and(equals(events.event, 'new-event2'), 1)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview', 'new-event2']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3397,9 +3387,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3412,7 +3402,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), or(and(equals(events.event, '$pageview'), 1), and(equals(events.event, 'new-event2'), 1)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAny(groupUniqArray(events.event), ['$pageview', 'new-event2']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3434,9 +3424,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3449,7 +3439,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), or(and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'bar'), ''), 'null'), '^"|"$', ''), 'foo'), 0))))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3471,9 +3461,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3486,7 +3476,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), or(and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0))))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview', 'new-event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3508,9 +3498,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3523,7 +3513,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), or(and(equals(events.event, '$pageview'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0)), and(equals(events.event, 'new-event'), ifNull(equals(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'foo'), ''), 'null'), '^"|"$', ''), 'bar'), 0))))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAny(groupUniqArray(events.event), ['$pageview', 'new-event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3545,9 +3535,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3560,7 +3550,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), or(and(equals(events.event, '$pageview'), 1), and(equals(events.event, 'custom_event'), 1)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview', 'custom_event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3582,9 +3572,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3597,7 +3587,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), or(and(equals(events.event, '$pageview'), 1), and(equals(events.event, 'custom_event'), 1)))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAny(groupUniqArray(events.event), ['$pageview', 'custom_event']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3619,23 +3609,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(and(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.message, 'random'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(and(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.message, 'random'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3657,23 +3647,23 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                        (SELECT console_logs_log_entries.log_source_id AS log_source_id
-                                                                                                                                                                                                                                                                                                                                                                                                                         FROM
-                                                                                                                                                                                                                                                                                                                                                                                                                           (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
-                                                                                                                                                                                                                                                                                                                                                                                                                            FROM log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                            WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
-                                                                                                                                                                                                                                                                                                                                                                                                                         WHERE and(or(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.message, 'random'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0), ifNull(in(session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                               (SELECT console_logs_log_entries.log_source_id AS log_source_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                FROM
+                                                                                                                                                                                                                                                                                                                                                                                                                                  (SELECT log_entries.log_source_id AS log_source_id, log_entries.level AS level, log_entries.message AS message, log_entries.log_source AS log_source
+                                                                                                                                                                                                                                                                                                                                                                                                                                   FROM log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                   WHERE and(equals(log_entries.team_id, 2), equals(log_entries.log_source, 'session_replay'))) AS console_logs_log_entries
+                                                                                                                                                                                                                                                                                                                                                                                                                                WHERE and(or(ifNull(equals(console_logs_log_entries.level, 'warn'), 0), ifNull(equals(console_logs_log_entries.message, 'random'), 0)), ifNull(equals(console_logs_log_entries.log_source, 'session_replay'), 0)))), 0))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3695,9 +3685,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3718,7 +3708,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  HAVING hasAny(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3740,9 +3730,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3763,7 +3753,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  HAVING hasAny(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3785,22 +3775,22 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id, ['session_id_one']), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                                                              (SELECT events.`$session_id` AS session_id
-                                                                                                                                                                                                                                                                                                                                                                                                                                                               FROM events
-                                                                                                                                                                                                                                                                                                                                                                                                                                                               WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1), in(events.`$session_id`, ['session_id_one']))
-                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY events.`$session_id`
-                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING hasAny(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(in(session_id, ['session_id_one']), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                       (SELECT events.`$session_id` AS session_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                        FROM events
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                        WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1), in(events.`$session_id`, ['session_id_one']))
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                        GROUP BY events.`$session_id`
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                        HAVING hasAny(groupUniqArray(events.event), ['$pageview']))))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3822,22 +3812,22 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
          sum(s.console_warn_count) AS console_warn_count,
          sum(s.console_error_count) AS console_error_count
   FROM session_replay_events AS s
-  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id, ['session_id_two']), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
-                                                                                                                                                                                                                                                                                                                                                                                                                                                              (SELECT events.`$session_id` AS session_id
-                                                                                                                                                                                                                                                                                                                                                                                                                                                               FROM events
-                                                                                                                                                                                                                                                                                                                                                                                                                                                               WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1), in(events.`$session_id`, ['session_id_two']))
-                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY events.`$session_id`
-                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING hasAny(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), 0), ifNull(in(session_id, ['session_id_two']), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0), in(s.session_id,
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                       (SELECT events.`$session_id` AS session_id
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                        FROM events
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                        WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-11 13:46:23.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-24 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1), in(events.`$session_id`, ['session_id_two']))
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                        GROUP BY events.`$session_id`
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                        HAVING hasAny(groupUniqArray(events.event), ['$pageview']))))
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3859,9 +3849,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3886,7 +3876,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(ifNull(equals(person_distinct_ids__person.properties___email, 'test@posthog.com'), 0), ifNull(equals(person_distinct_ids__person.properties___email, 'david@posthog.com'), 0)))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3908,9 +3898,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3935,7 +3925,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE or(ifNull(equals(person_distinct_ids__person.properties___email, 'test@posthog.com'), 0), ifNull(equals(person_distinct_ids__person.properties___email, 'david@posthog.com'), 0)))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3948,6 +3938,70 @@
                     max_bytes_before_external_group_by=0
   '''
 # ---
+# name: TestSessionRecordingsListFromFilters.test_ordering
+  '''
+  SELECT s.session_id AS session_id,
+         any(s.team_id),
+         any(s.distinct_id),
+         min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,
+         max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
+         dateDiff('SECOND', start_time, end_time) AS duration,
+         argMinMerge(s.first_url) AS first_url,
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
+         divide(sum(s.active_milliseconds), 1000) AS active_seconds,
+         minus(duration, active_seconds) AS inactive_seconds,
+         sum(s.console_log_count) AS console_log_count,
+         sum(s.console_warn_count) AS console_warn_count,
+         sum(s.console_error_count) AS console_error_count
+  FROM session_replay_events AS s
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0))
+  GROUP BY session_id
+  HAVING 1
+  ORDER BY start_time DESC
+  LIMIT 51
+  OFFSET 0 SETTINGS readonly=2,
+                    max_execution_time=60,
+                    allow_experimental_object_type=1,
+                    format_csv_allow_double_quotes=0,
+                    max_ast_elements=4000000,
+                    max_expanded_ast_elements=4000000,
+                    max_bytes_before_external_group_by=0
+  '''
+# ---
+# name: TestSessionRecordingsListFromFilters.test_ordering.1
+  '''
+  SELECT s.session_id AS session_id,
+         any(s.team_id),
+         any(s.distinct_id),
+         min(toTimeZone(s.min_first_timestamp, 'UTC')) AS start_time,
+         max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
+         dateDiff('SECOND', start_time, end_time) AS duration,
+         argMinMerge(s.first_url) AS first_url,
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
+         divide(sum(s.active_milliseconds), 1000) AS active_seconds,
+         minus(duration, active_seconds) AS inactive_seconds,
+         sum(s.console_log_count) AS console_log_count,
+         sum(s.console_warn_count) AS console_warn_count,
+         sum(s.console_error_count) AS console_error_count
+  FROM session_replay_events AS s
+  WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0))
+  GROUP BY session_id
+  HAVING 1
+  ORDER BY mouse_activity_count DESC
+  LIMIT 51
+  OFFSET 0 SETTINGS readonly=2,
+                    max_execution_time=60,
+                    allow_experimental_object_type=1,
+                    format_csv_allow_double_quotes=0,
+                    max_ast_elements=4000000,
+                    max_expanded_ast_elements=4000000,
+                    max_bytes_before_external_group_by=0
+  '''
+# ---
 # name: TestSessionRecordingsListFromFilters.test_person_id_filter
   '''
   SELECT s.session_id AS session_id,
@@ -3957,9 +4011,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -3975,7 +4029,7 @@
                                                                                                                                                                        GROUP BY person_distinct_id2.distinct_id
                                                                                                                                                                        HAVING ifNull(equals(argMax(person_distinct_id2.is_deleted, person_distinct_id2.version), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids
                                                                                                                                                                     WHERE ifNull(equals(person_distinct_ids.person_id, '00000000-0000-0000-0000-000000000000'), 0))), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-25 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-01 13:46:23.000000', 6, 'UTC')), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -3997,9 +4051,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4012,7 +4066,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4034,9 +4088,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4049,7 +4103,7 @@
      FROM events PREWHERE greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), minus(toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), toIntervalDay(90)))
      WHERE equals(events.team_id, 2)) AS s__events ON equals(s.session_id, s__events.`$session_id`)
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(equals(s__events.properties___is_internal_user, 'false'), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4071,9 +4125,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4086,7 +4140,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4108,9 +4162,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4123,7 +4177,7 @@
      FROM events PREWHERE greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), minus(toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), toIntervalDay(90)))
      WHERE equals(events.team_id, 2)) AS s__events ON equals(s.session_id, s__events.`$session_id`)
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(equals(s__events.properties___is_internal_user, 'false'), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4145,9 +4199,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4160,7 +4214,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4182,9 +4236,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4197,7 +4251,7 @@
      FROM events PREWHERE greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), minus(toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), toIntervalDay(90)))
      WHERE equals(events.team_id, 2)) AS s__events ON equals(s.session_id, s__events.`$session_id`)
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(equals(s__events.properties___is_internal_user, 'false'), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4219,9 +4273,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4234,7 +4288,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4256,9 +4310,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4271,7 +4325,7 @@
      FROM events PREWHERE greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), minus(toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), toIntervalDay(90)))
      WHERE equals(events.team_id, 2)) AS s__events ON equals(s.session_id, s__events.`$session_id`)
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(equals(s__events.properties___is_internal_user, 'false'), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4293,9 +4347,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4308,7 +4362,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4330,9 +4384,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4345,7 +4399,7 @@
      FROM events PREWHERE greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), minus(toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), toIntervalDay(90)))
      WHERE equals(events.team_id, 2)) AS s__events ON equals(s.session_id, s__events.`$session_id`)
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(equals(s__events.properties___is_internal_user, 'true'), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4367,9 +4421,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4382,7 +4436,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4404,9 +4458,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4419,7 +4473,7 @@
      FROM events PREWHERE greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), minus(toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC'), toIntervalDay(90)))
      WHERE equals(events.team_id, 2)) AS s__events ON equals(s.session_id, s__events.`$session_id`)
   WHERE and(equals(s.team_id, 2), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), 0), ifNull(greaterOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-14 00:00:00.000000', 6, 'UTC')), 0), ifNull(lessOrEquals(toTimeZone(s.min_first_timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), 0), ifNull(equals(s__events.properties___is_internal_user, 'true'), 0))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4441,9 +4495,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4456,7 +4510,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4478,9 +4532,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4505,7 +4559,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4527,9 +4581,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4542,7 +4596,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4564,9 +4618,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4591,7 +4645,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4613,9 +4667,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4628,7 +4682,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4650,9 +4704,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4677,7 +4731,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4699,9 +4753,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4714,7 +4768,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE and(equals(events.team_id, 2), notEmpty(events.`$session_id`), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2020-12-31 20:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), now64(6, 'UTC')), greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-13 23:58:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(events.timestamp, 'UTC'), toDateTime64('2021-01-21 20:00:00.000000', 6, 'UTC')), and(equals(events.event, '$pageview'), 1))
                                                                                                                                                                                                                                                                                                                                                                                                                          GROUP BY events.`$session_id`
                                                                                                                                                                                                                                                                                                                                                                                                                          HAVING hasAll(groupUniqArray(events.event), ['$pageview']))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
@@ -4736,9 +4790,9 @@
          max(toTimeZone(s.max_last_timestamp, 'UTC')) AS end_time,
          dateDiff('SECOND', start_time, end_time) AS duration,
          argMinMerge(s.first_url) AS first_url,
-         sum(s.click_count),
-         sum(s.keypress_count),
-         sum(s.mouse_activity_count),
+         sum(s.click_count) AS click_count,
+         sum(s.keypress_count) AS keypress_count,
+         sum(s.mouse_activity_count) AS mouse_activity_count,
          divide(sum(s.active_milliseconds), 1000) AS active_seconds,
          minus(duration, active_seconds) AS inactive_seconds,
          sum(s.console_log_count) AS console_log_count,
@@ -4763,7 +4817,7 @@
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               GROUP BY person.id
                                                                                                                                                                                                                                                                                                                                                                                                                                                                               HAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0)))), 0)) SETTINGS optimize_aggregation_in_order=1) AS person_distinct_ids__person ON equals(person_distinct_ids.person_distinct_ids___person_id, person_distinct_ids__person.id)
                                                                                                                                                                                                                                                                                                                                                                                                                          WHERE ifNull(equals(person_distinct_ids__person.properties___email, 'bla'), 0))))
-  GROUP BY s.session_id
+  GROUP BY session_id
   HAVING 1
   ORDER BY start_time DESC
   LIMIT 51
diff --git a/posthog/session_recordings/queries/test/test_session_recording_list_from_filters.py b/posthog/session_recordings/queries/test/test_session_recording_list_from_filters.py
index aeb434cb89ce9..cc228c813ec00 100644
--- a/posthog/session_recordings/queries/test/test_session_recording_list_from_filters.py
+++ b/posthog/session_recordings/queries/test/test_session_recording_list_from_filters.py
@@ -3750,3 +3750,35 @@ def test_event_filter_with_group_filter(self):
         )
 
         self.assertEqual([sr["session_id"] for sr in session_recordings], [session_id])
+
+    @freeze_time("2021-01-21T20:00:00.000Z")
+    @snapshot_clickhouse_queries
+    def test_ordering(self):
+        session_id_one = f"test_ordering-{str(uuid4())}"
+        session_id_two = f"test_ordering-{str(uuid4())}"
+        session_id_three = f"test_ordering-{str(uuid4())}"
+
+        produce_replay_summary(
+            session_id=session_id_one,
+            team_id=self.team.id,
+            mouse_activity_count=50,
+            first_timestamp=(self.an_hour_ago + relativedelta(seconds=60)),
+        )
+        produce_replay_summary(
+            session_id=session_id_two,
+            team_id=self.team.id,
+            mouse_activity_count=100,
+            first_timestamp=(self.an_hour_ago),
+        )
+        produce_replay_summary(
+            session_id=session_id_three,
+            team_id=self.team.id,
+            mouse_activity_count=10,
+            first_timestamp=(self.an_hour_ago + relativedelta(minutes=10)),
+        )
+
+        (session_recordings, _, _) = self._filter_recordings_by({"order": "start_time"})
+        assert [r["session_id"] for r in session_recordings] == [session_id_three, session_id_one, session_id_two]
+
+        (session_recordings, _, _) = self._filter_recordings_by({"order": "mouse_activity_count"})
+        assert [r["session_id"] for r in session_recordings] == [session_id_two, session_id_one, session_id_three]


Code review comments:
diff_hunk: @@ -234,6 +234,25 @@ function combineLegacyRecordingFilters(
     }
 }
 
+function sortRecordings(recordings: SessionRecordingType[], order: RecordingsQuery['order']): SessionRecordingType[] {
+    const orderKey:
+        | 'recording_duration'
+        | 'active_seconds'
+        | 'inactive_seconds'
+        | 'console_error_count'
+        | 'click_count'
+        | 'keypress_count'
+        | 'mouse_activity_count'
+        | 'start_time' = order === 'duration' ? 'recording_duration' : order === 'random_sample' ? 'start_time' : order
path: frontend/src/scenes/session-recordings/playlist/sessionRecordingsPlaylistLogic.ts
text: @user1:
why is random sample mapped to start time here?

@author:
The idea behind the randomisation was to pick a stratified set the were chosen over the course of your timespan. It felt weird looking at it that the results were unordered... which sounds funny to say 😅 

Maybe the right thing to do is have the random sample be a separate toggle and thus you can still "order" its results

@user1:
I'm not sure if this is more confusing (i.e. i asked for a random sample but these feel in order) or without. I like the separate toggle idea! Anyway will leave upto you to decide ⭐ 

@author:
I implemented the toggle so let's see how that feels to folks!