-->
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: joining 2 subqueries
PostPosted: Mon Oct 11, 2010 10:00 am 
Newbie

Joined: Tue Oct 14, 2003 1:52 pm
Posts: 3
Hi,
I have a very simple OM comprised only of the Transaction class with fields: merchantId, cardId, country, amount.
I want to create a criteria for selecting all Transactions for the cardIds that were used more than 5 times with the same merchantId.
The SQL select looks something like this:
Code:
select t2.*   from (
   select * from SYSTEM.TBL_TRANSACTIONS) t2
   JOIN (
      select MERCHANTID, CARDID, Count(CARDID) as nbTxns
         from SYSTEM.TBL_TRANSACTIONS GROUP BY MERCHANTID, CARDID) t1 on t2.CARDID = t1.CARDID AND t2.MERCHANTID=t1.MERCHANTID WHERE (nbTxns > 5);


Is there any way to accomplish this using the Criteria language?

Thx.


Top
 Profile  
 
 Post subject: Re: joining 2 subqueries
PostPosted: Tue Oct 12, 2010 4:59 am 
Newbie

Joined: Tue Oct 14, 2003 1:52 pm
Posts: 3
I would also welcome any other suggestion / alternative on how to get the correct results (other select statement etc.)


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.