I'd suggest creating and populating a look-up table that defined the date range to group by. Join that table to your t_alm_etl_obj_fld_err_log table and group by the date range. Perhaps something like:create table DateRanges ( StartDate date not null, EndDate date not null )insert into DateRanges....select dr.StartDate + ' to ' + dr.EndDate as DateRange, -- Use Convert to get the date format you want! a.etl_err_id as Error Code, count(*) as Recordsfrom t_alm_etl_obj_fld_err_log ainner join DateRange dr on a.pstn_cyc_id between dr.StartDate and dr.EndDategroup by dr.StartDate, dr.EndDate, a.etl_err_id
No amount of belief makes something a fact. -James Randi