select e.time, sum(t.tx), sum(ch.rx) ,sum(c.ec)
from ("Event" as e
left join "TXPC" as t on e.oid=t.the_event
left join "Channel+" as ch on e.oid=ch.the_event
left join "Cell+" as c on e.oid=c.the_event and c.number=276)
group by e.time
having sum(t.tx) is not null or sum(ch.rx) is not null or sum(c.ec) is not null
以上一段程序得出的结果如下:
time sum(t.tx) sum(ch.rx) sum(c.ec)
20:17 -9 -8 null
20:18 -10 null -20
20:19 14 20 19
20:20 null null 0
....要求:得出一个值:当(sum(t.tx)<20 或为空值 and sum(ch.rx)>-95 and sum(c.ec)>-15)的行数除以总行数以原来语句上面加要怎么写呢?谢谢大家了
from ("Event" as e
left join "TXPC" as t on e.oid=t.the_event
left join "Channel+" as ch on e.oid=ch.the_event
left join "Cell+" as c on e.oid=c.the_event and c.number=276)
group by e.time
having sum(t.tx) is not null or sum(ch.rx) is not null or sum(c.ec) is not null
以上一段程序得出的结果如下:
time sum(t.tx) sum(ch.rx) sum(c.ec)
20:17 -9 -8 null
20:18 -10 null -20
20:19 14 20 19
20:20 null null 0
....要求:得出一个值:当(sum(t.tx)<20 或为空值 and sum(ch.rx)>-95 and sum(c.ec)>-15)的行数除以总行数以原来语句上面加要怎么写呢?谢谢大家了
case when (a<20 or a is null) and b>-95 and c>-15 then 1 else 0 end*1.0/count(*) as 结果
from (
select e.time, sum(t.tx) as a, sum(ch.rx) as b,sum(c.ec) as c
from ("Event" as e
left join "TXPC" as t on e.oid=t.the_event
left join "Channel+" as ch on e.oid=ch.the_event
left join "Cell+" as c on e.oid=c.the_event and c.number=276)
group by e.time
having sum(t.tx) is not null or sum(ch.rx) is not null or sum(c.ec) is not null
) as t