Je suppose que vous voulez trouver la différence entre l'heure d'enregistrement minimale (où checktype =1) et l'heure de départ maximale (où 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