This file contains hidden or 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 *, | |
| CASE WHEN | |
| "time_difference" >= INTERVAL '30 days' THEN 1 ELSE 0 END AS "flag_macro_session_limits" | |
| FROM( | |
| SELECT *, | |
| LAG("timestamp",1) OVER ( | |
| PARTITION BY "user_id" | |
| ORDER BY "timestamp" DESC | |
| ) | |
| - "timestamp" as "time_difference" |
This file contains hidden or 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 "user_id", | |
| "user_id" || SUM("flag_macro_session_limits") OVER ( | |
| PARTITION BY "user_id" | |
| ORDER BY "timestamp" ASC | |
| ) | |
| - "flag_macro_session_limits" AS "user_macro_session", | |
| "channel", | |
| "timestamp" | |
| FROM( | |
| SELECT *, |
This file contains hidden or 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
| def subsets(s): | |
| ''' | |
| This function returns all the possible subsets of a set of channels. | |
| input : | |
| - s: a set of channels. | |
| ''' | |
| if len(s)==1: | |
| return s | |
| else: | |
| sub_channels=[] |
OlderNewer