# Problem with USQL

**URL:** <https://community.dynatrace.com/t/problem-with-usql/44010>\
**Category:** Real User Monitoring\
**Tags:** usql\
**Created:** [February 7, 2024, 9:58am UTC](https://community.dynatrace.com/t/problem-with-usql/44010 "2024-02-07T09:58:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![radek\_jasinski](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/radek_jasinski/32/10432_2.png) [@radek\_jasinski](https://community.dynatrace.com/u/radek_jasinski)\
**Post date:** [February 7, 2024, 9:58am UTC](https://community.dynatrace.com/t/problem-with-usql/44010/1 "2024-02-07T09:58:44Z")

</div>

Hi,

I have a USQL like this. I would like to catch information that a user has chosen a different look for the application. However, I am only interested in catching his last session (not all of them) to determine what app template they are using. Anyone know if this can be done?

_SELECT COUNT(DISTINCT internalUserId) AS “Number of users”, stringProperties.template\_type AS “GP Type” FROM usersession GROUP BY stringProperties.template\_type_

Radek

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [November 18, 2024, 12:39am UTC](https://community.dynatrace.com/t/problem-with-usql/44010/2 "2024-11-18T00:39:29Z")

</div>

I would add into your statement to have the end time, then filter ASC/DEC per the end time, that will give you the last session. Also keep in mind, until RUM is in grail (Right around the corner) you will only be looking at completed sessions with USQL.

---

<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:** [November 20, 2024, 9:03am UTC](https://community.dynatrace.com/t/problem-with-usql/44010/3 "2024-11-20T09:03:57Z")

</div>

Hello&nbsp;[@radek\_jasinski](https://community.dynatrace.com/user/16832)

PFA URL for checking the current scenario [https://www.dynatrace.com/support/doc/javascriptapi/interfaces/dtrum\_types.DtrumApi.html#addActionProperties](https://www.dynatrace.com/support/doc/javascriptapi/interfaces/dtrum_types.DtrumApi.html#addActionProperties)

 ![2024-11-20_12h58_18.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/3/53e7c07b9cceacf8f95cfd2c627f235f06757b02.png)

After defining the start and end actions you can create a USQL query to retrieve the target output.

Hoping it adds value.

BR,

Peter
