-->
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.  [ 3 posts ] 
Author Message
 Post subject: How do I... group by (a.leftYear = a.rightYear)
PostPosted: Tue Jul 15, 2008 10:48 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
Is it possible to write this query?

Code:
select
  (a.leftYear = a.rightYear),
  sum (a.someValue)
from A a
group by
  (a.leftYear = a.rightYear)

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 16, 2008 3:00 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Quote:
Is it possible to write this query?


You just did, so it is possible.

Or to rephrase: What do you want to know?
- What is the result?
- Will my database accept it (Oracle most probably won't)
- How to transform this into a valid HQL or Criteria Expression?

Enjoy

_________________
Please rate useful posts.


Schauderhaft: Softwaredevelopment, Projectmanagement, Qualitymanagement and all things "schauderhaft"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 17, 2008 4:13 am 
Regular
Regular

Joined: Thu Oct 13, 2005 4:19 am
Posts: 98
schauder wrote:
Quote:
Is it possible to write this query?


You just did, so it is possible.

Or to rephrase: What do you want to know?
- What is the result?
- Will my database accept it (Oracle most probably won't)
- How to transform this into a valid HQL or Criteria Expression?

Enjoy


I was hoping to use it as a HQL query, but it generates a HQL grammar exception.
MySQL does except this query directly as SQL.

I've found a workaround by doing

group by case when (....) then true else false end

_________________
http://www.ohloh.net/accounts/ge0ffrey


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.