# Is there any way of telling how popular a Theme is?

**URL:** https://meta.discourse.org/t/is-there-any-way-of-telling-how-popular-a-theme-is/93796
**Category:** Data & reporting
**Tags:** sql-query
**Created:** [2 augustus 2018 om 19:11 UTC](https://meta.discourse.org/t/is-there-any-way-of-telling-how-popular-a-theme-is/93796 "2018-08-02T19:11:10Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)
#### Post date: [2 augustus 2018 om 20:51 UTC](https://meta.discourse.org/t/is-there-any-way-of-telling-how-popular-a-theme-is/93796/4 "2018-08-02T20:51:04Z")

</div>

> [@merefield](#):
>
> `select u.username, t.id, t.name from users`

You don’t really need to look at the `users` table here to display usernames. [Data Explorer](https://meta.discourse.org/t/32566?silent=true) will automatically display avatars and username if the result of your query has a `user_id` column which the `user_options` table does have. 🙂

Anyway, this topic got me personally interested so I spent a few minutes playing with [data explorer](https://meta.discourse.org/t/32566?silent=true) and I got this little query which shows you user-selectable themes with the number of users using each theme:

```sql
WITH theme_stats AS (
    SELECT theme_ids[1] AS theme_id, COUNT(*)
    FROM user_options
    WHERE array_length(theme_ids, 1) <> 0
    GROUP BY theme_id
)

SELECT count AS "Number of users", themes.name AS "Theme name"
FROM theme_stats
JOIN themes
ON themes.id = theme_stats.theme_id
WHERE themes.user_selectable
ORDER BY "Number of users" DESC

```

---

_[View the full topic](https://meta.discourse.org/t/is-there-any-way-of-telling-how-popular-a-theme-is/93796)._
