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, biapar, Willr, Ingo, swaiba, simon_w

Retrieving max value from Dataobject


2 Posts   542 Views


26 June 2012 at 6:51am Community Member, 5 Posts


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!


27 June 2012 at 2:18am Forum Moderator, 1796 Posts

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