Monday, May 07, 2012
SQL Group by
SELECT p.PROJ_NAME ,
max(distinct case when (MPCF.MD_PROP_NAME)='Partner' then (LTV.LT_VALUE_TEXT) end )PARTNER
,max(distinct case when ( MPCF.MD_PROP_NAME )='Región' then (LTV.LT_VALUE_TEXT) end) REGION
,max(distinct case when ( MPCF.MD_PROP_NAME)='Fase' then (LTV.LT_VALUE_TEXT) end )FASE
,max(distinct case when ( MPCF.MD_PROP_NAME)='Area' then (LTV.LT_VALUE_FULL) end ) AREA
,max(distinct case when ( MPCF.MD_PROP_NAME)='Responsable Implementación' then (LTV.LT_VALUE_FULL) end ) RESPONSABLE
,max(distinct case when ( MPCF.MD_PROP_NAME)='Responsable TISA' then (LTV.LT_VALUE_TEXT ) end ) RESPONSABLE_IMPLE
FROM MSP_PROJECTS P
INNER JOIN MSP_PROJ_CUSTOM_FIELD_VALUES PCFV ON (P.PROJ_UID = PCFV.PROJ_UID)
INNER JOIN MSP_CUSTOM_FIELDS MPCF ON PCFV.MD_PROP_UID=MPCF.MD_PROP_UID -- AND MPCF.MD_PROP_NAME='Partner'
INNER JOIN MSP_LOOKUP_TABLE_VALUES LTV ON PCFV.CODE_VALUE=LTV.LT_STRUCT_UID
where
MPCF.MD_PROP_NAME IN('Partner','Región','Fase','Area','Responsable Implementación','Responsable TISA')
Group by PROJ_NAME
order by PROJ_NAME
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment