select id,wechat_id,online,happen_time
,lag(cast(happen_time as varchar),1,null) over(partition by wechat_id order by id )
,STR_TO_DATE(lag(happen_time,1,99991231000000)over(partition by wechat_id order by id ),'%Y%m%d%H%i%s')
from rt_ods.rt_ods_skynet_statistic_online_status_record where wechat_id='wxid_8074350742812'
结果如下
STR_TO_DATE(lag(happen_time,1,99991231000000)over(partition by wechat_id order by id ),'%Y%m%d%H%i%s')