SELECT * 
FROM
( 
SELECT p01 as p01,
       p02 as p02, 
       p03 as p03, 
       p04 as p04
from p20
where p01='{my_table}'
   && p02='{my_fld}'
   && p11=0

UNION ALL

SELECT p03 as p01,
       p04 as p02, 
       p01 as p03, 
       p02 as p04
from p20
where p03='{my_table}'
   && p04='{my_fld}'
   && p11=0
) as tbl01
WHERE p03 NOT IN ('i00tot', 't00tot', 'i47tot')   
GROUP BY p01, p02, p03, p04;
