SQL:
SELECT
a.buttonDisplayName,
COUNT(1) AS num
FROM
(SELECT
buttonDisplayName,
userId,
COUNT(1) cnt
FROM
tbl_new_buttonclick_202111 b
WHERE createTime > ‘2021-11-11’
AND createTime < ‘2021-11-13’
AND appId = 1072
GROUP BY buttonDisplayName,
userId) a
GROUP BY a.buttonDisplayName
explain analyze 报错
表结构
CREATE TABLE tbl_new_buttonclick_202111
(
id
bigint(20) unsigned NOT NULL AUTO_INCREMENT,
asId
varchar(64) DEFAULT NULL,
userId
bigint(20) DEFAULT NULL,
appVersionCode
int(11) DEFAULT NULL COMMENT ‘APP内部版本号’,
appVersionName
varchar(64) DEFAULT NULL COMMENT ‘版本名称’,
appPlatform
int(11) DEFAULT NULL COMMENT ‘1 android 2ios’,
appChannel
varchar(32) DEFAULT NULL COMMENT ‘推广渠道’,
registerChannel
varchar(32) DEFAULT NULL COMMENT ‘用户注册的channel’,
timeStamp
timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT ‘utc时间,事件发生的时间戳,毫秒的long类型’,
eventPage
varchar(64) DEFAULT NULL COMMENT ‘事件发生页面’,
itemId
varchar(500) DEFAULT NULL,
itemName
varchar(500) DEFAULT NULL,
packageName
varchar(128) DEFAULT NULL COMMENT ‘项目包名’,
appId
int(11) DEFAULT NULL COMMENT ‘项目APPID’,
createTime
datetime NOT NULL,
pageAsId
varchar(64) DEFAULT NULL COMMENT ‘page_open和page_close用这个id串联,代表是一对事件uuid’,
eventNewPage
varchar(128) DEFAULT NULL COMMENT ‘事件发生,产生的新页面名称’,
viewName
varchar(128) DEFAULT NULL COMMENT ‘该页面的子模块名称,或者弹窗名称,例如主页面的种植模块’,
viewDisplayName
varchar(128) DEFAULT NULL COMMENT ‘模块的中文名称’,
buttonId
varchar(64) DEFAULT NULL COMMENT ‘button的唯一命名,例如 tixian’,
buttonDisplayName
varchar(128) DEFAULT NULL COMMENT ‘button上的显示文案,例如 提现’,
userGold
bigint(20) DEFAULT NULL COMMENT ‘用户当前的金币’,
userLevel
int(11) DEFAULT NULL COMMENT ‘用户当前等级’,
userVit
bigint(20) DEFAULT NULL COMMENT ‘用户当前体力值’,
userMoney
varchar(32) DEFAULT NULL COMMENT ‘用户当前的红包券数量’,
awardTypeId
bigint(20) DEFAULT NULL COMMENT ‘事件如果发生奖励id,没有填空’,
awardTypeName
varchar(128) DEFAULT NULL COMMENT ’ 事件如果发生奖励,奖励类型,红包券,金币,体力,狗粮,化肥,种子’,
awardNumber
varchar(64) DEFAULT NULL COMMENT ‘事件如果发生奖励,奖励额度’,
planId
varchar(64) DEFAULT NULL,
createTimeStr
varchar(32) DEFAULT NULL,
extra
varchar(128) DEFAULT NULL,
first
varchar(50) DEFAULT NULL,
second
varchar(50) DEFAULT NULL,
third
varchar(50) DEFAULT NULL,
promotion
tinyint(2) DEFAULT NULL COMMENT ‘推广商: 0 头条 , 1 快手 ,2广点通’,
isNewUser
int(2) DEFAULT NULL COMMENT ‘区别新老用户: 1 新 ,0 老’,
PRIMARY KEY (id
,createTime
) /*T![clustered_index] NONCLUSTERED */,
KEY index_cacps
(createTime
,appId
,promotion
,appChannel
,second
)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=131610001
PARTITION BY RANGE COLUMNS(createtime) (
PARTITION p20211101
VALUES LESS THAN (“20211102”),
PARTITION p20211102
VALUES LESS THAN (“20211103”),
PARTITION p20211103
VALUES LESS THAN (“20211104”),
PARTITION p20211104
VALUES LESS THAN (“20211105”),
PARTITION p20211105
VALUES LESS THAN (“20211106”),
PARTITION p20211106
VALUES LESS THAN (“20211107”),
PARTITION p20211107
VALUES LESS THAN (“20211108”),
PARTITION p20211108
VALUES LESS THAN (“20211109”),
PARTITION p20211109
VALUES LESS THAN (“20211110”),
PARTITION p20211110
VALUES LESS THAN (“20211111”),
PARTITION p20211111
VALUES LESS THAN (“20211112”),
PARTITION p20211112
VALUES LESS THAN (“20211113”),
PARTITION p20211113
VALUES LESS THAN (“20211114”),
PARTITION p20211114
VALUES LESS THAN (“20211115”),
PARTITION p20211115
VALUES LESS THAN (“20211116”),
PARTITION p20211116
VALUES LESS THAN (“20211117”),
PARTITION p20211117
VALUES LESS THAN (“20211118”),
PARTITION p20211118
VALUES LESS THAN (“20211119”),
PARTITION p20211119
VALUES LESS THAN (“20211120”),
PARTITION p20211120
VALUES LESS THAN (“20211121”),
PARTITION p20211121
VALUES LESS THAN (“20211122”),
PARTITION p20211122
VALUES LESS THAN (“20211123”),
PARTITION p20211123
VALUES LESS THAN (“20211124”),
PARTITION p20211124
VALUES LESS THAN (“20211125”),
PARTITION p20211125
VALUES LESS THAN (“20211126”),
PARTITION p20211126
VALUES LESS THAN (“20211127”),
PARTITION p20211127
VALUES LESS THAN (“20211128”),
PARTITION p20211128
VALUES LESS THAN (“20211129”),
PARTITION p20211129
VALUES LESS THAN (“20211130”),
PARTITION p20211130
VALUES LESS THAN (“20211201”)
)