Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cableca
Starting Member
6 Posts |
Posted - 2008-02-27 : 14:46:38
|
| How can I add "filler" months to a query? I have a view that has data for January but I want the report that is linked via a pivot table to show february-december with blank data. so the report has a full 12month view.I hope this makes sense. any help would be greatly appreciated.Thanks! |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-02-27 : 14:50:14
|
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx E 12°55'05.25"N 56°04'39.16" |
 |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2008-02-27 : 21:18:40
|
| You need to create a sub query of your date range and outer join your query to it.select * from(select 1 m union allselect 2 union allselect 3 union allselect 4 union allselect 5 union allselect 6 union allselect 7 union allselect 8 union allselect 9 union allselect 10 union allselect 11 union allselect 12 ) monthsleft outer join("Your Query goes here" ) x onmonths.m=datepart(m, monthInYourQuery)order by m |
 |
|
|
|
|
|