refactor calculation of full_label; uppercase SQL keywords