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


Reply


2 Posts   566 Views

Avatar
ville

Community Member, 5 Posts

26 June 2012 at 6:51am

Hey,

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!

Avatar
swaiba

Forum Moderator, 1799 Posts

27 June 2012 at 2:18am

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