服务器之家

服务器之家 > 正文

MySQL页面访问统计及排名情况

时间:2020-05-31 15:42     来源/作者:MYSQL教程网

MySQL页面访问统计及排名情况

统计访问页面数量,以分辨率进行排名

?
1
2
3
4
5
SELECT CONCAT(`height` , '*', `width`) AS `resolution` , COUNT(CONCAT(`height`, '*', `width`)) AS `total`
FROM `wifi_status_page`
GROUP BY CONCAT(`height`, '*', `width`)
ORDER BY `total` DESC
LIMIT 0 , 30

最近7天页面访问量,每日统计数量,以日期为序

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
SELECT td AS showdate, COALESCE( totalcount, 0 ) AS totalcount
FROM (
SELECT CURDATE( ) AS td
UNION ALL SELECT DATE_ADD( CURDATE( ) , INTERVAL -1 DAY )
UNION ALL SELECT DATE_ADD( CURDATE( ) , INTERVAL -2 DAY )
UNION ALL SELECT DATE_ADD( CURDATE( ) , INTERVAL -3 DAY )
UNION ALL SELECT DATE_ADD( CURDATE( ) , INTERVAL -4 DAY )
UNION ALL SELECT DATE_ADD( CURDATE( ) , INTERVAL -5 DAY )
UNION ALL SELECT DATE_ADD( CURDATE( ) , INTERVAL -6 DAY )
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') add_data, COUNT( id ) AS totalcount
FROM wifi_status_page
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -6 DAY) AND CURDATE()
GROUP BY add_data
)b ON a.td = b.add_data

最近30天页面访问量,每日统计数量,以日期为序

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
SELECT td AS showdate, COALESCE( totalcount, 0 ) AS totalcount
FROM (
SELECT CURDATE( ) AS td
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -1 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -2 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -3 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -4 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -5 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -6 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -7 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -8 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -9 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -10 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -11 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -12 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -13 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -14 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -15 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -16 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -17 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -18 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -19 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -20 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -21 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -22 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -23 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -24 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -25 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -26 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -27 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -28 DAY)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -29 DAY)
ORDER BY td
)a
LEFT JOIN (
SELECT FROM_UNIXTIME(add_time, '%Y-%m-%d') add_data, COUNT( id ) AS totalcount
FROM wifi_status_page
WHERE FROM_UNIXTIME(add_time, '%Y-%m-%d') BETWEEN DATE_ADD(CURDATE(), INTERVAL -29 DAY) AND CURDATE()
GROUP BY add_data
)b ON a.td = b.add_data

昨天24小时分时

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
SELECT td AS showhour
FROM (
SELECT DATE_ADD(CURDATE(), INTERVAL -1 HOUR) as td
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -2 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -3 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -4 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -5 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -6 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -7 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -8 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -9 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -10 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -11 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -12 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -13 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -14 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -15 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -16 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -17 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -18 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -19 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -20 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -21 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -22 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -23 HOUR)
UNION ALL SELECT DATE_ADD(CURDATE(), INTERVAL -24 HOUR)
ORDER BY td
)a

今天过去的11个小时

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
SELECT td AS showhour
FROM (
SELECT NOW() AS td
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -1 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -2 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -3 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -4 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -5 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -6 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -7 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -8 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -9 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -10 HOUR)
UNION ALL SELECT DATE_ADD(NOW(), INTERVAL -11 HOUR)
ORDER BY td
)a

以上所述是小编给大家分享的MySQL页面访问统计及排名情况,希望对大家有所帮助。

相关文章

热门资讯

歪歪漫画vip账号共享2020_yy漫画免费账号密码共享
歪歪漫画vip账号共享2020_yy漫画免费账号密码共享 2020-04-07
沙雕群名称大全2019精选 今年最火的微信群名沙雕有创意
沙雕群名称大全2019精选 今年最火的微信群名沙雕有创意 2019-07-07
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分
玄元剑仙肉身有什么用 玄元剑仙肉身境界等级划分 2019-06-21
男生常说24816是什么意思?女生说13579是什么意思?
男生常说24816是什么意思?女生说13579是什么意思? 2019-09-17
超A是什么意思 你好a表达的是什么
超A是什么意思 你好a表达的是什么 2019-06-06
返回顶部