Trying to get unique records with MySQL
Posted
by Joshmattvander
on Stack Overflow
See other posts from Stack Overflow
or by Joshmattvander
Published on 2010-03-19T06:37:59Z
Indexed on
2010/03/19
6:41 UTC
Read the original article
Hit count: 168
mysql
|mysql-query
I have a query that is looking at a 'page_views' table. And I so far have the ability to get the total views by day. However, I am having an issue with getting unique views by day.
The column I am testing against is user_id... Here's the query I have for total views.
SELECT
site_id,
CONCAT(month(created_at) , '-', day(created_at), '-' , year(created_at)) as created_at_date,
COUNT(*) as total_results
FROM
page_views
GROUP BY day(created_at)
I can't figure out the logic to just get the unique views, by day based on the user_id column though.
© Stack Overflow or respective owner