title: Hibernate, how to count with condition
body: <p>I am using oracle and hibernate for mapping. I want to count with a condition in count() function. my code is:</p>
  
  <pre><code>select count(case when st.averageMark &lt; su.gradePass then 1 else 0 end)
  from Study st join st.subject su
   where st.acaYear in (2009)
    and st.semester = 4
    and su.idSeq = 1330
  group by st.acaYear
  </code></pre>
  
  <p>the code return me nothing. I used sum instead of count it returned a result but it is wrong, the result is bigger than I suppose it to be.</p>
  
  <p>thank in advance.</p>