SELECT i00.*, 
       ifnull( (select i01_in.nr01
                from i01 as i01_in
                where i01_in.p01=i00.pno
                   && i01_in.p013>=cast('{odbcdtos(my_df)}' as date)
                   && i01_in.p013<=cast('{odbcdtos(my_dt)}' as date)
                limit 1), 0) as i01nr01   
FROM i00
WHERE {my_where}
HAVING i01nr01=0;

