SELECT * 
FROM 

(
SELECT
     1 as type, 
     q12.p01 as p01, 
     q12.p02 as p02, 
     q12.p03 as p03, 
     q12.p05 as p05, 
     q12.p06 as p06, 
     q12.p07 as p07, 
     q12.p08 as p08
FROM q12 
WHERE p00='{np03}' 

UNION 

SELECT
     2 as type,
     concat('% ', q12.p01) as p01, 
     q12.p02 as p02, 
     concat('p_', nr01) as p03, 
     q12.p05 as p05, 
     "N" as p06, 
     14 as p07, 
     3  as p08
FROM q12 
WHERE p00='{np03}' 
   && p020='1'

) as t1
ORDER BY t1.p05, t1.type
   ;
