Bob Chiskey
Bob Chiskey

Reputation: 3

Timestamp calculation with CASE statement

I have a field in my Oracle SQL table:

LOGIN_TIME - this is a result after calculating the ENDTIME minus STARTTIME fields I am trying to achieve:

Please can you advise? This is my code so far:

SELECT DISTINCT a.SESSIONID,
d.USERNAME,
d.FNAME|| ' '||d.LNAME AS FULLNAME,
d.HOMEWKGRPID_NAME,
a.STARTTIME,
a.ENDTIME,
a.STATUS,
a.ENDTIME-A.STARTTIME AS LOGIN_TIME

from USERACCESSLOGSTATUS a INNER JOIN USERTABLE d ON a.USERID=d.ID
WHERE a.RDB_INSERT_DATE >= to_timestamp('2024-09-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')
AND d.HOMEWKGRPID_NAME LIKE ('REGION_%')

A previous comment advised to use a CASE statement to try and achieve this but I was unable to get this to work.

Example of current output

Upvotes: 0

Views: 28

Answers (0)

Related Questions