Guest User

Untitled

a guest
Dec 16th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. select top 100 tagname
  2. , sum(cast(p.viewcount as bigint)) as [sum of views]
  3. , avg(cast(p.viewcount as bigint)) as [average of views]
  4. from posts p
  5. inner join posttags pt on pt.postid = p.id
  6. inner join tags t on t.id = pt.tagid
  7. where p.creationdate > dateadd(m, -1, getdate())
  8. and p.posttypeid = 1
  9. group by tagname
  10. order by 2 desc
Add Comment
Please, Sign In to add comment