# :having problem

**URL:** <https://www.ruby-forum.com/t/having-problem/160422>\
**Category:** Ruby\
**Created:** [February 16, 2009, 7:37am UTC](https://www.ruby-forum.com/t/having-problem/160422 "2009-02-16T07:37:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ganeshk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7cd45c/32.png) [@ganeshk](https://www.ruby-forum.com/u/ganeshk)\
**Post date:** [February 16, 2009, 7:37am UTC](https://www.ruby-forum.com/t/having-problem/160422/1 "2009-02-16T07:37:11Z")

</div>

Hi I am using :having option in query it is giving error like

“Unknown key(s): having”

plz reply me with solution

Advanced Thanks  
Ganesh

---

<div class="post-metadata">

**Author:** ![ganeshk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7cd45c/32.png) [@ganeshk](https://www.ruby-forum.com/u/ganeshk)\
**Post date:** [February 16, 2009, 8:04am UTC](https://www.ruby-forum.com/t/having-problem/160422/2 "2009-02-16T08:04:15Z")

</div>

On Mon, Feb 16, 2009 at 1:37 AM, Ganesh K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi I am using :having option in query it is giving error like
> 
> “Unknown key(s): having”

Sounds like :having is an unknown key.

-greg

---

<div class="post-metadata">

**Author:** ![ganeshk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/7cd45c/32.png) [@ganeshk](https://www.ruby-forum.com/u/ganeshk)\
**Post date:** [February 16, 2009, 1:58pm UTC](https://www.ruby-forum.com/t/having-problem/160422/3 "2009-02-16T13:58:41Z")

</div>

On Mon, Feb 16, 2009 at 1:37 AM, Ganesh K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi I am using :having option in query it is giving error like
> 
> “Unknown key(s): having”
> 
> plz reply me with solution

First, off, I’m guessing that this is a question about ActiveRecord,  
probably in the context of Rails. In general the rails group does better  
fielding these kind of queries than ruby-lang which focuses on the ruby  
language, and not so much on rails.

That said.

ActiveRecordBase#find does not have a :having option. It’s been  
proposed,  
but never acted upon. Instead you should add the HAVING clause to the  
value of the :group option per the reply by Josh S. in this thread:

[http://www.ruby-forum.com/topic/76042](http://www.ruby-forum.com/topic/76042)

I think that this makes sense, since the HAVING clause must be used in  
conjunction with a GROUP BY clause in SQL

As far as I know, nothing came of making a plugin to add a having option  
which was mentioned at the end of this 30 something month old thread.

–  
Rick DeNatale

Blog: [http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)  
Twitter: [http://twitter.com/RickDeNatale](http://twitter.com/RickDeNatale)
