In my task I need to display the results based on “the newest first”. I perform a query:
$query = Drupal::database()->select('node_field_data', 'node'); $query->innerJoin('node__field_ils_apps', 'app', 'app.entity_id = node.nid AND app.field_ils_apps_target_id = '.$node->id()); $query->addField('app', 'entity_id', 'nid'); $query->groupBy('app.entity_id'); $query->orderBy('created', 'DESC'); $query->execute();
But it returns me an error:
SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column
Could you please tell me what I do wrong?