CREATE OR ALTER VIEW pricing.arcstx AS
SELECT
    v6part PART,
    v6plnt plnt,
    v6stat stat,
    v6rpln rpln,
    v6unti unit,
    COALESCE(cnsdat, cosdat, y3sdat) sdate,
    COALESCE(cnstcs,costcs, y3stcs) std,
    COALESCE(cnmats,costcs,y3smat + y3soc + y3sshc) mat,
    COALESCE(cnlabs,y3slab,0) lab,
    COALESCE(cnbrvs,y3svbr,0) var,
    COALESCE(cnbrfs,y3sfbr,0) fix,
    COALESCE(cnstoc,y3sotc,0) oth
FROM
    CMSInterfaceIN.lgdat.stka
    LEFT OUTER JOIN CMSInterfaceIN.ARCHIVE.ftcstm_2510 ftcstm ON
        cnpart = v6part
        AND cnplnt = v6plnt
    LEFT OUTER JOIN CMSInterfaceIN.ARCHIVE.ftcstp_2510 ftcstp ON
        copart = v6part
        AND coplnt = v6plnt
    LEFT OUTER JOIN CMSInterfaceIN.ARCHIVE.ftcstr_2510 ftcstr ON
        y3part = v6part
        AND y3plnt = v6plnt
WHERE
    v6plnt IN ('152','154','155','112','113');

