It's hard to explain, so I'll just write down what I have currently:
table.project("sum(`#{table.name}`.`#{table[:column_1].name}` * `#{table.name}`.`#{table[:column_2].name}`)")
I like to sanitize this and leave out as much raw sql as possible, and have multiple ideas/suggestions which may already exist:
table.project("sum(#{table[:column_1].full_name} * #{table[:column_2].full_name})")
table.project("sum(#{table[:column_1].times(table[:column_2]).full_name})") # If it's aliased, of course table.project(table[:column_1].times(table[:column_2]).sum) # #sum already exists, only #times doesn't.
Which of the above is possible, but in a different way?