sqlite 用了聚合函数,max 和min的有,差值的好像没有?求各位大神帮忙呀
表的结构:
key val time
001 123 2018/12/05 16:20:00
001 555 2018/12/05 16:25:00
001 234 2018/12/05 16:30:00
002 567 2018/12/05 16:20:00
002 111 2018/12/05 16:25:00
002 234 2018/12/05 16:30:00
003 222 2018/12/05 16:20:00
003 333 2018/12/05 16:25:00
003 234 2018/12/05 16:30:00
想要的结果:
key max min diff
001 555 123 111
002 567 111 -333
003 333 222 12
select max(val) as max, min(val) as min, (max(val) - min(val)) as diff from table group by key