I have a mysql table like:
id, visitorid, pageid
When a visitor hits the website it stores their visitor id and the page id as a row.
I am trying to extract the number of visitors who hit the website exactly X times. (for a chart). so how many visit just one page, how many visit 2 pages...
so far I have:
SELECT COUNT(visid),visid FROM vislog GROUP BY visid ORDER BY COUNT(visid) DESC
But I don't know how to do the next part of counting the counts.
Is it possible to do as a mysql query?
Edit: I have added my answer.
I could solve it this way:
The little
x
is important.Raina77ow (2nd reply) returned a clean solution in his third block of code
thank you
You can wrap your query inside another one:
or (I suppose this makes more sense for passing the numbers to a chart), remove the
ORDER BY
which is the same as putting:Try using following query
Hope it helps...
One way to do it is to wrap this query into another one:
But I think you need to get the histogram of visits: this can be done with PHP (assuming the query is the same as in the question):
Or with MySQL itself: