Good day to all, please help optimize the query:
select N,Nz ,Round(hz, 2) as Thick ,Round(pf, 3) as Weight ,tz,ts ,Round((select avg(NV1L) from tab2 where DT between tab1.tz and tab1.ts), 3) as AVG1L ,Round((select avg(NV1R) from tab2 where DT between tab1.tz and tab1.ts), 3) as AVG1R ,Round((select avg(NV2L) from tab2 where DT between tab1.tz and tab1.ts), 3) as AVG2L ,Round((select avg(NV2R) from tab2 where DT between tab1.tz and tab1.ts), 3) as AVG2R ,Round((select avg(NV3L) from tab2 where DT between tab1.tz and tab1.ts), 3) as AVG3L ,Round((select avg(NV3R) from tab2 where DT between tab1.tz and tab1.ts), 3) as AVG3R ,Round((select avg(NV4L) from tab2 where DT between tab1.tz and tab1.ts), 3) as AVG4L ,Round((select avg(NV4R) from tab2 where DT between tab1.tz and tab1.ts), 3) as AVG4R from tab1 where ts between :DateFrom and :DateTo order by ts This request is about 20 seconds, there are about 700 data. Thanks for the help.