select t.account,datediff(ss,t.starttime,t.endtime),
(datediff(ss,'1900-01-01 00:00:00',(select top 1 w.starttime from ipphone w where w.starttime>t.endtime)-t.endtime)) as jiange
from ipphone t
group by t.account,t.starttime,t.endtime
select t.host_no,(datediff(ss,'1900-01-01 00:00:00',(select top 1 w.s_time from biao w where w.s_time>t.e_time)-t.e_time)) as jiange
from biao t
group by t.host_no,t.s_time,t.e_time