最近的需求中一个日期格式为'时分秒'且该字段的数据类型是字符串,然后需要计算总的时间,于是想了想,在sql中这样处理可达到我想要的效果,代码如下
select (hours+minutes+seconds) AS total_seconds from(
select to_number(substr('00:12:20',0,2))*60*60 AS hours,
to_number(substr('00:12:20',4,2))*60 AS minutes,
to_number(substr('00:12:20',7,2)) AS seconds from dual
)