在一个SQL查询中获取唯一视图和视图

时间:2011-10-07 19:28:37

标签: mysql visitor-statistic

我想在单个查询中检索uniqie视图和视图。 我当前对retrive视图的查询看起来像这样,但我也想用它检索唯一的视图。

IP地址的字段称为IP

SELECT `time` - `time` % 86400 AS Date, count(*) AS Views 
    FROM `bvcms_pageviews` 
    WHERE 1=1 
    GROUP BY Date

祝你好运

1 个答案:

答案 0 :(得分:1)

独特的IP视图数据?选择'Distinct'会对此有所帮助

 SELECT DISTINCT IP, `time` - `time` % 86400 AS Date, count(IP) AS
 Views FROM `bvcms_pageviews` WHERE 1=1 GROUP BY Date

http://www.sql-tutorial.com/sql-distinct-sql-tutorial/