2016-05-13 182 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

啊!謝謝!這對我有用。 –

相關問題