JPro
JPro

Reputation: 6556

summing the sum in mysql

Say If I get a resultset in mysql as :

ID  count(posts)
101 2344
102 3245
103 232
104 23

Is there any way to get the tota count of count(posts) in the query itself, like this?

ID  count(posts)
101 2344
102 3245
103 232
104 23
   ------
    5844

Upvotes: 5

Views: 111

Answers (1)

Quassnoi
Quassnoi

Reputation: 425813

SELECT  id, COUNT(*)
FROM    mytable
GROUP BY
        id WITH ROLLUP

Upvotes: 6

Related Questions