• 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.
 
Beware the other head of science - it bites! Nibble on this message:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!