679
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
select t1.deriveno, t1.carno, t1.begintime, t2.endtime
from (select deriveno, carno, actualtime begintime
FROM (select a.deriveno,
a.carno,
a.stagecode,
to_char(a.actualtime, 'yyyy-mm-dd hh24:mi:ss') as actualtime
from app_carstatus a, app_send b
where a.deriveno = b.deriveno
and b.status in ('0', '10')
and b.deriveno not in (select deriveno from app_ridecost))
where stagecode = '3') t1
left join (select deriveno, actualtime endtime
from (select a.deriveno,
a.carno,
a.stagecode,
to_char(a.actualtime, 'yyyy-mm-dd hh24:mi:ss') as actualtime
from app_carstatus a, app_send b
where a.deriveno = b.deriveno
and b.status in ('0', '10')
and b.deriveno not in
(select deriveno from app_ridecost))
WHERE STAGECODE = '4') t2
on t1.deriveno = t2.deriveno