如何按日期查找每天有多少客户访问应用程序



嗨,我在MobApp中有一个移动应用程序,客户可以看到有关

金钱,新闻,预测,建议,我需要找出客户访问次数的计数

金钱,新闻,预测,建议每天根据日期分别进行。

日志表由以下列组成,例如

id  user_key  url_accessed   parameters           timestamp 
.. .........  ............   ..........          ............
1   sdhbhjbh  /user/money  mobile_no=9999999  2015-01-08 13:06:33
2   cnbjknjk  /user/news   user_key=534d2135  2014-09-06 26:02:25

在这里,我必须找到用户每天按日期访问 url 的次数,并计算访问次数

金钱,新闻,预测,建议的网址

在这里,我正在使用具有Pentaho数据集成的SQL Server。

请帮助解决这个问题

据推测,用户一天可以多次访问该应用程序。 如果是这样,您需要count(distinct)

select cast(timestamp as date) as thedate, count(distinct user_key)
from log l
group by cast(timestamp as date)
order by thedate;
SELECT 
  COUNT(DISTINCT user_key) user_key,
  url_accessed,
  CAST(timestamp as date) datestamp
FROM 
  yourtable
WHERE 
  url in ('/user/money', '/user/news', '/user/forecast', '/user/advice')
GROUP BY 
  url_accessed,
  CAST(timestamp as date)
ORDER BY 
  CAST(timestamp as date)

使用 COUNTGROUP BY 计算访问每个 URL 的唯一用户数。

SELECT COUNT(DISTINCT user_key), url_accessed
FROM logtable
GROUP BY url_accessed

最新更新