# Limiting results returned by find

**URL:** <https://www.ruby-forum.com/t/limiting-results-returned-by-find/92368>\
**Category:** Rails\
**Created:** [April 18, 2007, 7:00pm UTC](https://www.ruby-forum.com/t/limiting-results-returned-by-find/92368 "2007-04-18T19:00:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![simon1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@simon1](https://www.ruby-forum.com/u/simon1)\
**Post date:** [April 18, 2007, 7:00pm UTC](https://www.ruby-forum.com/t/limiting-results-returned-by-find/92368/1 "2007-04-18T19:00:38Z")

</div>

Hi,

I have the following line which returns a collection:  
@associated\_array = AssociatedAp.find(:all, :include =\> [:nic], :order  
=\> “date DESC”, :conditions =\> [‘nics.mac = ?’, @nic\_mac] )

Here @nic\_mac is a parameter being passed into the calling function.  
This call works perfectly, and returns all of AssociatedAp records  
that it should. However, what I would like to do is limit the  
returned set to include only the most recent occurrence of each unique  
associated\_ap. The uniqueness should be determined by both the  
associated\_ap.ssid and associated\_ap.mac fields.

Any help on how to accomplish this would be greatly appreciated.

Thanks,

Simon
