【发布时间】:2019-12-01 00:09:43
【问题描述】:
我有以下数据库架构
ID creation_date
1 2019-06-03
2 2019-06-04
3 2019-06-04
4 2019-06-10
5 2019-06-11
我需要按周找出表组的总大小。我正在寻找的输出类似于
year week number_of_records
2019 23 3
2019 24 5
我正在编写以下查询,它只给我每周创建的记录数
> select year(creation_date) as year, weekofyear(creation_date) as week,
> count(id) from input group by year, week;
我得到的输出是
year week number_of_records
2019 23 3
2019 24 2
【问题讨论】:
标签: mysql sql postgresql group-by aggregate