I have this query and I’d like to get a sum of the count values in the ‘membership count’ column. How can I get the sum of the count values?
select count(MAJOR_KEY) 'membership count', chapter from Name where MEMBER_RECORD = 1 and (STATUS = 'I' or STATUS = 'SN') group by CHAPTER order by CHAPTER
Advertisement
Answer
If you want a last row with the sum then use GROUP BY ROLLUP
:
select count(MAJOR_KEY) [membership count], chapter from Name where MEMBER_RECORD = 1 and (STATUS = 'I' or STATUS = 'SN') group by ROLLUP(CHAPTER)