Count the number of occurrences of certain values of TagName column
Sounds like a simple group by:
select tagname, count(*)
from alarmmaster
where tagname like '%Sensor%'  
   or groupname like '%Sensor%'
group by tagname;