Why does this query raise an exception? I am using the following code to query an ECK entity.

$query = \Drupal::database()-&gt;select('object__field_amount', 'f');
$query-&gt;fields('f', array('object__field_amount_value'));
$query-&gt;addExpression('MAX(object__field_amount_value)', 'maxvalue');
$query-&gt;execute()-&gt;fetchAssoc();


It raises the following exception.


  Drupal\Core\Entity\EntityStorageException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'maxvalue FROM object__field_amount f'


I've tried multiple other options, without result.

How do I avoid the code raises an exception?
MAXVALUE is a reserved word in MySQL (Maria). Change maxvalue to topvalue or something else.