# Report number of users that have used each login method

**URL:** https://meta.discourse.org/t/report-number-of-users-that-have-used-each-login-method/132943
**Category:** Data & reporting
**Created:** [February 5, 2019, 2:40am UTC](https://meta.discourse.org/t/report-number-of-users-that-have-used-each-login-method/132943 "2019-02-05T02:40:02Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rishabh](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rishabh/32/179446_2.png) [@rishabh](https://meta.discourse.org/u/rishabh)
#### Post date: [February 5, 2019, 2:40am UTC](https://meta.discourse.org/t/report-number-of-users-that-have-used-each-login-method/132943/1 "2019-02-05T02:40:02Z")

</div>

### Number of active users per login method

Counts how many users have used each login method in the last 28 days. The time period can be changed via a parameter

```sql
--[params]
-- integer :last_seen_days = 28

SELECT provider_name, count(*)
FROM user_associated_accounts uaa
JOIN users u on u.id = uaa.user_id
WHERE u.active AND NOT u.staged
AND u.last_seen_at IS NOT NULL
AND last_used > NOW() - INTERVAL ':last_seen_days days'
GROUP BY provider_name
ORDER BY count(*) DESC

```

> **Output**
>
> ![Screenshot 2020-11-10 at 11.29.52](https://global.discourse-cdn.com/meta/original/3X/2/9/295898f0397b0f9a51cc4d2e5f689a6e0b7fdca9.png)

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [November 10, 2020, 11:33am UTC](https://meta.discourse.org/t/report-number-of-users-that-have-used-each-login-method/132943/2 "2020-11-10T11:33:12Z")

</div>

I just updated this query following a [change to how we store GitHub login information](https://github.com/discourse/discourse/commit/cf21de0e7a8293d48e17d5004e910f415b2b4e6b).

It will now work for all core login methods, and any plugins which use the ‘ManagedAuthenticator’ system (including discourse-oauth2 and discourse-openid-connect)

I also added a last\_seen\_days parameter, so you can easily customize the query time period.
