Using an alias in a group by

Is it possible to add a result with an alias and then group by that alias?

query.result.add(
			query.case.when(
				query.and
				.add(query.columns.type.eq(1))
				.add(joinQuery.columns.uuid.not.isnull)
				).then(query.columns.creation_date.year)
				.else(query.columns.cancelled_date.year)
		
		, 'compare_date_year')

queryPolicyCanLap.groupBy....

I’ve tried the addColumn but that doesn’t work as I think that’s looking for a field in the table