Hello,
Have you tried pivot transform with ifthenelse condition? Create three output fields and first one would be the default value, second one use ifthenelse(MTART='B','ZZ', NULL), third one ifthenesle(MTART='B','YY', NULL). In the next query use a where condition carrying only non-null values.
Hope helpful.
Arun