-------------------------------------------------------------------------------
-- Part 3: Flatten the staircase table resulting from Part 1
-- Use the "max of" technique to squeeze out the blanks and get only
-- the actual values for each business unit
-------------------------------------------------------------------------------
SELECT
MATERIAL_NUMBER ,
'OU Specific ' TEXT_SECTION ,
NOTES ,
LANGUAGE ,
MAX( BU00001 ) PLANT_01 ,
MAX( BU00002 ) PLANT_02 ,
MAX( BU00003 ) PLANT_03 ,
MAX( BU00004 ) PLANT_04 ,
MAX( BU00005 ) PLANT_05 ,
MAX( BU00006 ) PLANT_06 ,
MAX( BU00007 ) PLANT_07 ,
MAX( BU00008 ) PLANT_08 ,
MAX( BU00009 ) PLANT_09 ,
MAX( BU00010 ) PLANT_10 ,
MAX( BU00011 ) PLANT_11 ,
MAX( BU00012 ) PLANT_12 ,
MAX( BU00013 ) PLANT_13 ,
MAX( BU00014 ) PLANT_14 ,
MAX( BU00015 ) PLANT_15 ,
MAX( BU00016 ) PLANT_16
FROM EACPMM33DX V01
GROUP BY
MATERIAL_NUMBER ,
NOTES ,
LANGUAGE
ORDER BY MATERIAL_NUMBER, NOTES