Sagitec Solutions interview question

join with group by query