I am looking to build a query in the data explorer - and being completely new to it, am not sure where to start!
I would like to run the following query:
Return the number of topics with a post marked as a solution by folk not in a given group, for a start and end date.
I couldn’t see any similar queries that do this, so my apologies if I missed it. All hints and tips gratefully received!
Hello and welcome @lju
This topic has a couple of examples in to get you started - How to get number of solutions per users using Data Explorer?
Thanks for that - it was helpful, and I think I got my head around the various fields
As a former data architect, I dream of having some sort of a data model to refer to, hint, hint…
I think you should be able to do it with two if you use
group_users. Maybe something like:
-- string :group_name = staff
-- date :date_from = 01/04/2022
-- date :date_to = 01/05/2022
COUNT(1) AS solved_count
FROM user_actions ua
JOIN group_users gu on ua.user_id = gu.user_id
WHERE ua.action_type = 15
AND gu.group_id = (SELECT id FROM groups WHERE name = :group_name)
AND ua.created_at::date BETWEEN :date_from::date AND :date_to::date
GROUP BY gu.group_id, ua.user_id
ORDER BY solved_count DESC
(FYI group_name is case sensitive)
Update: Belatedly realised I added in a third when I made the group look-up a bit more user-friendly than using a straight
group_id. But it could be done with two.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.