I have this:
SELECT
journals.id,
issues.created_on,
user_id,
journalized_id,
journals.created_on
FROM journals, issues
where issues.id=journals.journalized_id and journalized_id=23363
It shows next result:
id user_id journalized_id created_on
----- ------- -------------- -------------------
77996 182 23363 2013-10-07 13:41:45
77998 182 23363 2013-10-07 13:43:08
78000 174 23363 2013-10-07 13:54:26
78137 174 23363 2013-10-08 15:38:43
78269 167 23363 2013-10-09 17:14:26
78328 182 23363 2013-10-10 12:35:02
78442 167 23363 2013-10-11 18:06:13
I want to get the time difference between one "created_on" record and the previous one or the next for the same journalized_id
.
For ex: First record on the new row would be 0 ("2013-10-07 13:41:45"-"2013-10-07 13:41:45"), but next would be ("2013-10-07 13:43:08"-"2013-10-07 13:41:45"), I don't mind minutes or hours, and so on for the next, can you help me? How can I do it?
Thank you