我正在尝试计算范围之间的日期。我看了here,但这不适合我。
以下是我的表格样本
repo | revision | date | author
test | 1 | 01/01/2011 | chris
test | 2 | 01/01/2011 | chris
test | 3 | 01/02/2011 | chris
所以我想计算一个与repo等效的日期...所以在这种情况下,它会返回2
01/01/2011
和1
<{1}} < / p>
这是我认为最接近完成此事的......
01/02/2011
答案 0 :(得分:4)
如果您想要不同日期的数量,请使用count(distinct)
:
select repo, count(distinct date)
from SVNLogEntry
where repo = 'test' and date between '2011-01-01' and '2017-01-01'
group by repo;
要按repo
获取,请使用group by repo
,而不是group by date
。