I think I'm making this more complicated than it needs to be. Removing the joins, here is the query:SELECT TOP (100) PERCENT SUM(dbo.JobDetails.ULPounds) AS SumofPounds, dbo.MaterialCat.MaterialCat, dbo.MaterialCat.MaterialCatID, SUM(dbo.JobDetails.Amount) AS SumofAmountFROM dbo.Jobs INNER JOIN dbo.JobDetails ON dbo.Jobs.JobID = dbo.JobDetails.JobID INNER JOIN dbo.Materials ON dbo.JobDetails.MaterialID = dbo.Materials.MaterialID INNER JOIN dbo.MaterialCat ON dbo.Materials.MaterialCatID = dbo.MaterialCat.MaterialCatIDWHERE (dbo.Jobs.UnloadDate >= CONVERT(DATETIME, '2009-02-13', 102)) AND (dbo.Jobs.UnloadDate <= CONVERT(DATETIME, '2009-02-13', 102))GROUP BY dbo.Jobs.StatusID, dbo.MaterialCat.MaterialCat, dbo.MaterialCat.MaterialCatIDHAVING (SUM(dbo.JobDetails.ULPounds) <> 0) AND (dbo.Jobs.StatusID = 'C')ORDER BY dbo.MaterialCat.MaterialCat
Results:SumofPounds MaterialCat MaterialCatID SumofAmount160 Batteries and Bulbs 14 NULL21460 Construction 7 416.005802 Difficult 9 85.00315 Electronics 13 45.0030575 Metal 2 12.005400 Paper 1 NULL400 Wood 6 NULL
What I also want to show (here's where I need the help) is the SumofPoundsInvoiced. In order to do this, the WHERE statement would also include:InvID Is Not NULLResults:PoundsInvoiced MaterialCat MaterialCatID SumofAmount9500 Construction 7 416.00575 Difficult 9 85.00105 Electronics 13 45.00345 Metal 2 12.00
Desired Output:Pounds Pounds MaterialCat MaterialCatID SumofAmount Invoiced160 0 Batteries and Bulbs 14 NULL21460 9500 Construction 7 416.005802 575 Difficult 9 85.00315 105 Electronics 13 45.0030575 345 Metal 2 12.005400 0 Paper 1 NULL400 0 Wood 6 NULL
Does that make any sense? Apologies if I'm not being clear...TIA,Catherine