3
下記のクエリをより速くする必要があります。私はいくつかの選択を使用し、私のアプリケーションを非常に遅くする。 修正してください。以下のSQLコードでSQLクエリを高速化するにはどうすればよいですか?
select
Branch,
(select count(*) from TCB T1 where Standard like "%FCC%" and T0.Branch=T1.Branch) as FCC,
(select count(*) from TCB T2 where (Standard like "%ISEDC%" or Standard like "%RSS%") and T0.Branch=T2.Branch) as ISEDC,
(select count(*) from TCB T3 where (Standard like "%RED%" or Standard like "%EN%") and T0.Branch=T3.Branch) as RED,
(select count(*) from TCB T4 where Standard like "%MIC%" and T0.Branch=T4.Branch) as MICJapan,
(select count(*) from TCB T5 where Standard like "%IMDA%" and T0.Branch=T5.Branch) as IMDA,
(select count(*) from TCB T6 where Standard like "%ACTA%" and T0.Branch=T6.Branch) as ACTA,
(select count(*) from TCB T7 where Standard like "%CS03%" and T0.Branch=T7.Branch) as CS03,
((select count(*) from TCB T1 where Standard like "%FCC%" and T0.Branch=T1.Branch)+
(select count(*) from TCB T2 where (Standard like "%ISEDC%" or Standard like "%RSS%") and T0.Branch=T2.Branch)+
(select count(*) from TCB T3 where (Standard like "%RED%" or Standard like "%EN%") and T0.Branch=T3.Branch)+
(select count(*) from TCB T4 where Standard like "%MIC%" and T0.Branch=T4.Branch)+
(select count(*) from TCB T5 where Standard like "%IMDA%" and T0.Branch=T5.Branch)+
(select count(*) from TCB T6 where Standard like "%ACTA%" and T0.Branch=T6.Branch)+
(select count(*) from TCB T7 where Standard like "%CS03%" and T0.Branch=T7.Branch)
) as Total
from
TCB T0
group by Branch
結果:(結果が正しいですが、それは遅すぎる)
それは動作しますが、あなたにゴードン・リノフありがとうございます。あなたの時間を本当に感謝します。 – kiarash