Tuesday, January 28, 2014

Split date range without Calendar table

Miljan,


Did you try splitting the statement into two? Also check out the conditions...You want the data between @PeriodStart and @PeriodEnd right? Correct me if I misunderstood your requirement....




select T.PeriodStart, T.PeriodEnd, count(Column1)as count1, sum(Column2)as sum1
from Fact F with(nolock)WHERE F .[Start] >=@PeriodStart
and F.[End] <= @PeriodEnd

No comments:

Post a Comment