Skip to content
Advertisement

I have to get the total time spent for a question using SQL. I am unable to get the total time and provide the answer in minutes or H:M:S format

I am trying to find the total time taken per person and provide the answer in total minutes spent using SQL. The page_start_time is time data type.The data is shown below:

Data

This is the visitors table. I need to find the total time taken using the page_start_time field per USER_ID. I tried the following code:

I got the following answer:

answer

When I checked manually, the answer is incorrect.

Advertisement

Answer

I am guessing you want the difference between the minimum and maximum times for each user:

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement