/**
* Implements hook_views_pre_execute().
* @param $view
*/
function mymodule_views_pre_execute(&$view) {
if ($view->name == 'commerce_orders' && $view->current_display == 'admin_page') {
// Group order list on /admin/commerce/orders/list page.
$view->build_info['query']->groupBy('commerce_order.order_id');
}
}
Help links
https://www.drupal.org/node/1342616
http://linuxdev.dk/blog/altering-views-queries