drop table CITM.PROD_SEG_MQT;
--==============================================================
-- View: PROD_SEG_MQT
--==============================================================
create table CITM.PROD_SEG_MQT as
( SELECT HW_REL.SECOSINSTID, HW_REL.HOST, HW_REL.DOMAINNAME, HW_REL.HOST|| '.' || HW_REL.DOMAINNAME as FQDN,
HW_REL.IP_ADDR, HW_REL.HWTYPE, HW_REL.HWSERIAL, HW_REL.SITE, ITSASREP.LOCATION, ITSASREP.OS,
ITSASREP.PR_INTRANETADDRESS, DEVCONTACT.DEV_IIP, HW_REL.SEGMENT_ID,
SEG.SEGMENT_NAME, HW_REL.PRODUCT_ID, PROD.PRODUCT_NAME, ITM.POINTS,
CASE when ITM.COHORT_CODE = 'Red' then FCT.COHORT_CODE_TITLE
when ITM.COHORT_CODE = 'Yellow' then FCT.COHORT_CODE_TITLE
when ITM.COHORT_CODE = 'Green' then FCT.COHORT_CODE_TITLE else 'Unknown' END AS RYGSTATE,
CASE WHEN NOINST.HW_REL IS NULL THEN 'NOT EXEMPT' ELSE 'EXEMPT' END as ITMEXEMPTFLAG
FROM CITM.HW_REL as HW_REL
LEFT JOIN CITM.ITSASREP as ITSASREP on HW_REL.SECOSINSTID=ITSASREP.SECOSINSTID
LEFT JOIN CITM.ITM_UTIL as ITM on ITM.SECOSINSTID=ITSASREP.SECOSINSTID
LEFT JOIN CITM.FEDDB_CODE_TITLES as FCT on FCT.COHORT_CODE=ITM.COHORT_CODE
LEFT JOIN CITM.CITM_DEV_CONTACT as DEVCONTACT on ITSASREP.SECOSINSTID=DEVCONTACT.SECOSINSTID
LEFT JOIN CITM.SEGMENT as SEG on HW_REL.SEGMENT_ID=SEG.SEGMENT_ID
LEFT JOIN CITM.PRODUCT as PROD on PROD.PRODUCT_ID=HW_REL.PRODUCT_ID
LEFT OUTER JOIN CITM.ITM_NOINST as NOINST on HW_REL.HWREL_ID=NOINST.HW_REL
WHERE LOWER(HW_REL.STATUS) = 'active' AND DEVCONTACT.DEV_IIP IS NOT NULL
)
data initially deferred refresh deferred;