How to access variable alias name within a query?

By following this post blog I have created a dashboard variable using an alias.
Is there a way to access the __text within a query?

My goal is to automate a SQL query by using __value as column name and __text as its alias.