# Count Number of Groupings

**URL:** <https://community.dynatrace.com/t/count-number-of-groupings/48160>\
**Category:** Dashboarding\
**Tags:** dashboards-classic, user-sessions\
**Created:** [October 4, 2024, 8:24pm UTC](https://community.dynatrace.com/t/count-number-of-groupings/48160 "2024-10-04T20:24:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![awassel](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@awassel](https://community.dynatrace.com/u/awassel)\
**Post date:** [October 4, 2024, 8:24pm UTC](https://community.dynatrace.com/t/count-number-of-groupings/48160/1 "2024-10-04T20:24:19Z")

</div>

I’m using the below query but it’s not giving me the exact

```auto
SELECT userSessionId, COUNT(*) FILTER > 1 FROM usersession GROUP BY userSessionId

```

This give me the table with all the results, but I’m looking for the total number of groupings. Basically, this is the result:

| userSessionId | count(\*) |
| --- | --- |
| XXXXXXXX | 3 |
| XXXXX | 3 |
| XXXXXXXXX-XX | 2 |
| XXXXX | 2 |
| XXXXXXXXXXXXXXX | 2 |

However, I’m looking to get 5 - or the total number of rows (groups) in the table.

Is this possible?

---

<div class="post-metadata">

**Author:** ![p\_devulapalli](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/p_devulapalli/32/41590_2.png) [@p\_devulapalli](https://community.dynatrace.com/u/p_devulapalli)\
**Post date:** [October 7, 2024, 2:52am UTC](https://community.dynatrace.com/t/count-number-of-groupings/48160/2 "2024-10-07T02:52:36Z")

</div>

Hi&nbsp;[@awassel](https://community.dynatrace.com/user/81462)&nbsp;,&nbsp; &nbsp;Does something like below work ? If not, could you please elaborate your query a bit further

```markup
SELECT COUNT(DISTINCT userSessionId) AS sessionCount
FROM usersession

```

---

<div class="post-metadata">

**Author:** ![Peter\_Youssef](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/peter_youssef/32/14668_2.png) [@Peter\_Youssef](https://community.dynatrace.com/u/Peter_Youssef)\
**Post date:** [October 7, 2024, 6:06am UTC](https://community.dynatrace.com/t/count-number-of-groupings/48160/3 "2024-10-07T06:06:24Z")

</div>

Hi&nbsp;[@awassel](https://community.dynatrace.com/user/81462)

As per the attached query the below result will be presented

 ![Peter_Youssef_0-1728281088195.png](https://global.discourse-cdn.com/dynatrace/original/3X/6/4/646e8dba2041283e14cd0709cc296f76490518ce.png)

And as per the query provided by&nbsp;[@p\_devulapalli](https://community.dynatrace.com/user/21657), the below result is presented.

 ![Peter_Youssef_1-1728281153444.png](https://global.discourse-cdn.com/dynatrace/original/2X/e/ea10d9765b56b256ecf32eb4c938286a8301000a.png)

BR,
