Created
July 23, 2015 17:40
-
-
Save bstancil/554c0f5de49d046ce70b to your computer and use it in GitHub Desktop.
snippets.sql
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
SIMPLE VERSION | |
## Snippet | |
SELECT rr.id, | |
rr.created_at, | |
rr.report_id, | |
rr.account_id, | |
rr.executed_by_id, | |
rr.data_source_id, | |
rr.state, | |
MAX(CASE WHEN rs.id IS NOT NULL OR lsr.id IS NOT NULL THEN 1 ELSE 0 END) AS scheduled_run | |
FROM report_runs rr | |
LEFT JOIN report_schedule_runs rs | |
ON rs.report_run_id = rr.id | |
LEFT JOIN list_run_report_runs lrrr | |
ON lrrr.report_run_id = rr.id | |
LEFT JOIN list_schedule_runs lsr | |
ON lsr.list_run_id = lrrr.list_run_id | |
GROUP BY 1,2,3,4,5,6,7 | |
## Query | |
SELECT * | |
FROM ({{run_detail}}) a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment