A study of the Thomas-Reiche-Kuhn sum rule in finite nuclei