UNION ALL

05/05/2011

SELECT   
        {GENERIC_CONTENT}.[Title] AS OPINION,     

     COUNT({TRACKING}.[ContentId]) AS NOPINION,
   'GENERIC_CONTENT'
FROM         
     {TRACKING} 
     LEFT OUTER JOIN
                      {GENERIC_CONTENT} 
    ON {TRACKING}.[ContentId]= {GENERIC_CONTENT}.[Id]
WHERE 
         {TRACKING}.[ContentId] = {GENERIC_CONTENT}.[Id]
AND {GENERIC_CONTENT}.[ContentType] = 6

GROUP BY 
         {GENERIC_CONTENT}.[Title]

UNION ALL

SELECT
         {GENERIC_CONTENT}.[Title] AS SUCCESS_STORY, 
         COUNT({TRACKING}.[ContentId]) AS NStories,
         'GENERIC_CONTENT'
FROM  
        {TRACKING} 
                    LEFT OUTER JOIN
                      {GENERIC_CONTENT}
          ON {TRACKING}.[ContentId] = {GENERIC_CONTENT}.[Id]

WHERE 
        {TRACKING}.[ContentId] = {GENERIC_CONTENT}.[Id]
AND {GENERIC_CONTENT}.[ContentType] = 7
GROUP BY 
    {GENERIC_CONTENT}.[Title]


UNION ALL

SELECT
       {GENERIC_CONTENT}.[Title] AS EDITORIAL, 
        COUNT({TRACKING}.[ContentId]) AS NEditorial,
        'GENERIC_CONTENT' 

FROM
        {TRACKING} 
            LEFT OUTER JOIN
                 {GENERIC_CONTENT}
          ON {TRACKING}.[ContentId] = {GENERIC_CONTENT}.[Id]
WHERE 
        {TRACKING}.[ContentId] = {GENERIC_CONTENT}.[Id]
AND {GENERIC_CONTENT}.[ContentType] = 3
GROUP BY 
        {GENERIC_CONTENT}.[Title]