SQLite总和时间

时间:2019-02-20 21:09:21

标签: sqlite

我有一个表,该表的列包含事件的持续时间。 它的格式为“ h:mm:ss” 我找到了函数strftime-但根据手册,它要求格式为“ hh:mm:ss” 有人可以告诉我如何总结持续时间而无需重新创建sql表吗?

2 个答案:

答案 0 :(得分:0)

这是您想要的吗?

with t as (
  select '4:02:01' as v
  union all
  select '9:30:12'
  union all
  select '2:14:00'
),
diff as (
 select sum(strftime('%s', '0'||v) - strftime('%s', '00:00:00')) as v
 from t
)

select (v/3600) || ' hours, ' || (v%3600/60) ||' minutes, '
       || (v%60) || ' seconds.'
from diff

https://www.db-fiddle.com/f/2SNbFYQv2zYiCE4gw5bhzi/0

答案 1 :(得分:0)

您可以使用loading() { return this.$store.state.section.loading; } time()

strftime()

结果时间总和的格式为select time(sum( strftime('%s', case length(timecolumn) when 7 then '0' else '' end || timecolumn) - strftime('%s','00:00:00')), 'unixepoch') totaltime from tablename