beowulf1416

Untitled

Feb 4th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. select
  2. c.id,
  3. c.title rca,
  4. count(*) gateway_count
  5. from data_gateway b
  6. inner join data_group_rca c on b.rca_id = c.id
  7. where b.id in (
  8. select
  9. d.gateway_id
  10. from (
  11. select
  12. a.gateway_id,
  13. sum(a.total_minutes) sum_minutes
  14. from report_total_minutes_by_day a
  15. where a.report_date >= '2015-01-01'
  16. and a.report_date <= '2015-01-31'
  17. group by a.gateway_id
  18. ) d
  19. where d.sum_minutes > 1000
  20. )
  21. and b.is_deleted = 0
  22. and c.is_deleted = 0
  23. group by c.id
Advertisement
Add Comment
Please, Sign In to add comment