View count, raw, by Post Type

1

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for programmers

SELECT      CASE WHEN (GROUPING (pt.Name) = 1) THEN 'Grand Total:'
                 ELSE ISNULL (pt.Name, 'UNKNOWN')
            END AS [Post Type],
            SUM ( COALESCE (p.ViewCount, 0) )   AS Views
FROM        Posts       p
LEFT JOIN   PostTypes   pt
ON          pt.Id       = p.PostTypeId
GROUP BY    pt.Name     WITH ROLLUP

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results
:records returned in :time ms:cached