-->
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: Urgent need help in self join an query using criteria
PostPosted: Tue Sep 29, 2009 10:20 am 
Newbie

Joined: Tue Sep 29, 2009 9:29 am
Posts: 1
Hi need help on self join and query.

I have a sales_table with sales info and below are the below columns
id
item_id
items_sold
sale_time (time stamp)

This table will have all the sales info for a given item id, and how many items sale and at what time it was sale.
Now the challenge is i need to generate a summary report of items sold for a month.
If want to get using native sql i will do below way.

select tmptable.date_month, sum(tmptable.items_sold) from
(select items_sold items_sold,
DATE_FORMAT(end_date, '%b %Y') date_month
from sales_table) tmptable
group by tmptable.date_month

Can some one help me out how to do this using hibernate criteria. As I understand we need a self join and query it.

Thanks in advance.


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.