implemented groupByKatIdAndInst