Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I need to form an query in JPQL (2.0) to select a the max value (rank).
I use:
SELECT max(rank) FROM test
This works fine, except the case where the table is empty, then the result is
null
, but I need
0
.
This would be no problem if I was able to "catch" the null with an simple if-statement, but I can't do this (the framework allows only to specify an JPA Query but no java code).
Does anybody have an idea how to tune that query to get an
0
instead of an
null
if the table is empty? - The database is an MySQL, and native queries or stored procedures are no option.
–
Thanks for contributing an answer to Stack Overflow!
-
Please be sure to
answer the question
. Provide details and share your research!
But
avoid
…
-
Asking for help, clarification, or responding to other answers.
-
Making statements based on opinion; back them up with references or personal experience.
To learn more, see our
tips on writing great answers
.