I'm wondering if it is possible to sum specific values after a count statement. At the moment I have:
SELECT roles.Name AS Role_Name , COUNT(DISTINCT ur.UserId ) AS RoleCount FROM dbo.AbpUsers as users
LEFT JOIN resourcing.CompanyorganizationUnitUserRole AS ur on users.Id = ur.UserId
LEFT JOIN dbo.AbpRoles AS roles ON roles.Id = ur.RoleId
GROUP BY roles.Name;
Which outputs:
Role_Name: |RoleCount:
TimeTrackingWritingMember |8277
OrganizationUnitLeader |529
Member |13901
DepartmentalCoordinator |759
OrganizationUnitSecondLeader |4
ResourceCoordinator |6
The idea is to SUM for example the roleCount of TimeTrackingWritingMember + Member = "Basic User"
I don't seem to get the logic how i could use both in one query. All help would be much appreciated