• That kind of calculation can usually be done much more easily in the front end application or report.

    Aggregates in SQL have to be grouped and broken down by all the columns you are selecting. If you need something else, what you need to do is a sub-query that does the aggregate, and join that to the outer query. Are you familiar with writing sub-queries (either CTEs or "derived tables")?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon