Custom fields in Activity/History subpanel - show Dropdown value instead of key

So I’ve been following this article to show my custom field in the Activity and History subpanels, which all works fine.

The issue I’m having now is that my custom field is a dropdown field, and the custom SQL query retrieves the key of the dropdown list. Is it possible to somehow retrieve the value (display label) of my custom dropdown field and show this in the Activity/History subpanel instead?