Add support for groupby in the query