Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JPA - grouping by date part (as in t-sql datepart)

843830Feb 26 2008
hello, everyone.

I use JPA with Hibernate and need to group record (which has datetime field) by month and year.

In T-SQL it would look like:
select count(*) as ccc ,datepart(month , XM_DATE_CREATED) as mmm,datepart(year , XM_DATE_CREATED) as yyy from XT_SHOP_ORDER group by datepart(month , XM_DATE_CREATED),datepart(year , XM_DATE_CREATED) order by yyy,mmm

But how to do the same in JPA query language?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 25 2008
Added on Feb 26 2008
0 comments
901 views