None
NO
Instead Of MAX Use LAST_VALUE For Time-Based Data
['Den Delimarsky']
Hi, I'm Den 👋 on Den Delimarsky
If you’d be tracking Twitter followers for an account the same way, you probably don’t care about the maximum number of followers your account got in a day, but rather what you ended up with at the end of the day. SELECT * FROM ( SELECT last_value ( follower_count ) OVER ( PARTITION BY target_date ) followers , last_value ( following_count ) OVER ( PARTITION BY target_date ) following , target_date FROM ( SELECT strftime ( '%Y-%m-%d' , time_of_capture ) target_date , following_count , follower_count FROM ( SELECT * FROM user_snapshots WHERE user_id = 'foo_bar' ORDER BY time_of_capture )) ) GROUP BY target_date , followers , following What this means is that if you look at our table above, the LAST_VALUE , assuming that we partitioned the table by the simplified date and ordered by time,…