Hello I have created a store procedure to display a report, I did what a report supposes to be. But there is one small thing that I dislike the way it displays, and that is: The output displays like below:SocialSecurityNumber ClearedDate Type DDS TOTALCLEARED 2 111223333 1/1/2009 DE BO 1 452127891 1/5/2009 SM CT 1 the number 2 is sum of two rows of the column "TOTALCLEARED". I wish it to display 2 at the bottom of column "TotalCleared" (not display 2 on top)DO ANYONE HERE KNOW HOW?HERE IS MY STORE PROCEDURE FOR THE DISPLAY ABOVEALTER PROCEDURE [dbo].[WklyCasesClearedWithNoReturns] -- Add the parameters for the stored procedure here @Start Datetime, @End Datetime, @Office varchar(5)ASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; --select * from ROCAPcreate table #temp(SocialSecurityNumber varchar(9),ClearedDate datetime,[Type] varchar(5),DDS varchar(50),TotalCleared int )if @office = 'ALL'begin--DEinsert into #tempselect SocialSecurityNumber, DEClearedDate as ClearedDate, 'DE' as [Type], DDS, NULL from ROCAPData whereDEClearedDate between @start and @Endand DESecondClearedDate is NULLand DEThirdClearedDate is NULLand DEFourthClearedDate is NULLOrder BY ISNULL( DEClearedDate, '31-Dec-2090')--Somaticinsert into #tempselect SocialSecurityNumber, SomaticMCClearedDate as ClearedDate, 'SM' as [Type], DDS, NULL from ROCAPData where SomaticMCClearedDate between @start and @Endand SomaticMCSecondClearedDate is NULLand SomaticMCThirdClearedDate is NULLand SomaticMCFourthClearedDate is NULLOrder BY ISNULL( SomaticMCClearedDate, '31-Dec-2090')--Psycinsert into #tempselect SocialSecurityNumber, PsycMCClearedDate as ClearedDate, 'PM' as [Type], DDS, NULL from ROCAPData where PsycMCClearedDate between @Start and @Endand PsycMCSecondClearedDate is NULLand PsycMCThirdClearedDate is NULLand PsycMCFourthClearedDate is NULLOrder BY ISNULL( PsycMCClearedDate, '31-Dec-2090')endelsebegin--DEinsert into #tempselect SocialSecurityNumber, DEClearedDate as ClearedDate, 'DE' as [Type], DDS, NULL from ROCAPData whereDEClearedDate between @Start and @Endand DESecondClearedDate is NULLand DEThirdClearedDate is NULLand DEFourthClearedDate is NULLand DDS = @officeOrder BY ISNULL( DEClearedDate, '31-Dec-2090')--Somaticinsert into #tempselect SocialSecurityNumber, SomaticMCClearedDate as ClearedDate, 'SM' as [Type], DDS, NULL from ROCAPData where SomaticMCClearedDate between @Start and @Endand SomaticMCSecondClearedDate is NULLand SomaticMCThirdClearedDate is NULLand SomaticMCFourthClearedDate is NULLand DDS = @officeOrder BY ISNULL( SomaticMCClearedDate, '31-Dec-2090')--Psycinsert into #tempselect SocialSecurityNumber, PsycMCClearedDate as ClearedDate, 'PM' as [Type], DDS, NULL from ROCAPData where PsycMCClearedDate between @Start and @Endand PsycMCSecondClearedDate is NULLand PsycMCThirdClearedDate is NULLand PsycMCFourthClearedDate is NULLand DDS = @officeOrder BY ISNULL( PsycMCClearedDate, '31-Dec-2090')endSelect SocialSecurityNumber, ClearedDate, [Type], DDS, Count(*) As TotalClearedfrom #tempGroup By SocialSecurityNumber, ClearedDate, [Type], DDSUnionSelect Null, Null, Null, Null, count(*)as TotalCleared from #tempEND
Joseph