SQL创建enum作为列和组的日期



我有一个像下面这样的表格

<表类> id folder_num 类别 日期 tbody><<tr>1100/2021添加8/25/2021 20:582200/2021删除8/25/2021 21:023300/2021添加8/25/2021 21:064400/2021添加8/25/2021 21:105500/2021删除8/26/2021 21:146600/2021编辑8/26/2021 21:187700/2021编辑8/27/2021 21:228800/2021编辑8/27/2021 21:269900/2021编辑8/27/2021虽然101000/2021添加8/27/2021 21:34

不能嵌套聚合函数,但可以简单地使用:

SELECT date(l.date) as date,
sum(l.category = 'add') as add,
sum(l.category = 'delete') as delete,
sum(l.category = 'edit') as edit
FROM log l
WHERE l.date >= '2021-08-01' AND l.date < '2021-08-31'
GROUP BY l.date

相关内容

  • 没有找到相关文章

最新更新