# model.sum(:colï¼Œ:group=\>'col1,col2') only return 2 columns?

**URL:** <https://www.ruby-forum.com/t/model-sum-coli-oe-group-col1-col2-only-return-2-columns/144011>\
**Category:** Rails\
**Created:** [July 24, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/model-sum-coli-oe-group-col1-col2-only-return-2-columns/144011 "2008-07-24T17:13:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![phoenix520](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/6f9a4e/32.png) [@phoenix520](https://www.ruby-forum.com/u/phoenix520)\
**Post date:** [July 24, 2008, 5:13pm UTC](https://www.ruby-forum.com/t/model-sum-coli-oe-group-col1-col2-only-return-2-columns/144011/1 "2008-07-24T17:13:26Z")

</div>

There are 3 columns in my model ‘Bank’:bank\_name,money,save\_year,and I  
want to get the sum money group by bank\_name and save\_year.  
However,Bank.sum(:money,:group=\>‘bank\_name,save\_year’) just returns the  
sum money and the save\_year column,and  
Bank.sum(:money,:group=\>‘save\_year,bank\_name’) just returns the sum  
money and the bank\_name column!How can I get all of the three  
columns?And it’s a rails feature or bug?My db is mysql,and the sql of  
rails 2.1 generated returns all of the three columns in mysql query  
browser.  
Any help will be appreciated!
