Q&A for programmers
with timeevents as
, len(body) as length
when posttypeid = 1 then 'Q'
when posttypeid = 2 then 'A'
end as type
where owneruserid = ##userid:int##
where userid = ##userid:int##
, numbered as (
select row_number() over(order by creationdate) as eventnum
, minutes_between_events as (
select datediff(n, s.creationdate, e.creationdate) as span
, cast(s.eventnum as nvarchar)
+ ' - '
+ cast(e.eventnum as nvarchar) as evm
, s.length + e.length as totlen
, s.type + e.type as types
from numbered s
inner join numbered e on s.eventnum + 1 = e.eventnum
select count(*) as [hours lost of your life]
, count(*) / 24 as [days lost of your life]
where span < 60