-------------------------------------------------------------------------------

-- Part 4: Re-order the notes in the same order that they were in,

--         in the original set of records, using the RRN

--         of the previous work table

-------------------------------------------------------------------------------

 

 SELECT

          V01.MATERIAL_NUMBER                               ,

          V01.TEXT_SECTION                                  ,

          V01.NOTES                                         ,

          V01.LANGUAGE                                      ,

          V01.PLANT_01                                      ,

          V01.PLANT_02                                      ,

          V01.PLANT_03                                      ,

          V01.PLANT_04                                      ,

          V01.PLANT_05                                      ,

          V01.PLANT_06                                      ,

          V01.PLANT_07                                      ,

          V01.PLANT_08                                      ,

          V01.PLANT_09                                      ,

          V01.PLANT_10                                      ,

          V01.PLANT_11                                      ,

          V01.PLANT_12                                      ,

          V01.PLANT_13                                      ,

          V01.PLANT_14                                      ,

          V01.PLANT_15                                      ,

          V01.PLANT_16                                      ,

              MIN(RRN(V02))        RELATIVE_RECORD_NUMBER

 FROM EACPMM34DX V01

 INNER JOIN EACPMM32DX V02

 ON  V01.MATERIAL_NUMBER = V02.MATERIAL_NUMBER

 AND V01.NOTES           = V02.NOTES

 

 GROUP BY

          V01.MATERIAL_NUMBER                               ,

          V01.TEXT_SECTION                                  ,

          V01.NOTES                                         ,

          V01.LANGUAGE                                      ,

          V01.PLANT_01                                      ,

          V01.PLANT_02                                      ,

          V01.PLANT_03                                      ,

          V01.PLANT_04                                      ,

          V01.PLANT_05                                      ,

          V01.PLANT_06                                      ,

          V01.PLANT_07                                      ,

          V01.PLANT_08                                      ,

          V01.PLANT_09                                      ,

          V01.PLANT_10                                      ,

          V01.PLANT_11                                      ,

          V01.PLANT_12                                      ,

          V01.PLANT_13                                      ,

          V01.PLANT_14                                      ,

          V01.PLANT_15                                      ,

          V01.PLANT_16

 

order by MATERIAL_NUMBER, RELATIVE_RECORD_NUMBER