2016-05-13 122 views
0

我正在计算范围之间的日期。我看过here但这不适合我。计数范围之间的日期

这里是我的表的样本

repo | revision | date   | author 

test | 1   | 01/01/2011 | chris 
test | 2   | 01/01/2011 | chris 
test | 3   | 01/02/2011 | chris 

所以我想算对等同的回购日期...所以在这种情况下,它会返回201/01/2011101/02/2011

这里是我想我已经得到办成这个最接近...

select date, count(*) 
from SVNLogEntry 
where repo = 'test' and date between '01/01/2011' and '01/01/2017' 
group by date; 

回答

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

+0

啊!谢谢!这对我有用。 –