Suppose I have the following an event table with personId, startDate and endDate.
personId
startDate
endDate
I want to know how much time the person X sp
;WITH cte(gap) AS ( SELECT sum(b-a) from xxx GROUP BY uid ) SELECT * FROM cte