Counting number of occurrences for each tag


I’m currently working with a table that is almost entirely qualitative event data, such as locale, device name, operation type, etc. I want to create aggregate counts of this data, for example like this in SQL. Is something like this possible using a tickscript in kapacitor? I’ve tried looking at Count and Distinct but neither appears to work for this specific scenario. I have looked at using conditionals such as where(lambda: “DeviceName” == ‘lge lg-h830’), and this does work, but I wouldn’t be able to add conditions for every possible case.

Thank you in advance!