# Time in Learn

<figure><img src="https://562960931-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkJKV1xpCBb6myYGAGdfV%2Fuploads%2FjXJijPETgZJL16SPO18p%2Ftime_spent_all_content_types.png?alt=media&#x26;token=ca095a53-f20a-4900-8082-a6e8b4520648" alt=""><figcaption></figcaption></figure>

To replicate the Time spent per month in all content types chart, you can use the following query:

```sql
SELECT
    date_trunc('month', occurred_at) as month,
    course_variant_id, 
    if(sum(duration_engaged) = 0, 0, sum(duration_engaged) / 3600) AS total_hours_on_learn
FROM data_connector_1234.fact_learn_events
-- The chart includes the current month and 11 months before
WHERE date(occurred_at) between
    date_trunc('month', date_add('month', -11, current_date)) and current_date
GROUP BY 1,2
ORDER BY 1,2

```
