Anton.Sandbox

1

Please login or register to vote for this query.

(click on this box to dismiss)

Iota

Q&A for users of Iota, the open-source cryptocurrency for IoT that does not use a blockchain

DECLARE @All int = ##All:int?1##
DECLARE @Frequency int = ##Frequency:int?3##
DECLARE @UsedId int = ##UserId:int##
DECLARE @YearsBack int = ##YearsBack:int?1##

;WITH tmp AS
(
  SELECT q.ViewCount, DATEPART("day", q.CreationDate) as CreationDay
  FROM Posts q
  WHERE q.OwnerUserId = CASE WHEN @All = 1 THEN q.OwnerUserId ELSE @UsedId END
    AND q.CreationDate > DATEADD("year", -2, CURRENT_TIMESTAMP)
    AND q.CreationDate < DATEADD("year", -1, CURRENT_TIMESTAMP)
    AND q.PostTypeId = 1
    AND DATEPART("week", q.CreationDate) IN (51, 52)
  )
  SELECT CreationDay,
  CAST(SUM(ViewCount) AS FLOAT)/CAST(COUNT(*) AS FLOAT) AS [Views per question]
FROM tmp
GROUP BY CreationDay
ORDER BY CreationDay

Enter Parameters

Options:
Switch to meta site
loading Hold tight while we fetch your results