Ik vermoed dat je het verschil wilt vinden tussen de minimale inchecktijd (waarbij checktype =1) en de maximale uitchecktijd (waarbij checktype =0)
select userID,
min_date,
max_date,
(max_date - min_date) diff
from (
select distinct userID,
(
select min(checktime)
from checkinout t2
where t1.userID = t2.userID
and t2.checktype = 1
) min_date,
(
select max(checktime)
from checkinout t3
where t1.userID = t3.userID
and t3.checktype = 0
) max_date
from checkinout t1
)
order by userID