Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving count of Y and count of N from a single column in a table

 
Shankar Raj
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I have an issue I represent a column with String of length 1 in my db for maintaining a status Y or N . This column will never allow null.
Now I need to write a hibernate query to get count of Y and count of N from that table.
Say there are x number of records for a student and this column represents pass or fail for a particular subject.
So I need to get a student by id and how many subjects he as passed and in how many he had failed in one go using hibernate.

Need samples for this. I dont know if I have to use group by or union or whatever. Please help as soon as possible.

Regards,
Shankar Raj.J
 
Zoran Roncevic
Greenhorn
Posts: 13
Eclipse IDE Hibernate MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try reading this:
http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html#queryhql-grouping


I think it answers your question.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic