日付データが欠落している場合、2 つの日付の間のすべての日付を表示したい場合は、val 列にゼロを表示する必要があります。
declare @temp table (
id int identity(1,1) not null,
CDate smalldatetime ,
val int
)
チェックするデータのステートメントを挿入
insert into @temp select '10/2/2012',1
insert into @temp select '10/3/2012',1
insert into @temp select '10/5/2012',1
insert into @temp select '10/7/2012',2
insert into @temp select '10/9/2012',2
insert into @temp select '10/10/2012',2
insert into @temp select '10/13/2012',2
insert into @temp select '10/15/2012',2
月の初日から今日までのレコードを取得する
select * from @temp where CDate between '10/01/2012' AND '10/15/2012'
このクエリを実行すると、これら2つの日付の間のすべてのデータが表示されますが、欠落している日付も含めたいですval=0