select da8.nr01 as nr01,
       da8.p02  as p02,
       da8.p03  as p03,
       da8.p04  as p04,
       da8.p05  as p05,
       da5.p01  as da5p01,
       da5.p02  as da5p02,
       da5.p03  as da5p03,
       da5.p04  as da5p04,
       da5.p05  as da5p05,
       da5.p06  as da5p06,
       da5.p07  as da5p07,
       da5.p09  as da5p09,
       da5.p010 as da5p010,
       da5.p011 as da5p011,
       da5.p30  as da5p30,
       da8.p03  as vp03,
       da6.p02 as da6p02, 
       da7.p03  as da7p03, 
       
       ifnull(da8001.nr01, 0) as da8_nr01, 
       ifnull(da8001.p02, '')  as da8_p02, 
       ifnull(da8001.p03, '')  as da8_p03 
FROM da8
LEFT JOIN da5 ON da5.nr01=da8.p02
LEFT JOIN da7 ON da7.nr01=da8.p04
LEFT JOIN da6 ON da6.nr01=da5.p07
LEFT JOIN da8001 ON da8001.p01=da8.nr01
WHERE da8.p01='{nnr01}';
