Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » how to implement join for Same table
how to implement join for Same table [message #1400470] Mon, 14 July 2014 08:37
hun k is currently offline hun kFriend
Messages: 3
Registered: May 2014
Junior Member
Hello,

I have an interesting thing to implement. I have to implement the following Query in JPA2 without using NativeQuery method.

select smsid, smstimestamp, hphonenumber from db.sms as detail join (select max(smsid) as maxsmsid, max(smstimestamp) as maxtime from db.sms where myrmnid=5 group by hphonenumber order by maxsmsid limit 0,15) as topconv on detail.smstimestamp=topconv.maxtime and detail.smsid = topconv.maxsmsid

How can I do this?

query = entityManager.createQuery("select detail from sms as detail join (select max(m.smsid) as maxsmsid, max(m.smstimestamp) as maxtime from sms as m where m.myrmnid=:myrmnid group by m.hphonenumber order by maxsmsid limit 0,15) as topconv on detail.smstimestamp=topconv.maxtime and detail.smsid = topconv.maxsmsid");

The above statement is getting failed. Please help me with this. Any help is appreciated.

[Updated on: Wed, 16 July 2014 05:36]

Report message to a moderator

Previous Topic:MSSQL encoding issue
Next Topic:GROUP BY on a datetime field without time part
Goto Forum:
  


Current Time: Thu Apr 25 15:42:24 GMT 2024

Powered by FUDForum. Page generated in 0.02536 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top