beowulf1416

Untitled

Feb 6th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. SELECT c.id, c.title,
  2. 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,
  3. 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,
  4. b.country_id
  5. from report_2015_1 a
  6. inner join data_gateway b on a.gateway_id = b.id
  7. inner join data_group_country c on b.country_id = c.id
  8. 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