mysql数据库中,查询一个表的下一条数据减上一条数据的值的写法

mysql数据库中,查询一个表的下一条数据减上一条数据的值的写法:

select 
	a.nodeId,
	a.cpuCharge-b.cpuCharge cpuCharge, 
	a.chargeTime from
(select @arownum:=@arownum+1 rownum,nodeId,cpuCharge,chargeTime from rn_ext_vir_instance_charge_history,(select @arownum:=0) t where nodeId = 318263374 order by chargeTime) a,
(select @brownum:=@brownum+1 rownum,nodeId,cpuCharge,chargeTime from rn_ext_vir_instance_charge_history,(select @brownum:=1) t where nodeId = 318263374 order by chargeTime) b
where a.rownum = b.rownum;

展开阅读全文

没有更多推荐了,返回首页