title: ORA-00979: not a GROUP BY expression oracle how to group by?
body: <p>I have an application that uses Hibernate.  It generated the following SQL statement.  I am trying to modify the query to group the data but I keep getting an error</p>
  
  <pre><code>ORA-00979: not a GROUP BY expression
  </code></pre>
  
  <p>The query</p>
  
  <pre><code>&gt;  select
  &gt;         snstoken0_.id as id20_0_,
  &gt;         snstokenme1_.SNS_MESSAGE_ID as SNS2_21_1_,
  &gt;         snstokenme1_.SNS_TOKEN_ID as SNS3_21_1_,
  &gt;         snsmessage2_.id as id19_2_,
  &gt;         snsmaster3_.id as id17_3_,
  &gt;         snstokenpr4_.id as id22_4_,
  &gt;         snstoken0_.ACTIVE_STATE as ACTIVE2_20_0_,
  &gt;         snstoken0_.MEMBER_ID as MEMBER8_20_0_,
  &gt;         snstoken0_.SNS_MASTER_ID as SNS9_20_0_,
  &gt;         snstoken0_.TOKEN1 as TOKEN3_20_0_,
  &gt;         snstoken0_.TOKEN2 as TOKEN4_20_0_,
  &gt;         snstoken0_.TOKEN3 as TOKEN5_20_0_,
  &gt;         snstoken0_.DATE_TOKEN as DATE6_20_0_,
  &gt;         snstoken0_.USERNAME as USERNAME20_0_,
  &gt;         snstokenme1_.ARTICLE_ID as ARTICLE1_21_1_,
  &gt;         snstokenme1_.SNS_TOKEN_ID as SNS3_20_0__,
  &gt;         snstokenme1_.SNS_MESSAGE_ID as SNS2_0__,
  &gt;         snstokenme1_.SNS_TOKEN_ID as SNS3_0__,
  &gt;         snsmessage2_.ACTIVE_STATE as ACTIVE2_19_2_,
  &gt;         snsmessage2_.CONTENT_ID as CONTENT5_19_2_,
  &gt;         snsmessage2_.MESSAGE_TEXT as MESSAGE3_19_2_,
  &gt;         snsmessage2_.SNS_MESSAGE_ID as SNS6_19_2_,
  &gt;         snsmessage2_.POST_DATE as POST4_19_2_,
  &gt;         snsmaster3_.ACTIVE_STATE as ACTIVE2_17_3_,
  &gt;         snsmaster3_.ACTIVE_ICON as ACTIVE3_17_3_,
  &gt;         snsmaster3_.AUTHENTICATION_URL as AUTHENTI4_17_3_,
  &gt;         snsmaster3_.BREAK_TOKEN_URL as BREAK5_17_3_,
  &gt;         snsmaster3_.INACTIVE_ICON as INACTIVE6_17_3_,
  &gt;         snsmaster3_.NAME as NAME17_3_,
  &gt;         snsmaster3_.URL_WEBSITE as URL8_17_3_,
  &gt;         snstokenpr4_.ACTIVE_STATE as ACTIVE2_22_4_,
  &gt;         snstokenpr4_.SNS_TOKEN_ID as SNS5_22_4_,
  &gt;         snstokenpr4_.VALUE as VALUE22_4_,
  &gt;         snstokenpr4_.VAR as VAR22_4_,
  &gt;         snstokenpr4_.SNS_TOKEN_ID as SNS5_20_1__,
  &gt;         snstokenpr4_.id as id1__ 
  &gt;     from
  &gt;         SNS_TOKEN snstoken0_ 
  &gt;     left outer join
  &gt;         SNS_TOKEN_MESSAGE snstokenme1_ 
  &gt;             on snstoken0_.id=snstokenme1_.SNS_TOKEN_ID 
  &gt;     left outer join
  &gt;         SNS_MESSAGE snsmessage2_ 
  &gt;             on snstokenme1_.SNS_MESSAGE_ID=snsmessage2_.id 
  &gt;     left outer join
  &gt;         SNS_MASTER snsmaster3_ 
  &gt;             on snstoken0_.SNS_MASTER_ID=snsmaster3_.id 
  &gt;     left outer join
  &gt;         SNS_TOKEN_PROP snstokenpr4_ 
  &gt;             on snstoken0_.id=snstokenpr4_.SNS_TOKEN_ID 
  &gt;     group by
  &gt;         snstoken0_.MEMBER_ID
  &gt;     having
  &gt;         snstokenpr4_.VAR='PROFILE_IMAGE'
  </code></pre>