# Amount of time spent reading by Discourse groups

**URL:** <https://meta.discourse.org/t/amount-of-time-spent-reading-by-discourse-groups/77702>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [10 Enero, 2018 21:41 UTC](https://meta.discourse.org/t/amount-of-time-spent-reading-by-discourse-groups/77702 "2018-01-10T21:41:16Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)\
**Post date:** [22 Abril, 2018 06:45 UTC](https://meta.discourse.org/t/amount-of-time-spent-reading-by-discourse-groups/77702/5 "2018-04-22T06:45:22Z")

</div>

I took a look at this for @tobiaseigen and came up with the following:

```plaintext
SELECT group_users.group_id, ROUND((cast(sum(user_visits.time_read) as decimal)/60), 2) FROM user_visits
INNER JOIN group_users ON group_users.user_id = user_visits.user_id
WHERE user_visits.visited_at >= current_date - interval '60' day
GROUP BY group_users.group_id

```

1. We want each group compared against their time\_read sum

2. We need to join group\_users to user\_visits to make the comparison

3. We want to restrict the records to the last 60 days (for the recent time read)

4. We want to group the results by group\_id

If you want to get the results in hh:mm:ss format, just add `interval '1' minute *` before `ROUND`.

e.g.

 ![Screenshot%20at%20Apr%2022%2016-30-31](https://global.discourse-cdn.com/meta/original/3X/c/e/ce8ce2dbb3932ebf9bd21848cdef9d650f63df47.jpg)

---

_[View the full topic](https://meta.discourse.org/t/amount-of-time-spent-reading-by-discourse-groups/77702)._
