黑帽联盟

 找回密码
 会员注册
查看: 1878|回复: 0
打印 上一主题 下一主题

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

[复制链接]
yun 黑帽联盟官方人员 

920

主题

37

听众

1364

积分

超级版主

Rank: 8Rank: 8

  • TA的每日心情
    奋斗
    2019-10-18 11:20
  • 签到天数: 678 天

    [LV.9]以坛为家II

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

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

    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天页面访问量,每日统计数量,以日期为序

    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天页面访问量,每日统计数量,以日期为序

    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小时分时

    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个小时

    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页面访问统计及排名情况,希望对大家有所帮助。


    帖子永久地址: 

    黑帽联盟 - 论坛版权1、本主题所有言论和图片纯属会员个人意见,与本论坛立场无关
    2、本站所有主题由该帖子作者发表,该帖子作者与黑帽联盟享有帖子相关版权
    3、其他单位或个人使用、转载或引用本文时必须同时征得该帖子作者和黑帽联盟的同意
    4、帖子作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任
    5、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
    6、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
    7、黑帽联盟管理员和版主有权不事先通知发贴者而删除本文

    您需要登录后才可以回帖 登录 | 会员注册

    发布主题 !fastreply! 收藏帖子 返回列表 搜索
    回顶部