-231 Cannot perform aggregate function with distinct on expression.
This statement selects DISTINCT (expression) within an aggregate
function. This action is not supported. Select the DISTINCT value and
other columns into a temporary table; then select ALL from that table
applying the aggregate function.