Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT c.id, c.title,
- sum(case when a.report_date >= '2015-01-25' and a.report_date <= '2015-01-31' then a.total_minutes else 0 end) last_week,
- sum(case when a.report_date >= '2015-02-01' and a.report_date <= '2015-02-07' then a.total_minutes else 0 end) current_week,
- b.country_id
- from report_2015_1 a
- inner join data_gateway b on a.gateway_id = b.id
- inner join data_group_country c on b.country_id = c.id
- WHERE a.report_date >= '2015-01-25' and a.report_date <= '2015-02-07' group by c.id
Advertisement
Add Comment
Please, Sign In to add comment