分组统计,时间维度、类目维度,分组后排序
-- 统计条数
SELECT pubdate_day AS 日期, level_1 AS 一级品类, count(article_id) AS 发布数
FROM t1
WHERE pubdate_day > '20190801'
AND pubdate_day < '20190901'
GROUP BY 日期, 一级品类
ORDER BY 日期, 发布数 DESC;
-- 求平均值
SELECT DATE_FORMAT(dt, '%Y%m') AS 月份,
level_1 AS '品类',
AVG(app_pv) AS '品类月均PV'
FROM t2
WHERE dt > '20191001'and dt < '20200101'
GROUP BY level_1,
月份
ORDER BY 月份 DESC
修改列名称
ALTER TABLE
t1 CHANGE COLUMN c1 c2 VARCHAR(255) COMMENT '本列的注释'
网友评论