Search code examples
activejdbc

ActiveJDBC MAX() function


I'm new to ActiveJDBC and Java. How can I do

SELECT MAX(age) FROM persons

with ActiveJDBC on a MySQL database?

I have tried

Pesrsons.find("MAX(age)")

but this one returns an empty list and

Persons.FindBySql("SELECT MAX(age) FROM persons")

this other one returns null. Any idea?


Solution

  • You can't use .find() to execute a custom "SELECT" query.

    But with .findBySql() this should work Persons.FindBySql("SELECT MAX(age) as age FROM persons")