简体   繁体   中英

How to find the difference of time between 2 rows in column

Hi When I use this query it gives me a 2 columns, each row will have a request and a response. How do I take the time difference between these two in seconds.

select M.MSG_DESC, M.Msg_Ts from INTLOG.ESB_MSG_L M,INTLOG.ESB_PAYLOAD_L P
where M.MSG_ID = P.MSG_ID
And M.Msg_Ts >= Timestamp'2014-02-16 00:00:00' 
And M.Msg_Ts <= Timestamp'2014-02-17 12:00:00' 
And M.Msg_ID IN ('90808','67678','534534')
ORDER by M.MSG_TS,p.payload_corl_id desc;

DatabaseUtility Request Internal 18-FEB-14 01.00.10.569000000 PM
DatabaseUtility Response Internal 18-FEB-14 01.00.19.553000000 PM
DatabaseUtility Request Internal 18-FEB-14 01.00.29.146000000 PM
DatabaseUtility Response Internal 18-FEB-14 01.00.29.705000000 PM
DatabaseUtility Request Internal 18-FEB-14 01.00.35.278000000 PM
DatabaseUtility Response Internal 18-FEB-14 01.00.38.313000000 PM

select M.MSG_DESC
     , M.Msg_Ts 
     ,TIMESTAMPDIFF(SECOND, M.MSG_DESC, M.Msg_Ts )
from INTLOG.ESB_MSG_L M INNER JOIN INTLOG.ESB_PAYLOAD_L P
ON   M.MSG_ID = P.MSG_ID
WHERE
    M.Msg_Ts >= Timestamp'2014-02-16 00:00:00' 
And M.Msg_Ts <= Timestamp'2014-02-17 12:00:00' 
And M.Msg_ID IN ('90808','67678','534534')
ORDER by M.MSG_TS,p.payload_corl_id desc;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM