私は次のように2つのテーブルを持っています------
表1
CalenderType periodNumber periodstartdate
1 1 01-01-2013
1 2 11-01-2013
1 3 15-01-2013
1 4 25-01-2013
2 1 01-01-2013
2 2 15-01-2013
2 3 20-01-2013
2 4 25-01-2013
テーブル2
Incidents Date
xyz 02-01-2013
xxyyzz 03-01-2013
ccvvb 12-01-2013
vvfg 16-01-2013
x3 17-01-2013
x5 24-01-2013
ここで、特定の期間に発生したインシデントの数を調べたい (カレンダーの種類は実行時に変更される可能性があります) クエリは次のようになります
select .......
from ......
where CalendarType=1
返すべきもの
CalendarType PeriodNumber Incidents
1 1 2
1 2 1
1 3 3
1 4 0
誰かが私にこれを達成するためのアプローチや方法を提案できますか?
注: 10 日、5 日など、それぞれperiod
変動します。size.peroid1
period2