select
    i00.p00 as p00,
    i00.pno as pno
FROM i00
LEFT JOIN i01 ON i01.p01=i00.pno
              && i01.p013>=cast( '{odbcdtos(ns_dat1)}' as date)
              && i01.p013<=cast( '{odbcdtos(ns_dat2)}' as date)
              && i01.p014='{ns_log}'
WHERE ( {epi_cond} )
   && i01.nr01 is not null
GROUP BY i00.pno