Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Retrieving max value from Dataobject

Go to End

2 Posts   1163 Views


Community Member, 5 Posts

26 June 2012 at 6:51am


I have column in a table which contains numbers. How can I retrieve the max value from that column? Do I have to use rawsql-query or is it possible to do with Dataobject::get?

Thanks in advance!


Forum Moderator, 1890 Posts

27 June 2012 at 2:18am

$iMax = DB::query("SELECT MAX(\"Field\") FROM \"DataObjectClassName\"")->value();