Friday 15 April 2011

mysql - GROUP BY DAY(FROM_UNIXTIME) unexpectedly changes count -


I am accumulating session IDs, IP addresses and timestamps of individual website visits, and all associated pageviews in the database. This includes more data, but related data has been removed from this query:

  SELECT page views .id, visitors.time, visitors, visitors. Pageviews on visitors coming from visitors. Session = Pageviews.session Order by visitors. Time ASC   

There are some such results:

  ID time session IP 1048 1371473496 nhie5sh2tiufs2ufupcremc6c2 x88.xxx. Kskskskksksks 1050 1371474103 8hfphqvq5ri6muc84oidp7q195 X6xkkskskskkskskskksksks 1062 1371474 9 56 hhgssr4v26pjbilkg8d81olqj7 Xxxkks3xkkskskskksksks 1066 137147633 9 ic8iqd0a4mpoelni15n4tq3404 Xlxkkskskskkskskskksksks 1067 137147662 9 ockivrm61upk7ss5ni4n8muv23 X2xkkskskskkskskskksksks 1070 +1371477856 5tdj9rrd1qsvafovufnkgh8r26 Xxxkksksks . X7x.xxx 1068 1371477856 5tdj9rrd1qsvafovufnkgh8r26 xxx.xxx.xxx.x2x 1069 1371478229 5e82v29nuf2k46ir13i21msps5 xxx.x5x.xxx.x8x   

The total number of visitors (different IPs), visits (different sessions) And the pageviews (separate pageview id), I ask the database like this:

  select count (differentiate (visitors.IP)) as 'visitors', count (individually) (Visitorship)), 'Visits' joins visitors with 'Pageview' in the form of Count (PageviewId). = Pageviews Session   

which gives something similar to the following:

  Visitor Visit Pageviews 211 244 412   

However, I Use archived timestamps for those years, months and days. To get that data, I wrote the following question:

  SELECT DAY (FROM_UNIXTIME (Visitors.time)) as 'de', MONTH (FROM_UNIXTIME (visitors.time)) 'Month' Year ('FROM_UNIXTIME' (Visitors.time)) as 'Year', Count as 'Visitors' (separate (Visitor.IP)), Count as 'Visits' (Separate (Visitorship) )), Count (Visitors on Visitors from Visitors to Pageviews 'Pageviews') = Pageviews C By year, month, year order of year, month, day DESC   

This works very well, at that date, pageviews and visits are correct: Day Month Year Visitors Visits Page Views 20 6 2013 40 43 59 19 6 2013 80 90 112 18 6 2013 62 66 173 17 6 ​​2013 43 45 68

As you can see, here the pageview reaches up to 412 and up to 244. What has kept me at night, however, is that of visitors Is not increased Nkya 211, as it should be, but instead of 225. I do not know why this is happening only for visitors

Sorry for the long question Any ideas will be highly appreciated.

Since you are counting a different IP, when you group groupings per month (months) The number of different IPs, i.e., if they travel in months, people can be counted more than once. For example: 12.123.456.78 visits in March and April, this is a specific IP counted each month, but if there is only one separate IP if the group is not from month to month, then you do not want to aggregate total COUNT (DISTINCT) Can not add results of a grouped COUNT (DISTINCT) only.

This functionality can be helpful because it puts some light on repeat visitors.

No comments:

Post a Comment