# Paginate with sqlserver

**URL:** <https://www.ruby-forum.com/t/paginate-with-sqlserver/146078>\
**Category:** Rails\
**Created:** [August 17, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/paginate-with-sqlserver/146078 "2008-08-17T14:34:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mgreenly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/85f322/32.png) [@mgreenly](https://www.ruby-forum.com/u/mgreenly)\
**Post date:** [August 17, 2008, 2:34pm UTC](https://www.ruby-forum.com/t/paginate-with-sqlserver/146078/1 "2008-08-17T14:34:28Z")

</div>

I do a sum query, the sql looks like below:

select material.code as material\_code,material.name as material\_name,  
sum(inventories.qty) as qty  
from inventories  
inner join materials on inventories.material\_id=materials.id  
group by material.code,material.name

It run correctly.But when I add the group item, one day the rails told  
me something error.And report the identifier is too long.Then I  
find,each time,rails alway run a sql like below:

select count(\*) as count\_all,material.code,material.name as  
material\_code\_material\_name  
from inventories  
inner join materials on inventories.material\_id=materials.id  
group by material.code,material.name

when I add the group item,one day the identifier like  
material\_code\_material\_name become too long

why??  
And How can I fix it??
