服务器之家:专注于服务器技术及软件下载分享
分类导航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|数据库技术|

服务器之家 - 数据库 - Mysql - MySQL页面访问统计及排名情况

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

2020-05-31 15:42MYSQL教程网 Mysql

这篇文章主要介绍了MySQL页面访问统计及排名情况,涉及到mysql页面访问统计,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页面访问统计及排名情况,希望对大家有所帮助。

延伸 · 阅读

精彩推荐
  • MysqlERROR: Error in Log_event::read_log_event()

    ERROR: Error in Log_event::read_log_event()

    ERROR: Error in Log_event::read_log_event(): read error, data_len: 438, event_type: 2 ...

    MYSQL教程网6402020-03-13
  • Mysql解决MySQl查询不区分大小写的方法讲解

    解决MySQl查询不区分大小写的方法讲解

    今天小编就为大家分享一篇关于解决MySQl查询不区分大小写的方法讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起...

    Veir_dev5592019-06-25
  • MysqlMySQL 数据备份与还原的示例代码

    MySQL 数据备份与还原的示例代码

    这篇文章主要介绍了MySQL 数据备份与还原的相关知识,本文通过示例代码给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下...

    逆心2962019-06-23
  • Mysqlmysql 不能插入中文问题

    mysql 不能插入中文问题

    当向mysql5.5插入中文时,会出现类似错误 ERROR 1366 (HY000): Incorrect string value: '\xD6\xD0\xCE\xC4' for column ...

    MYSQL教程网5722019-11-25
  • MysqlMySQL锁的知识点总结

    MySQL锁的知识点总结

    在本篇文章里小编给大家整理了关于MySQL锁的知识点总结以及实例内容,需要的朋友们学习下。...

    别人放弃我坚持吖4362020-12-14
  • Mysql浅谈mysql 树形结构表设计与优化

    浅谈mysql 树形结构表设计与优化

    在诸多的管理类,办公类等系统中,树形结构展示随处可见,本文主要介绍了mysql 树形结构表设计与优化,具有一定的参考价值,感兴趣的小伙伴们可以参...

    小码农叔叔5242021-11-16
  • Mysql详解MySQL中的分组查询与连接查询语句

    详解MySQL中的分组查询与连接查询语句

    这篇文章主要介绍了MySQL中的分组查询与连接查询语句,同时还介绍了一些统计函数的用法,需要的朋友可以参考下 ...

    GALAXY_ZMY5432020-06-03
  • MysqlMySQL数据库varchar的限制规则说明

    MySQL数据库varchar的限制规则说明

    本文我们主要介绍了MySQL数据库中varchar的限制规则,并以一个实际的例子对限制规则进行了说明,希望能够对您有所帮助。 ...

    mysql技术网4192019-11-23