Generalize macro for agg functions and impl Min, Max, Avg, Count and CountAll