-->
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: express extra criteria on left outer join queries with jpaql
PostPosted: Fri May 25, 2007 2:37 pm 
Newbie

Joined: Thu Mar 17, 2005 12:10 am
Posts: 8
The following SQL query counts the number of users in specific percentage ranges by using criteria on the join clause. How do you express the query in JPAQL? You may use the table names as entity names...Ill get the picture.

Code:
select e.location_id, count(p1.*) AS p1, count(p2.*) AS p2, count(p3.*) AS p3, count(p4.*) AS p4, count(p5.*) AS p5, count(p6.*) AS p6
   from monthly_participation_rates p1
   inner join enrollments e
     on p1.enrollment_id = e.id
   left outer join   monthly_participation_rates p2
     on p1.id = p2.id
     and p2.rounded_total_rate >= 100
   left outer join   monthly_participation_rates p3
     on p1.id = p3.id
    and p3.rounded_total_rate <= 99
    and p3.rounded_total_rate >= 75
   left outer join   monthly_participation_rates p4
     on p1.id = p4.id
    and p4.rounded_total_rate <= 74
    and p4.rounded_total_rate >= 50
   left outer join   monthly_participation_rates p5
     on p1.id = p5.id
    and p5.rounded_total_rate <= 49
    and p5.rounded_total_rate >= 1
   left outer join monthly_participation_rates p6
     on p1.id = p6.id
    and p6.rounded_total_rate <= 0
   where p1.month_id = -1
   group by e.location_id;


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.