-->
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.  [ 1 post ] 
Author Message
 Post subject: HQL or native SQL for a SQL query with multiple joins
PostPosted: Wed Oct 06, 2004 11:58 pm 
Newbie

Joined: Wed Oct 06, 2004 11:43 pm
Posts: 1
Hibernate version:2.1.6

Hi,

Please help me to get the results of the following SQL query using HQL or native SQL support in hibernate.

Code:
select g.categoryid, g.categoryname, sum(b.amount) totalbill,
                sum(case when c.gender='F' then b.amount else 0 end)  totalfemalebill
         from category g
                left join customer c on g.categoryid = c.categoryid
                left join bill b on b.customerid = .customerid
        group by g.categoryid, g.categoryname
        order by g.categoryname


The tables are as follows:

category (class Category)
----------
categoryid
categoryname

customer (class Customer)
----------
customerid
categoryid
gender
customername

bill (class Bill)
----------
billid
customerid
amount
billdate


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

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.