2014-09-22 72 views
0
SELECT ip_address,datetime,DATE(datetime) as thedate, count(DATE(datetime)) as visits 
FROM articleview_logtable 
GROUP BY DATE(datetime) 

這個查詢的效果很好,它返回每個日期的行數。我想要一個查詢找出每一天的行數總數,而不用計算ip重複次數。 當有人訪問我製作的頁面時,插入每一行,問題是如果某人從相同的ip返回,我不想在那一天將他們算作一個新人。mysql group by display unique count of columns

+0

使用DISTINCT到組複製'SELECT COUNT(DISTINCT(IP地址)),日期時間,日期(日期時間)爲thedate,計數(DATE(日期時間))作爲訪問 FROM articleview_logtable GROUP BY DATE(datetime)' – yajakass 2014-09-22 21:23:28

回答

0

嘗試使用DISTINCT

SELECT ip_address, COUNT(DISTINCT(ip_address)) as visits, datetime,DATE(datetime) as thedate, 
FROM articleview_logtable 
GROUP BY DATE(datetime)