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

Count query

 
Darvesh Niz
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can count how many cats are green for example like this
"select count(cat.name) from Cat cat group by cat.color"
and then i can say
List count = query.getResultList()
the result are plain numbers like 2,1 etc...

what is want is to fetch the color also
"select count(cat.color),color from Cat cat group by cat.color
this should get me a result
2 green
1 red

etc...

Any advice.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try it?

"select count(cat.color), cat.color from Cat cat group by cat.color"

or,

"select count(cat.id), cat.color from Cat cat group by cat.color"
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic