Last active
August 29, 2015 14:27
-
-
Save rherrick/443fcaa0003fdf659401 to your computer and use it in GitHub Desktop.
SQL for getting event count
This file contains 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 event_id, event_label, total | |
FROM (SELECT DISTINCT | |
CASE pipeline_name | |
WHEN 'Transfer'::text | |
THEN 'Archive'::text | |
ELSE | |
CASE xs_lastposition('/'::text, pipeline_name::text) | |
WHEN 0 | |
THEN pipeline_name | |
ELSE substring(substring(pipeline_name::text, xs_lastposition('/'::text, pipeline_name::text) + 1), 1, xs_lastposition('.'::text, substring(pipeline_name::text, xs_lastposition('/'::text, pipeline_name::text) + 1)) - 1) | |
END | |
END AS event_label, | |
pipeline_name AS event_id, | |
count(*) AS total | |
FROM (SELECT * | |
FROM wrk_workflowData | |
WHERE externalid !='ADMIN' AND | |
externalid !='' AND | |
externalid IS NOT NULL AND | |
launch_time > now() - '1 year'::interval) AS current | |
GROUP BY event_id, event_label) AS events | |
WHERE total > 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment