1 DROP VIEW IF EXISTS current_subscription;
3 CREATE VIEW current_subscription AS SELECT device_id, podcast_id, c.user_ptr_id AS user_id, a.timestamp as subscribed_since, sum(a.action) as summe
4 FROM (subscription_log a JOIN device b on a.device_id=b.id)
5 JOIN user c on b.user_id=c.user_ptr_id
6 GROUP BY a.podcast_id, device_id