Add api for aggregate by categories (for bar chart)