Jump to content

distinct hits


brown2005

Recommended Posts

SELECT DISTINCT hits_user, year( hits_date ) AS hits_year, COUNT( hits_user ) AS hits_unique, SUM( hits_count ) AS hits_count

FROM a

GROUP BY year( hits_date )

ORDER BY year( hits_date ) DESC

LIMIT 0 , 30

 

i have the above which outputs

 

hits_user          hits_year  hits_unique  hits_count 

185.584.584      2007        2                100

 

but the hits unique bit should be 1 as there are two records with  185.584.584 in..

 

can anyone help please?

Link to comment
https://forums.phpfreaks.com/topic/41283-distinct-hits/
Share on other sites

hits_user          hits_year  hits_unique  hits_count 

185.584.584      2007        2                100

 

that is what it is displaying at the moment

 

i want it to display

 

hits_user          hits_year  hits_unique  hits_count 

185.584.584      2007        1              100

 

because 185.584.584 has visited the site two different days, but is only 1 unique hit. if you know what i mean?

Link to comment
https://forums.phpfreaks.com/topic/41283-distinct-hits/#findComment-200017
Share on other sites

hits_user          hits_year  hits_unique  hits_count 

185.584.584      2007        2                100

 

that is what it is displaying at the moment

 

i want it to display

 

hits_user          hits_year  hits_unique  hits_count 

185.584.584      2007        1              100

 

because 185.584.584 has visited the site two different days, but is only 1 unique hit. if you know what i mean?

 

I just read your reply  :)

 

Don't bother with hits_unique, because you have DISTINCT. There will only be one row returned. So you don't need to calculate '1' as it is always 1

 

monk.e.boy

Link to comment
https://forums.phpfreaks.com/topic/41283-distinct-hits/#findComment-200022
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.