本文介绍了如何获得2列之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个查询正在生成类似这样的内容:
I have a query that is producing something like this:
StartTimestamp | EndTimestamp ================================ 100 | 450 -------------------------------- 150 | 500我希望结果还包括EndTimestamp和StartTimestamp之间的差异:
I'd like the result to also include the difference between EndTimestamp and StartTimestamp:
StartTimestamp | EndTimestamp | Difference ============================================== 100 | 450 | 350 ---------------------------------------------- 150 | 600 | 450如何在MySQL中做到这一点?
How do I do this in MySQL?
推荐答案如果表被命名为t:
SELECT t.StartTimestamp, t.EndTimestamp, t.EndTimestamp - t.StartTimestamp AS Difference FROM &c当然,如果未修饰的名称StartTimestamp和EndTimestamp在其余查询的上下文中是明确的,则不需要在选择列中使用t.部分.
Of course, you don't need the t. parts in the select's columns if the undecorated names StartTimestamp and EndTimestamp are unambiguous in the context of the rest of your query.
更多推荐
如何获得2列之间的差异
发布评论