• Because you're selecting these columns directly: ListingID,StreetAddress, City, [State]

    They will need to be in the group by clase. Emaliagent and the rest shouldn't be. Think select distinct. Anything not being manipulated across rows to a single result needs to grouped by so each group is unique. If you just want listingID, only include listingID and the rest of the SUM()s.

    As to why you're getting 0s... The HAVING clause kicks in AFTER the aggregations are done, so if the other sums are positive while viewproperty is 0, and 0 when viewproperty is positive, you won't see the results. Once you fix up the group by clause as well you should clear up most of your issues. Otherwise, we'd need to see the tabledefs and sample data to puzzle that out. See the first link in my sig for help if you need it.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA