-->
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: max-Function with subquery returning a list
PostPosted: Thu Feb 22, 2007 6:37 pm 
Newbie

Joined: Thu Feb 22, 2007 5:42 pm
Posts: 2
hello,

i have a table A with a field B
and what i want seems to work in SQL but not in HQL or which syntax can i use?

SQL:
SELECT MAX(B) FROM (
SELECT MAX(a.B) FROM A a WHERE .. GROUP BY .. HAVING sum(C) > 0
)


because of a GROUP BY + HAVING, i get several result-groups
but i need only one overall-MAX

in HQL "FROM (" leads to a syntax-error
and even if it would work, how to name the field?


-----------

at writing, i have tested another solution,

SELECT MAX(a.B) FROM A a WHERE .. AND 0 < (SELECT subquery)

works, but is slow because of the subquery..

_________________
Hansa wird Meister.


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.