Sunday, August 4, 2013

Please help with the below SQL to get the counts: as counts in groups of 4. It is giving error of "expression containing an aggregate or a subquery". How can I get the counts?

SELECT


CASE WHEN c. PRTNR_TYPE_CD is NULL THEN


( Case when c. par_ou_id is not null then 'SUBSIDIARY' ELSE


Case when C. row_id in (


select distinct par_ou_id


from


COMMON. dbo. W_SBL_S_ORG_EXT


where


par_ou_id is not null


)


then 'PARENT' ELSE


'SELF-PARENTED' END END )


ELSE NULL


END , COUNT ( 1)



No comments:

Post a Comment