# Find duplicate entries

**URL:** <https://www.ruby-forum.com/t/find-duplicate-entries/160464>\
**Category:** Rails\
**Created:** [February 16, 2009, 5:52pm UTC](https://www.ruby-forum.com/t/find-duplicate-entries/160464 "2009-02-16T17:52:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [February 16, 2009, 5:52pm UTC](https://www.ruby-forum.com/t/find-duplicate-entries/160464/1 "2009-02-16T17:52:08Z")

</div>

Hey all,

i create a hash from an description field to find equal entries.  
Now i want to show only the entries with an equal hash.  
(Hash value is stored in text\_hash field on the model)

I try :group =\> ‘text\_hash’ but i dont figure out the where condition.  
(Where Count(\*) \> 2 something like this… )

Can this be done with minimum?

Thanks for help 🙂

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [February 16, 2009, 7:34pm UTC](https://www.ruby-forum.com/t/find-duplicate-entries/160464/2 "2009-02-16T19:34:31Z")

</div>

I think i have a solution:

:group =\> "text\_hash having count(text\_hash) \> 2

but how to :order, :order =\> ‘text\_hash DESC’ seems not to work :-/

Perhaps i have to sort the result collection…

Stephan M. wrote:

> Hey all,
> 
> i create a hash from an description field to find equal entries.  
> Now i want to show only the entries with an equal hash.  
> (Hash value is stored in text\_hash field on the model)
> 
> I try :group =\> ‘text\_hash’ but i dont figure out the where condition.  
> (Where Count(\*) \> 2 something like this… )
> 
> Can this be done with minimum?
> 
> Thanks for help 🙂

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [February 16, 2009, 8:11pm UTC](https://www.ruby-forum.com/t/find-duplicate-entries/160464/3 "2009-02-16T20:11:31Z")

</div>

On 16 Feb 2009, at 16:52, Stephan M. wrote:

> Can this be done with minimum?  
> you need a ‘having’ clause to filter on an aggregate function such as  
> count. rails 2.3 allows you to pass :having =\> ‘…’ with old versions  
> you need to do mucky stuff like :group =\> ‘text\_hash having something  
> 2’

Fred

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [February 17, 2009, 4:36am UTC](https://www.ruby-forum.com/t/find-duplicate-entries/160464/4 "2009-02-17T04:36:51Z")

</div>

You need to clean up your question. It makes no sense. Please be  
clearer if you want a response.

Blog: [http://random8.zenunit.com/](http://random8.zenunit.com/)  
Learn rails: [http://sensei.zenunit.com/](http://sensei.zenunit.com/)

On 17/02/2009, at 3:52 AM, Stephan M.  
\<removed\_email\_address@domain.invalid
