Created
August 16, 2019 14:12
-
-
Save tfgrahame/8f05c653f57afd29d9e518a54b788d34 to your computer and use it in GitHub Desktop.
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 | |
s.service_id, COUNT(s.service_id) | |
FROM | |
service s | |
LEFT JOIN | |
(SELECT | |
s.service_id | |
FROM | |
service s | |
JOIN broadcast b ON s.service_id = b.service_id | |
WHERE | |
b.planned_start_time IS NOT NULL | |
AND DATE(b.created) > '2017-12-05' | |
AND YEAR(b.published_time) > '2017') AS planned ON s.service_id = planned.service_id | |
JOIN | |
entity e ON e.pid = s.pid | |
AND e.partner_pid = 's0000001' | |
WHERE | |
s.type = 'TV' | |
GROUP BY s.service_id | |
ORDER BY COUNT(s.service_id) DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment