This covers most use cases How do you use variables in a simple PostgreSQL script? but not the select clause.
This code produces an error column "ct"
column "ct"