SELECT
     i00.pno  as v101,
     i00.fpa  as v108_a,
     ifnull(a27.p3, i00.fpa)   as v108,
/*     if(i99001.p03 IS NULL,
            if(i13.p03 IS NULL, 0, i13.p03),
            i99001.p03) as v105*/
     ifnull(i99001.p03, 
            ifnull(i13.p03, 
                 ifnull(i13_fpa.p03, 0) ) ) as v105        
            

FROM i00
LEFT JOIN a27 ON i00.fpa=a27.p2 && a27.p1='{par_pararr[2]}'
LEFT JOIN i13 ON i13.p01=a27.p3
LEFT JOIN i13 as i13_fpa ON i13_fpa.p01=i00.fpa
LEFT JOIN i99001 ON i99001.p01=i13.p01
                 && i99001.p101<='{odbcdtos(par_pararr[3])}'
                 && i99001.p102>='{odbcdtos(par_pararr[3])}'
WHERE pno='{par_pararr[1]}'
GROUP BY pno;