1/27/2015

CI Classification - Export to XLS

CI classification with attributes names: Link to XLS file

SQL Query script:
select
main.classificationid CIROOT, main.classstructureid CI_ID,
chold1.classificationid CH1, chold1.classstructureid CH1_ID,
chold2.classificationid CH2, chold2.classstructureid CH2_ID,
chold3.classificationid CH3, chold3.classstructureid CH3_ID,
chold4.classificationid CH4, chold4.classstructureid CH4_ID,
CASE WHEN chold4.classstructureid is not NULL THEN chold4.classstructureid
ELSE CASE WHEN chold3.classstructureid is not NULL THEN chold3.classstructureid
ELSE CASE WHEN chold2.classstructureid is not NULL THEN chold2.classstructureid
ELSE CASE WHEN chold1.classstructureid is not NULL THEN chold1.classstructureid END END END
END CHECK_ID,
specification.assetattrid SPEC_ATTR
from classstructure main
left join classstructure chold1 on chold1.parent = main.classstructureid
left join classstructure chold2 on chold2.parent = chold1.classstructureid
left join classstructure chold3 on chold3.parent = chold2.classstructureid
left join classstructure chold4 on chold4.parent = chold3.classstructureid
left join classspec specification on specification.classstructureid = (CASE WHEN chold4.classstructureid is not NULL THEN chold4.classstructureid
ELSE CASE WHEN chold3.classstructureid is not NULL THEN chold3.classstructureid
ELSE CASE WHEN chold2.classstructureid is not NULL THEN chold2.classstructureid
ELSE CASE WHEN chold1.classstructureid is not NULL THEN chold1.classstructureid END END END
END)
where main.classificationid = 'CIROOT'
order by CIROOT, CH1, CH2, CH3, CH4, SPEC_ATTR

For update data from your database you need to update your connection settings:

No comments:

Post a Comment