tags:

views:

75

answers:

1
+----+--------------+------+--------+---------+---------------------+-----------
| 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.

+2  A: 

1)Query which pages are requested most at a same moment.

SELECT time, uri, count(1) 
FROM tableName 
GROUP BY time, uri 
ORDER BY 3 DESC

2)Query which files are requested most at a same moment.

- Not sure how this is different from Query 1

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)

SELECT uri, refers, count(1) 
FROM tableName 
GROUP BY uri, refers 
ORDER BY 3 DESC
InSane
http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html#Access_Log_Valve/Attributes This is the pattern-combin, the page and file can not be differented by the "%r - First line of the request (method and request URI)"?
hguser
@hguser - Try giving an example of data you are expecting to see in "uri" and how file values differs from the "uri", if that is really what you are trying to indicate!!
InSane