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

だから私はレポについて等価であり、日付をカウントしたい...だから、この場合には、それは01/02/2011

ため 01/01/20111ため 2を返すです ここ

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

答えて

4

あなたはワンなら...私はこれを達成するには得ていると思います最も近いです明確な日付のナンバーT、そして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

Ah!ありがとうございました!これは私のために働く。 –