Snippets

encapsia retrieve activities group by month

Created by Petre Mierlutiu
SELECT
    (
        SELECT zone FROM operational.assertions WHERE id=1
    ) AS trial
    , "how" as browser
    , "who" as user
    , DATE_TRUNC('month', "when") as period
    , (
        SELECT string_agg(cs.c, '::') FROM
        (
            SELECT jsonb_array_elements_text(capabilities)
            FROM operational.users u
            LEFT JOIN operational.roles r ON u.role = r.name
            WHERE u.email = "who"
        ) AS cs(c)
       ) AS capabilities
    , count(1) as frequency
    FROM operational.activities a
    WHERE "what" = 'Known user identified'
    GROUP BY "how", "who", DATE_TRUNC('month', "when")

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.