Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select
- c.id,
- c.title rca,
- count(*) gateway_count
- from data_gateway b
- inner join data_group_rca c on b.rca_id = c.id
- where b.id in (
- select
- d.gateway_id
- from (
- select
- a.gateway_id,
- sum(a.total_minutes) sum_minutes
- from report_total_minutes_by_day a
- where a.report_date >= '2015-01-01'
- and a.report_date <= '2015-01-31'
- group by a.gateway_id
- ) d
- where d.sum_minutes > 1000
- )
- and b.is_deleted = 0
- and c.is_deleted = 0
- group by c.id
Advertisement
Add Comment
Please, Sign In to add comment