Q: Adding one table column values and sum should save in same column of other table The procedure i used is
INSERT INTO Tbl_PPACA_Report(ssn,lastname,firstname,level1_code,level1,level2_Code,level2,level3_Code,level3,level4_Code,level4,level5_Code,level5,DOH,UNIONCode,PPE,Hours,Grosswages,EmployerId,PayrollActivityDate) 
            SELECT Pr.ssn,Pr.lastname,Pr.firstname,level1code,level1description,level2Code,level2description,level3Code,level3description,level4Code,level4description,level5Code,level5description,DateOfHire,ISNULL(Pr.UNIONCode,'') UNIONCode,Pr.PPE,Pr.Hours,Pr.Grosswages,Pr.EmployerId,Pr.PayrollActivityDate
            from Tbl_PPACA_Import PR 
            LEFT OUTER JOIN Tbl_PPACA_Report P ON P.SSN=PR.SSN and P.EmployerID=PR.EmployerId and 
            ISNULL(P.Level1_code,'')=ISNULL(PR.LEVEL1CODE,'') and ISNULL(P.Level2_code,'')=ISNULL(PR.LEVEL2CODE,'') 
            and ISNULL(p.Level3_code,'')=ISNULL(Pr.LEVEL3CODE,'') and ISNULL(p.Level4_code,'')=ISNULL(Pr.LEVEL4CODE,'') 
            and ISNULL(p.Level5_code,'')=ISNULL(Pr.LEVEL5CODE,'') and P.DOH=PR.DATEOFHIRE and P.PPE=PR.PPE
            and P.[HOURS]=PR.[HOURS] and P.[GrossWages]=PR.[GrossWages]

            where (p.DOH is null OR P.PPE is null  OR P.[HOURS] is null OR P.[GrossWages] is null ) and pr.EmployerId=@Employer_Id and PR.SSN is not null and PR.PPE is not null and PR.DATEOFHIRE is not null and ISNUMERIC(PR.SSN)=1  ;

so i want the hours column from tbl_ppaca_import and save the sum of this column in Tbl_ppaca_report Hours column..
Thanks

A: INSERT INTO Tbl_PPACA_Report(ssn,lastname,firstname,level1_code,level1,level2_Code,level2,level3_Code,level3,level4_Code,level4,level5_Code,level5,DOH,UNIONCode,PPE,Hours,Grosswages,EmployerId,PayrollActivityDate) 
        SELECT Pr.ssn,Pr.lastname,Pr.firstname,level1code,level1description,level2Code,level2description,level3Code,level3description,level4Code,
        level4description,level5Code,level5description,DateOfHire,ISNULL(Pr.UNIONCode,'') UNIONCode,Pr.PPE,
        sum(Pr.Hours),sum(Pr.Grosswages),Pr.EmployerId,Pr.PayrollActivityDate
        from Tbl_PPACA_Import PR 
        LEFT OUTER JOIN Tbl_PPACA_Report P ON P.SSN=PR.SSN and P.EmployerID=PR.EmployerId and 
        ISNULL(P.Level1_code,'')=ISNULL(PR.LEVEL1CODE,'') and ISNULL(P.Level2_code,'')=ISNULL(PR.LEVEL2CODE,'') 
        and ISNULL(p.Level3_code,'')=ISNULL(Pr.LEVEL3CODE,'') and ISNULL(p.Level4_code,'')=ISNULL(Pr.LEVEL4CODE,'') 
        and ISNULL(p.Level5_code,'')=ISNULL(Pr.LEVEL5CODE,'') and P.DOH=PR.DATEOFHIRE and P.PPE=PR.PPE
        and P.[HOURS]=PR.[HOURS] and P.[GrossWages]=PR.[GrossWages]
        where (p.DOH is null OR P.PPE is null  OR P.[HOURS] is null OR P.[GrossWages] is null or pr.PPE is not null ) and pr.EmployerId=@Employer_Id and PR.SSN is not null and PR.PPE is not null and PR.DATEOFHIRE is not null and ISNUMERIC(PR.SSN)=1 
        group by Pr.ssn,Pr.lastname,Pr.firstname,level1code,level1description,level2Code,level2description,level3Code,level3description,level4Code,level4description,level5Code,level5description,DateOfHire,Pr.UNIONCode,Pr.PPE,
        Pr.EmployerId,Pr.PayrollActivityDate  ;

