Last updated November 23, 2012. Created by drupalshrek on November 23, 2012.
Log in to edit this page.
Grouping
To group by a given field, use the groupBy() method.
<?php
$query->groupBy('uid');
?>The above code will instruct the query to group by the uid field. Note that the field name here should be the alias created by the addField() or addExpression() methods, so in most cases you will want to use the return value from those methods here to ensure the correct alias is used. To group by multiple fields, simply call groupBy() multiple times in the order desired.