SELECT
   t1.snr01 as snr01,
   t1.nr01 as nr01,
   t1.p01 as p01,
   t1.vp01 as vp01,
   t1.p02 as p02,
   t1.sp02 as sp02,
   t1.p02-t1.sp02 as yp02
FROM
(
select
    i00.name as vp01,
    cona13.p00 as snr01,
    cona13.nr01 as nr01,
    cona13.p01  as p01,
    cona13.p02  as p02,
   sum(if( d38.p02 is null, 0, d38.p02)) as sp02
from cona13
LEFT JOIN d38 ON d38.p04=cona13.nr01
LEFT JOIN i00 ON i00.pno=cona13.p01
where cona13.p00='{np303}'
  && locate( concat('#', i00.p62, '#'), '{p_d99p103}')=0
GROUP BY cona13.nr01

) as t1
WHERE t1.p02>t1.sp02
order by t1.p01;

