For example:

SELECT MAX(sid) FROM {webform_submission} table0 WHERE table0.uid = 1;

It would be handy to support GROUP BY as well.

SELECT MAX(sid) FROM {webform_submission} table0 WHERE table0.uid = 1 GROUP BY table0.webform_id;

Comments

imclean created an issue. See original summary.

  • imclean committed 7d1cd6d on 8.x-1.x
    Issue #3227786: Support MIN/MAX
    
imclean’s picture

Status: Active » Fixed

Min/Max sid is now supported with an optional GROUP BY field.

For example, to retrieve the latest submissions by user 1 of 3 different forms:

$webformQuery = \Drupal::service('webform_query');
$results = $webformQuery->addCondition('webform_id', ['webform_one', 'webform_two', 'webform_three'], 'IN', 'webform_submission')
    ->addCondition('uid', 1, '=', 'webform_submission')
    ->addMinMax('MAX', 'webform_submission', 'webform_id') // MAX sid in webform_submission table, grouped by webform ID.
    ->orderBy('created', 'ASC', 'webform_submission')
    ->processQuery()->fetchCol();

Currently it only really makes sense with something like the above example. Grouping by form submission values isn't properly supported.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.