# Is there a better way to do this (SQL groups)?

**URL:** <https://www.ruby-forum.com/t/is-there-a-better-way-to-do-this-sql-groups/162551>\
**Category:** Rails\
**Created:** [March 11, 2009, 9:06am UTC](https://www.ruby-forum.com/t/is-there-a-better-way-to-do-this-sql-groups/162551 "2009-03-11T09:06:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [March 11, 2009, 9:06am UTC](https://www.ruby-forum.com/t/is-there-a-better-way-to-do-this-sql-groups/162551/1 "2009-03-11T09:06:54Z")

</div>

I have a Task model and a Category model with belongs\_to and has\_many.  
What I want is to get from de DB the tasks in groups of categories and  
each one of this groups with a maximum of 5 tasks. Later, I want to show  
this in tables; each table will be a group.
