For a table that holds the records of user\'s webpages visiting behavior, how can I select users that visit more than one webpages.
The structure of this tables is:<
just add having clause
SELECT userId, COUNT(DISTINCT webpageId) AS count
FROM visits
GROUP BY userId
HAVING COUNT(DISTINCT webpageId) > 1
but if you only what the ID
SELECT userId
FROM visits
GROUP BY userId
HAVING COUNT(DISTINCT webpageId) > 1
the reason why you are filtering on HAVING clause and not on WHERE is because, WHERE clause cannot support columns that where aggregated.