Last active
February 12, 2022 12:39
-
-
Save Mr--John-Doe/121d7b8df87c28138af6c3a0e22ef653 to your computer and use it in GitHub Desktop.
Tuning - slow query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT DISTINCT username | |
, account_id | |
, FIRST_VALUE(session_id) OVER (PARTITION BY account_id ORDER BY login_ts) AS session_id | |
, FIRST_VALUE(ip_address) OVER (PARTITION BY account_id ORDER BY login_ts) AS ip_address | |
, FIRST_VALUE(country_id) OVER (PARTITION BY account_id ORDER BY login_ts) AS country_id | |
, FIRST_VALUE(website_entry_point) OVER (PARTITION BY account_id ORDER BY login_ts) AS website_entry_point | |
, FIRST_VALUE(payment_platform) OVER (PARTITION BY account_id ORDER BY login_ts) AS payment_platform | |
, FIRST_VALUE(platform_type) OVER (PARTITION BY account_id ORDER BY login_ts) AS platform_type | |
, FIRST_VALUE(session_duration_s) OVER (PARTITION BY account_id ORDER BY login_ts) AS session_duration_s | |
, FIRST_VALUE(number_sold_items) OVER (PARTITION BY account_id ORDER BY login_ts) AS number_sold_items | |
, FIRST_VALUE(sales_gbp) OVER (PARTITION BY account_id ORDER BY login_ts) AS sales_gbp | |
FROM SALES.SALES_SESSION_AGGREGATION | |
WHERE is_meaningful_visit = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment