17 Apr 2024 01:30 PM - last edited on 10 May 2024 03:35 PM by Michal_Gebacki
Hi dears,
I have an USQL query where I am showing by user, the session duration, and the number of actions by users, but I would like to add : the number of visits (sessions) by user also
SELECT userId, duration/1000/60 AS "Session duration / min", userActionCount AS "Number of actions" FROM usersession WHERE (userType="REAL_USER") AND userId IS NOT NULL
Can you help please ?
Regards
Solved! Go to Solution.
17 Apr 2024 01:57 PM
SELECT
userId,
COUNT(userId) AS "Number of visits",
AVG(duration/1000/60) AS "Average session duration / min",
SUM(userActionCount) AS "Total number of actions"
FROM
usersession
WHERE
userType = "REAL_USER"
AND userId NOT LIKE "%ca-cib.com%"
AND userId NOT LIKE "%zarrad%"
AND userId NOT LIKE "%aydi%"
AND userId IS NOT NULL
GROUP BY
userId;
Does this help?
17 Apr 2024 02:16 PM
I modified it as bellow because I can not calculate the AVG in seconds
I had the error : Mathematical Operation with aggregator functions is not supported!
SELECT
userId,
COUNT(*) AS "Number of visits",
AVG(duration) AS "Average session duration in ms",
SUM(userActionCount) AS "Total number of actions"
FROM
usersession
WHERE
userType = "REAL_USER"
AND userId IS NOT NULL
GROUP BY
userId
is there any solution for the ms to seconds ?