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/Group By on dates ???!
PostPosted: Mon Nov 06, 2006 7:10 pm 
Newbie

Joined: Mon Jan 30, 2006 6:33 pm
Posts: 9
Dear community,

I'm trying to execute the following HQL-Statement to get an overview of orders:

Code:
select count(custOrder), custOrder.Created from CustomerOrder as custOrder group by custOrder.Created order by custOrder.Created


This works out, but in my database the "Created"-field is a DateTime-field so the aggregate is done for every distinct hh:MM:ss of each day.
I would like to count the orders of ONE day (all 24 hours).

So I suggested something like the following

Code:
select count(custOrder), date(custOrder.Created) from CustomerOrder as custOrder group by date(custOrder.Created) order by date(custOrder.Created)


Didn't work so I tried:


Code:
select count(custOrder), {fn date(custOrder.Created)} from CustomerOrder as custOrder group by {fn date(custOrder.Created)} order by {fn date(custOrder.Created)}


Didn't work either.

Is there a way to accomplish this task?

Thank you in advance


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.