dcsimg
LinkedIn
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Summing a COUNT Aggregate SQL Function

See how to sum the result of a count aggregate function.


advertisement

The following code snippet shows a small example of how you can sum the result of a count aggregate function.

select sum(studentcount) as TotalCount
from
(
    SELECT  
        count(s.studentname) as studentcount,
        s.studentname as studentname
    FROM [students] as s  
    group by s.studentname 
    order by count(s.studentname) desc 
)a

 

Visit the DevX Tip Bank

 



   
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date