- What is the fastest way to use a calculated column in a where clause with postgres?
SELECT (column1 + column2) AS super_column WHERE super_column > 1
- use a sub query in the FROM
- duplicate the logic for the calculated column
- _before_type_cast lets you get to attributes of a model before they are type cast, useful for validations and calculations.