Ночные вопросы

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

select
  DATEFROMPARTS(DATEPART(yyyy, CreationDate), DATEPART(mm, CreationDate), 1) as Month,
  sum(IIF(DATEPART(hh, CreationDate) >= 20, 1, 0)) as [20+],
  sum(IIF(DATEPART(hh, CreationDate) >= 21, 1, 0)) as [21+],
  sum(IIF(DATEPART(hh, CreationDate) >= 22, 1, 0)) as [22+],
  sum(IIF(DATEPART(hh, CreationDate) >= 23, 1, 0)) as [23+]
from Posts
where PostTypeId = 1 and DATEPART(yyyy, CreationDate) >= 2016
group by DATEFROMPARTS(DATEPART(yyyy, CreationDate), DATEPART(mm, CreationDate), 1)
order by 1

Enter Parameters

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