Hello. For each record in a lookup table, I want to sum values in a data table. I have an old query that correctly performs the sums, but leaves out any rows that don't have a corresponding record in the data table. So I first queried the lookup table for each record, but then the summing quit working. It has something to do with the GROUP BY, I know that, but any help would be greatly appreciated.

Here are the two queries. This is the old one that sums correctly but does not return a record if there is none in the data table:

SELECT PM.sPmtMethod, PM.sPmtMethodId, COALESCE (COUNT(QP.dPledgeAmt), 0) AS iPledgeCount, COALESCE (SUM(QP.dPledgeAmt), 0) AS dPledgeAmt,
PM.bPayrollDeduction
FROM dbo.tblPmtMethods PM LEFT OUTER JOIN
dbo.tblQueryPledges QP ON QP.sPmtMethodId = PM.sPmtMethodId
WHERE (QP.iCampaignId IS NULL OR
QP.iCampaignId = 3) AND (QP.iHierId IS NULL OR
QP.iHierId = 6 OR
QP.iHierId = 0)
GROUP BY PM.bPayrollDeduction, PM.sPmtMethod, PM.sPmtMethodId

Here is the new one that includes all the rows from the lookup table (ideally grouping all pmt methods were bPayrollDeduction = 1) but does not do the summing correctly:

SELECT PM.sUwDesc, PM.bPayrollDeduction, COALESCE (COUNT(QP.dPledgeAmt), 0) AS iPledgeCount, COALESCE (SUM(QP.dPledgeAmt), 0)
AS dPledgeAmt
FROM dbo.tblCampaigns_PmtMethods C_PM INNER JOIN
dbo.tblPmtMethods PM ON C_PM.sPmtMethodId = PM.sPmtMethodId LEFT OUTER JOIN
dbo.tblQueryPledges QP ON C_PM.iCampaignId = QP.iCampaignId
WHERE (C_PM.iCampaignId = 3) AND (QP.iCampaignId = 3) AND (QP.iHierId = 6 OR
QP.iHierId = 0)
GROUP BY PM.sUwDesc, PM.bPayrollDeduction

Any help is appreciated.