Aggregate function manage custom SQL data type