I have the following query...SELECT mc.modelproductdetailid, mp.modelproductid,mpd.subproductid,SubProdPref.valuetext,SUM(CASE WHEN timeperiod = 'Y0' THEN mc.Reimbursement END) AS Y0Reimbursement,SUM(CASE WHEN timeperiod = 'Y1' THEN mc.Reimbursement END) AS Y1Reimbursement, SUM(CASE WHEN timeperiod = 'Y2' THEN mc.Reimbursement END) AS Y2Reimbursement, SUM(CASE WHEN timeperiod = 'Y3' THEN mc.Reimbursement END) AS Y3Reimbursement,SUM(CASE WHEN timeperiod = 'Y0' THEN mc.OtherValue END) AS Y0OtherValue, SUM(CASE WHEN timeperiod = 'Y1' THEN mc.OtherValue END) AS Y1OtherValue,SUM(CASE WHEN timeperiod = 'Y2' THEN mc.OtherValue END) AS Y2OtherValue,SUM(CASE WHEN timeperiod = 'Y3' THEN mc.OtherValue END) AS Y3OtherValue,msp.TotFinImpactY0,msp.TotFinImpactY1, msp.TotFinImpactY2, msp.TotFinImpactY3 FROM isim.modelproduct mpJOIN isim.ModelProductDetail mpd ON mp.modelproductid = mpd.modelproductidJOIN isim.preference ProdPref ON mp.productid = ProdPref.prefskey JOIN isim.preference SubProdPref ON mpd.subproductid = SubProdPref.prefskeyJOIN ISIM.MCProduct MC ON mpd.modelproductdetailid = MC.modelproductdetailidJOIN isim.modelscenario MS ON mp.modelid = MS.modelID JOIN isim.modelscenproduct MSP ON ms.modelscenarioid = msp.modelscenarioidAND mpd.modelproductid = MSP.modelproductID --product must be part of the scenario.AND mpd.whatifnum = MSP.whatifnum --get the correct whatifnumWHERE mp.modelid = 1197AND prodpref.prefcd = 'MC'AND MS.scenarionum = 1AND MS.RowDeletedDT IS NULLAND MP.RowDeletedDT IS NULLAND MPD.RowDeletedDT IS NULLAND MC.RowDeletedDT IS NULLAND MSP.RowDeletedDT IS NULLGROUP BY mc.modelproductdetailid, mp.modelproductid, mpd.subproductid, SubProdPref.valuetext,msp.TotFinImpactY0, msp.TotFinImpactY1, msp.TotFinImpactY2, msp.TotFinImpactY3
It returns the following results...13286 2720 21 Life 1320 2340 1230 1230 0 0 0 0 17600 26550 54140 -100013287 2720 25 AD&D 1230 3420 2450 3450 0 0 0 0 17600 26550 54140 -100013288 2720 26 Auto 3450 4560 3450 4560 0 0 0 0 17600 26550 54140 -100013314 2720 10 Other 0 0 0 0 1230 1450 1450 14560 17600 26550 54140 -100013315 2720 10 Other 0 0 0 0 1240 2340 4530 1340 17600 26550 54140 -100013316 2720 10 Other 0 0 0 0 3450 3450 3450 2350 17600 26550 54140 -100013317 2720 10 Other 0 0 0 0 2340 6540 7560 6540 17600 26550 54140 -100013318 2720 10 Other 0 0 0 0 3340 3450 3450 3450 17600 26550 54140 -1000
What I need to happen is for it to combine all "Other" products and give me the combined sum for all of them on one line. How can I go about doing this? Also, if there is a better way to write this query, please let me know.