Last active
January 23, 2020 14:34
-
-
Save anonrig/3d1363ffc7b591989f7c9c2a954d9606 to your computer and use it in GitHub Desktop.
subscription
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 | |
| "SubscriberID", | |
| "StandardSubscriptionDuration" as "SubscriptionDuration", | |
| MIN("EventDate") as "FirstTransaction", | |
| MAX("EventDate") as "LastTransaction", | |
| "ApplicationId", | |
| CASE | |
| WHEN MAX("EventDate") BETWEEN LOCALTIMESTAMP - ("StandardSubscriptionDuration")::interval AND LOCALTIMESTAMP THEN true ELSE false | |
| END AS "isActive" | |
| FROM "Subscriptions" | |
| INNER JOIN "Applications" | |
| ON "Applications"."id" = "Subscriptions"."ApplicationId" | |
| GROUP BY "SubscriberID", "StandardSubscriptionDuration", "ApplicationId" | |
| ORDER BY "LastTransaction" DESC | |
| OFFSET 0 | |
| LIMIT 50; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment