# How to get monthly pageviews programatically? Preferably using Data Explorer

**URL:** <https://meta.discourse.org/t/how-to-get-monthly-pageviews-programatically-preferably-using-data-explorer/178103>\
**Category:** Data & reporting\
**Tags:** sql-query\
**Created:** [February 2, 2021, 1:00pm UTC](https://meta.discourse.org/t/how-to-get-monthly-pageviews-programatically-preferably-using-data-explorer/178103 "2021-02-02T13:00:42Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![michebs](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/michebs/32/190102_2.png) [@michebs](https://meta.discourse.org/u/michebs)\
**Post date:** [February 2, 2021, 1:25pm UTC](https://meta.discourse.org/t/how-to-get-monthly-pageviews-programatically-preferably-using-data-explorer/178103/2 "2021-02-02T13:25:45Z")

</div>

This is the query behind the `Consolidated Pageviews` report, I hope it helps.

```plaintext
-- [params]
-- date :start_date
-- date :end_date

SELECT
    ar.date,
    CASE 
      WHEN ar.req_type=6 THEN 'Crawlers'
      WHEN ar.req_type=7 THEN 'Logged in users'
      WHEN ar.req_type=8 THEN 'Anonymous users'
    END,
    ar.count AS views
FROM application_requests ar
WHERE req_type IN (6,7,8)
    AND ar.date::date BETWEEN :start_date::date
	AND :end_date::date
ORDER BY ar.date ASC, ar.req_type

```

---

_[View the full topic](https://meta.discourse.org/t/how-to-get-monthly-pageviews-programatically-preferably-using-data-explorer/178103)._
