I have three table TableA, TableB, TableC they all are linked by id. Table A has logTime and tableB has detectionTime and TableC has emptId.
For each empId I want 1. count of logTime when no detectionTime found in tableB 2. average of logTime and detectionTime difference if detectionTime found.
I have written this query that gets the average when detectionTime found but not sure how to get data when detectionTime not found
select det.empid ,average(det.blocked_time)
FROM (SELECT c.emplid as empid, EXTRACT(EPOCH FROM ( a.detectionTime - b.logTime )) as blocked_time
## inner and join condition here
) As det group by det.emplid where dat.blocked_time>0
Here I got entry when blocked_time>0 average and other stats.
How to get count of blocked_time for each empId when blocked_time is 0