I was wondering if I could get some help with a query. I am using SQL 2008 and have a temporary table named RESULTS that contains 4 columns needing to be totaled, with those totals grouped by LISTINGID. The query I have below produces the correct result for ViewProperty, but the rest come back as 0(zero). I don't understand why is it requiring me to list all the other fields in the Group By clause when ListingID is the only field I want to group by. Can someone please tell me what I am doing wrong and how to get the correct totals on the other fields?
SELECT ListingID,StreetAddress, City, [State], SUM(ViewProperty) as ViewProperty, SUM(EmailAgent) as EmailAgent, SUM(AgentWebsite) as AgentWebsite, SUM(PDFFlyer) as PDFFlyer, SUM(Directions) as Directions
GROUP BY ListingID,StreetAddress, City, [State], ViewProperty, EmailAgent, AgentWebsite, PDFFlyer, Directions
HAVING ViewProperty >0
ORDER BY ViewProperty Desc