update ReportBuildingBlock set SQLSTRING='(select Bw_Pro_DOW_Trend.DAYOFWEEK as Day, sum(Bw_Pro_DOW_Trend.TOTAL_BYTES)/(CASE WHEN ${noofweeks}>0 THEN ${noofweeks} ELSE 1 END) as Bytes, ''Historical'' as Type from Bw_Pro_DOW_Trend inner join Resources on Bw_Pro_DOW_Trend.RID = Resources.RESOURCEID group by Day,Type order by position(DAYOFWEEK in ''SunMonTueWedThuFriSat'')) union  all (select to_char(User_Vs_Bandwidth_Dy.HOUR,''Dy'') as Day,sum(User_Vs_Bandwidth_Dy.TOTAL_BYTES) as Bytes, ''Last Week''  as Type from User_Vs_Bandwidth_Dy inner join Resources on User_Vs_Bandwidth_Dy.RID = Resources.RESOURCEID where ( User_Vs_Bandwidth_Dy.HOUR BETWEEN (localtimestamp(0) - INTERVAL ''7 DAY'') AND localtimestamp(0) ) group by Day,Type)' where RBBNAME like 'Weekly Trend Projection - BandWidth Comparison';
update ReportBuildingBlock set SQLSTRING='(select Evt_Vs_Pri_DOW_Trend.DAYOFWEEK as Day, sum(Evt_Vs_Pri_DOW_Trend.EVENT_COUNT)/(CASE WHEN ${noofweeks}>0 THEN ${noofweeks} ELSE 1 END) as Total_Events, ''Historical'' as Type from Evt_Vs_Pri_DOW_Trend inner join Resources on Evt_Vs_Pri_DOW_Trend.RID = Resources.RESOURCEID group by Day,Type order by position(DAYOFWEEK in ''SunMonTueWedThuFriSat'')) union  all (select to_char(Evt_Count_Dy.HOUR,''Dy'') as Day,sum(Evt_Count_Dy.EVENT_COUNT) as Total_Events, ''Last Week''  as Type from Evt_Count_Dy inner join Resources on Evt_Count_Dy.RID = Resources.RESOURCEID  where ( Evt_Count_Dy.HOUR BETWEEN (localtimestamp(0) - INTERVAL ''7 DAY'') AND localtimestamp(0) ) group by Day,Type)' where RBBNAME like 'Weekly Trend Projection - Event Comparison';
