I want to sum values in a column but they are repeated and each entry is linked to a different view. The table looks something like this -
| id | User Count | View |
|---|---|---|
| 1 | 500 | Reporting |
| 2 | 500 | Accounting |
| 3 | 500 | Marketing |
| 4 | 500 | Reporting |
How would I go about only summing up user count only for Reporting view?
Thanks!
CodePudding user response:
select sum(UserCount) from Table where View='Reporting';
CodePudding user response:
select View, sum(UserCount) as TotalUser from Table group by View
HAVING View='Reporting'; -- you can comment this clause to see sum for all View
