# Paginator order\_by

**URL:** <https://www.ruby-forum.com/t/paginator-order-by/105090>\
**Category:** Rails\
**Created:** [May 25, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/paginator-order-by/105090 "2007-05-25T18:52:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![itsnotvalid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e8c25b/32.png) [@itsnotvalid](https://www.ruby-forum.com/u/itsnotvalid)\
**Post date:** [May 25, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/paginator-order-by/105090/1 "2007-05-25T18:52:29Z")

</div>

I would like to use the paginator helper to order by a quantity that is  
the product of two database columns.

Is there a simple way to do this?

---

<div class="post-metadata">

**Author:** ![itsnotvalid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e8c25b/32.png) [@itsnotvalid](https://www.ruby-forum.com/u/itsnotvalid)\
**Post date:** [May 26, 2007, 2:47pm UTC](https://www.ruby-forum.com/t/paginator-order-by/105090/2 "2007-05-26T14:47:57Z")

</div>

Alan C. wrote:

> I would like to use the paginator helper to order by a quantity that is  
> the product of two database columns.
> 
> Is there a simple way to do this?

Someone will correct me if I’m wrong, but by using simple SQL you should  
be able to do…

:order =\> “(col1 \* col2)”

I’m also assuming that by product you mean multiplication. You can of  
course do any simple maths, or even other SQL queries in here.
