# Arel: Mathematical arithmic on columns

**URL:** <https://www.ruby-forum.com/t/arel-mathematical-arithmic-on-columns/193456>\
**Category:** Rails\
**Created:** [August 18, 2010, 1:57am UTC](https://www.ruby-forum.com/t/arel-mathematical-arithmic-on-columns/193456 "2010-08-18T01:57:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dykam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b5e925/32.png) [@Dykam](https://www.ruby-forum.com/u/Dykam)\
**Post date:** [August 18, 2010, 1:57am UTC](https://www.ruby-forum.com/t/arel-mathematical-arithmic-on-columns/193456/1 "2010-08-18T01:57:51Z")

</div>

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?

–  
Dykam
