如何划分两个查询

时间:2018-05-03 06:52:20

标签: sql influxdb

我想将以下两个查询分开:

第一次查询:

i

第二次查询:

select count_value from (select count(*) 
from jmeter 
where "project" = 'testmatrix' 
AND "suite" = 'apitest' 
AND "build"='132' 
AND "status" = 'ok' 
AND "page" != 'all' 
AND "metric" = 'count' 
AND "value"=0)

感谢您的帮助。

2 个答案:

答案 0 :(得分:1)

SELECT SUM(CASE WHEN "Value"  = 0 THEN 1 ELSE 0 END)/COUNT(*) 
from jmeter 
where "project" = 'testmatrix' 
AND "suite" = 'apitest' 
AND "build"='132' 
AND "status" = 'ok' 
AND "page" != 'all' 
AND "metric" = 'count'

答案 1 :(得分:0)

这会有所帮助。

select sum(f_query)/ sum(S_query) as Result 
from (
    select  count(*) as f_query , 0 as S_query from jmeter where "project" = 'testmatrix' AND "suite" = 'apitest' AND "build"='132' AND "status" = 'ok' AND "page" != 'all' AND "metric" = 'count' AND "value"=0
    union all
    select 0 as f_query , count(*) as S_query  from jmeter where "project" = 'testmatrix' AND "suite" = 'apitest' AND "build"='132' AND "status" = 'ok' AND "page" != 'all' AND "metric" = 'count'
) as GroupTable