I have the following problem.
I have a table lets call it Activity.
In this table there are 3 fields one is the date_start, the second is date_end and the third is the activity_type, which correspond the date that the activity start and ends and the type of activity for example physical activity and eating.
I would like to find the median time period that a activity_type lasts.
For example:
Activity.where(activity_type: "Eating healthy")
So I want to apply in this question, a sum statement with the time difference between the date_start and date_end.
How I can find the time differences of all the same type activities?
Aucun commentaire:
Enregistrer un commentaire