-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: how can create this HQL
PostPosted: Tue Apr 27, 2004 2:50 am 
Newbie

Joined: Tue Apr 27, 2004 2:36 am
Posts: 12
sorry, My english is poor, i will try to describe clearlly.

I have a Table to record the information when a user borrowed a book

the struct of the table is below

Code:
RecordID 
UserID     
BookID
BorrowTime


I want to count the book's be borrowed times, so I create a hql like this
Code:
select Rocord.book, count(*) from Record as Record group by Record.book


but it is not be sorted

I want it be sorted by total borrowed times,
how can i create the hql


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 03, 2004 6:01 am 
Regular
Regular

Joined: Wed Apr 21, 2004 10:57 am
Posts: 62
Location: Hasselt, Belgium
As shown in the example in the reference manual chapter 11.10.

Code:
select cat
from eg.Cat cat
    join cat.kittens kitten
group by cat
having avg(kitten.weight) > 100
order by count(kitten) asc, sum(kitten.weight) desc


In your code this would make :

Code:
select Record.book, count(*)
from Record as Record
group by Record.book
order by count(*)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.