I am looking to build an idea of how many unique visitors who have logged in to my site have had repeat visits over the last year
For example if I had 100k unique visitors YTD I would like to calculate how many times each user logged into the site for example build the below chart:
5k customers – 3 visits
40k – 2 visits
45k – 1 visit
This is what I currently have which seems to be doing the job mostly apart from some fringe results, i.e 100k users logged in 100k times, I feel like I’m missing a way to make it distinct
SELECT visit_count, COUNT(*) AS user_count
FROM (
SELECT USER_ID, COUNT(*) AS visit_count
FROM database
WHERE auth_succeeded = 'true' AND (log_time BETWEEN '2024-01-01' AND '2024-08-01')
GROUP BY USER_ID
) AS visit_counts
GROUP BY visit_count
ORDER BY visit_count;