# Data Structure for grouped queries?

I'm not sure what a more precise title could be. I have daily data incoming in which I want to total occurrences of a type. E.G today produced

Abc 20 times
Bca 19 times
Cab 13 times


Etc. I'm interested in querying this data grouped by an arbitrary time span, for example "total Abc's in January". Is there a way to preprocess this data to make those lookups more efficient?

I feel that with large tables the naïve approach could be slow...

-