Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set @curr = 0;
- set @val = 0;
- select
- b.title gateway,
- b.ani,
- b.did,
- b.total_minutes
- from (
- select
- *,
- @curr := if(@val = a.id, @curr + 1, 1) rank,
- @val := a.id
- from (
- select
- dg.id,
- dg.title,
- vl.ani,
- vl.did,
- round(sum(vl.seconds)/60) total_minutes
- from zenoreport.v2v25log vl
- inner join `zenoradio-v25`.data_gateway dg on vl.gateway_id = dg.id
- where vl.gateway_id in (87,219,221,223,238,265,310)
- and length(vl.ani) = 11
- and vl.date_start >= '2015-11-29'
- and vl.date_start < '2016-01-28'
- group by vl.gateway_id, vl.ani
- having total_minutes > 9
- order by dg.id, total_minutes desc
- ) a
- ) b
- where b.rank < 201
Advertisement
Add Comment
Please, Sign In to add comment