Count based on condition in SQL Server
I think he wanted user id in the results
SELECT
userid,
COUNT(*) as TotalcaseID, --total
SUM(CASE WHEN name = 'system' THEN 1 ELSE 0 END) as TotalRecordsWithSystem
FROM
myTable
group by userid
Use SUM/CASE...
SELECT
COUNT(*), --total
SUM(CASE WHEN name = 'system' THEN 1 ELSE 0 END) --conditional
FROM
myTable