CREATE OR REPLACE FORCE VIEW ULD_MANIFEST_REPORTS_V ( FLIGHT_NO,
FLIGHT_ID, FLIGHT_DATE, ULD_NO, BAG,
BAG_1, BAG_2A, BAG_2B, BAG_3
 ) AS SELECT    
          b.flight_no,
          b.flight_id,
          b.flight_date,
          b.uld_no,
          CONCAT(RTRIM(nvl(b.bag_tag2a,b.bag_tag2b)), LPAD(TO_CHAR(b.bag_tag3),6,0)) BAG,
          b.BAG_TAG1 BAG_1,
          b.BAG_TAG2A BAG_2A,
          b.BAG_TAG2B BAG_2B,
          b.BAG_TAG3A BAG_3
FROM      bag_v2 b, ulds u
   WHERE  b.uld_no is not null
   AND	  b.uld_no = u.uld_no
   AND	  b.flight_id = u.flight_id
ORDER BY  flight_no,
          flight_id,
          flight_date,
          DECODE(SUBSTR(uld_no,2,4), 'BULK', 1,0),
          uld_no,
          BAG_TAG
/

