-2
select (1- (s1 + s2 + s3) / (s4 + s5 + s6))*100,startdate
from (
  select sum(v1) as s1 ,sum(v2) as s2,sum(v3) as s3,sum(v4) as s4,sum(v5) as s5,sum(v6) as s6,startdate 
    from (
      select 
        avg(case when indicateur like '%Vmgw%' and compteur = 'pmNrOfAal2TermsRej' then valeur else null end) as v1,
        avg(case when indicateur like '%Vmgw%' and compteur = 'pmNrOfIpTermsRej' then valeur else null end) as v2,
        avg(case when indicateur like '%TdmTermGrp%' and compteur = 'pmNrOfTdmTermsRej' then valeur else null end) as v3,
        avg(case when indicateur like '%Vmgw%' and compteur = 'pmNrOfAal2TermsReq' then valeur else null end) as v4,
        avg(case when indicateur like '%Vmgw%' and compteur = 'pmNrOfIpTermsReq' then valeur else null end) as v5,
        avg(case when indicateur like '%TdmTermGrp%' and compteur = 'pmNrOfTdmTermsReq' then valeur else null end) as v6,
        startdate
      from MGW1 
      group by startdate
    )
    group by startdate
  )
4

2 回答 2

1

尝试这个

select (1- (s1 + s2 + s3) / (s4 + s5 + s6))*100,startdate
from
(   select sum(v1) as s1 ,sum(v2) as s2,sum(v3) as s3,sum(v4) as s4,sum(v5) as s5,sum(v6) as s6,startdate 
    from
    (   select avg(case when indicateur like '%Vmgw%' and compteur = 'pmNrOfAal2TermsRej' then valeur else null end) as v1,
        avg(case when indicateur like '%Vmgw%' and compteur = 'pmNrOfIpTermsRej' then valeur else null end) as v2,
        avg(case when indicateur like '%TdmTermGrp%' and compteur = 'pmNrOfTdmTermsRej' then valeur else null end) as v3,
        avg(case when indicateur like '%Vmgw%' and compteur = 'pmNrOfAal2TermsReq' then valeur else null end) as v4,
        avg(case when indicateur like '%Vmgw%' and compteur = 'pmNrOfIpTermsReq' then valeur else null end) as v5,
        avg(case when indicateur like '%TdmTermGrp%' and compteur = 'pmNrOfTdmTermsReq' then valeur else null end) as v6,
        startdate
        from MGW1
        group by startdate
    ) xDerived1 --  NEED AN ALIAS HERE
    group by startdate
) xDerived2 --  NEED AN ALIAS HERE

请注意我偷偷加入的两个派生表名 (xDerived1xDerived2)。它通过了错误代码 1248

于 2015-12-28T22:04:02.690 回答
0

我在第 11 行有语法错误:

select (1- (s1 + s2 + s3) / (s4 + s5 + s6))*100 as succ_rate,startdate as Time from ( select sum(v1) as s1 ,sum(v2) as s2,sum(v3) as s3,sum(v4) as s4,sum(v5) as s5,sum(v6) as s6,startdate from ( select avg(当指示符像 '%Vmgw%' 和 compteur = 'pmNrOfAal2TermsRej' 然后 valeur else null end)作为 v1,avg(当指示符像 '%Vmgw%' 和 compteur = 'pmNrOfIpTermsRej' 然后 valeur else null end)作为 v2,avg(当指示符像 '%TdmTermGrp%' 和 compteur = 'pmNrOfTdmTermsRej' 然后 valeur else null end) 作为 v3, avg(当指示符像 '%Vmgw%' 和 compteur = 'pmNrOfAal2TermsReq' 然后 valeur else null end) 作为 v4, avg(指示符像 '%Vmgw%' 和 compteur = 'pmNrOfIpTermsReq' 然后 valeur 的情况else null end) 作为 v5,avg(当指示符像 '%TdmTermGrp%' 和 compteur = 'pmNrOfTdmTermsReq' 然后 valeur else null end)作为 v6,从 SUBSTR(date_format(startdate,'AAAA-%m-JJ HH:%m:%s 的数据开始日期'),1,10) 像 $P{date_debut} 和 MGW 像 $P{par_mgw} 按 startdate 分组,MGW)

于 2015-12-31T22:39:39.237 回答