I have a query that is producing something like this:
StartTimestamp | EndTimestamp
================================
100 | 450
--------------------------------
150 | 500
I'd like the result to also include the difference between EndTimestamp and StartTimestamp:
StartTimestamp | EndTimestamp | Difference
==============================================
100 | 450 | 350
----------------------------------------------
150 | 600 | 450
How do I do this in MySQL?
If the table is named, say, t
:
SELECT t.StartTimestamp, t.EndTimestamp, t.EndTimestamp - t.StartTimestamp AS Difference
FROM &c
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With