with a(id,carld,runkm) as
(
 select 1,1,3 union all
 select 2,3,8 union all
 select 3,1,5 union all
 select 3,3,7 union all
 select 4,2,8 union all
 select 5,1,9
)
select * from 
(select  b.carld,C.runkm-b.runkm as runkm from 
(select *,ROW_NUMBER()over(partition by carld order by id) as aid from a) as b,
(select *,ROW_NUMBER()over(partition by carld order by id) as aid from a) as c
where b.carld=c.carld and b.aid+1=c.aid
union all
select a.carld,MIN(a.runkm) as runkm from a group by a.carld having COUNT(*)=1) as d
order by d.carld/**
carld runkm
------------
1    2
1    4
2    8
3   -1
-----------
**/