V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
TypeErrorNone
V2EX  ›  问与答

求助, mysql + grafana 数据展示的 sql 怎么写呢?

  •  
  •   TypeErrorNone · Sep 24, 2019 · 2433 views
    This topic created in 2414 days ago, the information mentioned may be changed or developed.

    表的字段:

    image

    CREATE TABLE `user_log` (
      `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
      `uid` bigint(20) unsigned NOT NULL DEFAULT '0',
      `request_id` varchar(100) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
      `event` varchar(100) COLLATE utf8mb4_general_ci NOT NULL DEFAULT '',
      `coin` int(10) NOT NULL DEFAULT '0',
      `mobile` int(10) NOT NULL DEFAULT '0',
      `create_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
      `update_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
      PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=269 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户操作日志表';
    

    想实现按照 event 来展示数据,单位时间内 event 出现的次数,类似这种

    image

    求助这个 sql 怎么写呢?

    image

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1037 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:57 · PVG 01:57 · LAX 10:57 · JFK 13:57
    ♥ Do have faith in what you're doing.