-->
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: Aggregate for boolean?
PostPosted: Wed May 26, 2004 12:42 pm 
Beginner
Beginner

Joined: Tue Jan 06, 2004 4:51 pm
Posts: 48
Hi,

I'm in need of some help. I have a table that has a record of employees and their info (H). Every record has a date. Now, every employee will enter timesheets (T) so I need the most recent (H) for each (T).

Now I want to return H,T pairs using a hibernate query. H is mapped as a composite element of a set of an Employee record (E).

So initially, you would think of something like

select H,T from H inner join T where T.date >= H.date and H.date = (select max(date) from H where date <= T.date) group by T.E.id

but I wanted to get rid of the subquery, which turned into something like

select max(H.date), T.date, T.E.id, min(T), min(H) where T.date >= H.date group by T.E.id, T.date

which would work, except that H has a boolean column and min doesn't work on boolean values. In fact, none of the aggregate functions that would return an actual value of my boolean will work. What do I do? is there another way to rewrite the query without the subquery?


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.