Prev: images in select query
Next: Build a date value
From: Plamen Ratchev on 4 May 2010 18:39 Try this: SELECT COUNT(DISTINCT L.LocationID) AS [LocRowCount], SUM(L.RiskCount) AS [RiskCount], SUM(C.TSI) AS [TSI] FROM #Location AS L JOIN (SELECT LocationID, SUM(TSI) AS TSI FROM #Coverage GROUP BY LocationID) AS C ON C.LocationID = L.LocationID; -- Plamen Ratchev http://www.SQLStudio.com |