构建sql sql语法
+----+--------------+------+--------+---------+---------------------+----------- | Id | ip | uri | status | browser | time |refer .......... +----+--------------+------+--------+---------+---------------------+----------- int varchar varchar int varchar timeStampe varchar .......... -------------------------------------------------------------------------------
这是我的表的结构,用于保存tomcat日志(模式是组合)。
现在我想做一些类型的统计,但是我不擅长sql语句,所以我在这里问。
统计类型为:
1)查询同一时刻哪些页面被请求最多。然后我想将它们显示在表格中。 2)查询同一时刻哪些文件被请求最多。然后我想将它们显示在表格中。 3)查询访客从哪里(引用)跳转到网站,并对引用进行排序。
更新
日志示例:
127.0.0.1 - - [19/Oct/2010:20:38:43 +0800] "GET /tomcat.gif HTTP/1.1" 200 1934 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:43 +0800] "GET /asf-logo-wide.gif HTTP/1.1" 200 5866 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:43 +0800] "GET /tomcat-power.gif HTTP/1.1" 200 2324 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:43 +0800] "GET /favicon.ico HTTP/1.1" 200 21630 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:46 +0800] "GET /manager/html HTTP/1.1" 401 1833 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:49 +0800] "GET /manager/status HTTP/1.1" 401 1833 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10"
/tomcat.gif /asf-logo-wide.gif 是文件。
/manager/status /manager/html 是页面。
+----+--------------+------+--------+---------+---------------------+----------- | Id | ip | uri | status | browser | time |refer .......... +----+--------------+------+--------+---------+---------------------+----------- int varchar varchar int varchar timeStampe varchar .......... -------------------------------------------------------------------------------
This is the structure of my table used to save the tomcat logs(pattern is combine) here.
Now I want to do some types of statistics,however I am not good at sql words,so I ask it here.
statistics type is:
1) query which pages are requested most at a same monment. Then I want to show them in a table.
2)query which files are requested most at a same monment. Then I want to show them in a table.
3)query from where (the refer )visitor jump to the site,sort the refers.
update
THe example of the log:
127.0.0.1 - - [19/Oct/2010:20:38:43 +0800] "GET /tomcat.gif HTTP/1.1" 200 1934 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:43 +0800] "GET /asf-logo-wide.gif HTTP/1.1" 200 5866 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:43 +0800] "GET /tomcat-power.gif HTTP/1.1" 200 2324 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:43 +0800] "GET /favicon.ico HTTP/1.1" 200 21630 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:46 +0800] "GET /manager/html HTTP/1.1" 401 1833 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10" 127.0.0.1 - - [19/Oct/2010:20:38:49 +0800] "GET /manager/status HTTP/1.1" 401 1833 "http://localhost:9000/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10"
The /tomcat.gif /asf-logo-wide.gif are files.
/manager/status /manager/html are pages.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
1)查询同一时刻哪些页面被请求最多。
2)查询同一时刻哪些文件被请求最多。
3) 对于特定的 URI,这将为您提供最受欢迎的引用站点。 (这就是你所要求的,如果我理解正确的话)
1)Query which pages are requested most at a same moment.
2)Query which files are requested most at a same moment.
3) For a particular URI, this will give you the most popular referring sites. (this is what you are asking for, IF i have understood correctly)