D&D family views vs total views

0

Please login or register to vote for this query.

(click on this box to dismiss)

Esperanto Language

Q&A for teachers and students of the Esperanto language

--A query for checking how dominant DnD questions are in page views
-- Returns views for DnD and all questions, respectively,
-- followed by the total share of DnD questions' page views.

WITH results AS
(SELECT
  (
    SELECT SUM(ViewCount)
    FROM Posts
    --Questions only, possibly redundant
    WHERE PostTypeId = 1
    AND (
      Posts.Tags LIKE '%dnd%'
      OR Posts.Tags LIKE '%pathfinder%'
      OR Posts.Tags LIKE '%dungeons-and-dragons%'
    )
  ) AS DndViews,
  (
    SELECT SUM(ViewCount)
    FROM Posts
    WHERE PostTypeId = 1
  ) AS TotalViews
)
-- Views of DnD questions, Total views, ratio of the former
SELECT DndViews, TotalViews, (DndViews * 1.0 /TotalViews) AS ratio
FROM results

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results