Assuming your dates are DATETIME datatypes:create a table with a range of dates and JOIN by the range.declare @fy table (periodStart datetime, periodend datetime, fiscalYear int)insert @fy select '2006-05-01', '2007-05-01', 2006 union allselect '2007-05-01', '2008-05-01', 2007 union allselect '2008-05-01', '2009-05-01', 2008select fy.fiscalYear ,sum([AmtCol])from @fy fyinner join [someOtherTable] d on d.[dtCol] >= periodStart and d.[dtCol] < periodEndgroup by fy.fiscalYear
Ugh, looking at your example I'm guessing you are storing dates as CHAR(6), right?EDIT:Well, even so I guess this would work:declare @fy table (periodStart char(6), periodend char(6), fiscalYear int)insert @fy select '200605', '200705', 2006 union allselect '200705', '200805', 2007 union allselect '200805', '200905', 2008
Be One with the OptimizerTG