select avg((DATEDIFF(day,us.CreationDate, GETDATE())*1.0...

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

  avg((DATEDIFF(day,us.CreationDate, GETDATE())*1.0/365)*1.0) as anosCriacao,

  avg((DATEDIFF(day,us.LastAccessDate, GETDATE())*1.0/365)*1.0) as anosUltimoAcesso,

  avg(us.Views*1.0) as views,

  avg(us.Reputation*1.0) as reputacao,

  count(*) as qtd,

  sum(qtdPosts) as posts,

  count(OwnerUserId) as usuariosQuePostaram

 

from

   Users us

  

left join

  (

  select

    OwnerUserId,

    count(*) as qtdPosts

  from

    Posts po

  group by

    OwnerUserId

  ) as po

  on

    us.Id = po.OwnerUserId

Enter Parameters

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