|how to implement join for Same table [message #1400470]
||Mon, 14 July 2014 08:37
| hun k
Registered: May 2014
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
Powered by FUDForum
. Page generated in 0.02810 seconds