mysql数据库查询表中相邻数据的差值

select a.time ,a.sum - b.sum sum,a.time,b.time
from  
(select @arownum:=@arownum+1 rownum,sum ,time from summary_hour,(select @arownum:=0) t where energy_type= 1 order by time) a,  
(select @brownum:=@brownum+1 rownum ,sum,time from summary_hour,(select @brownum:=1) t where energy_type= 1 ORDEr by time) b  
where a.rownum = b.rownum;  

 

posted @ 2018-06-08 13:27  谁将新樽辞旧月,今月曾经照古人  阅读(878)  评论(0编辑  收藏  举报