• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding the Max of Select Query

 
Skanda Siva
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new developer for JPA and have a assignment to write the retrieve records from database using JPQL. Below is my Query. Basically I am trying to find the max of field1 from table Z



While Executing this query I am getting the error as below



Please Advise. When I am running the query using normal sql, its working fine.

When I tried removing the SELECT Query from the MAX and do something like MAX(somefield), it is working fine. Do you think if there are issues with the Syntax? Please let me know

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34669
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That query is complicated enough that it is hard to tell what is wrong. Can you try a simpler one and build up to where the error shows up?

For example, getting this working shows you know how to use an aggregate query/group by.

 
Skanda Siva
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I mentioned in my post, when I try query with Max(some field), its working fine. Error seems to be only when there is select statement in Max query. I tried NVL also to return ZERO in case if there are No records, but the error seems to still exist.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34669
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I missed that. This post says that it might not be supported by your JPA provider.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic