Database: create sum(col) but with where?

Hello,

I found the $query->sum(col)-statement, but this does not allow to restrict the records with WHERE.
How can I achieve this with kirby?

I tried

$where = 'user_id = "'.$userID.'" AND datum BETWEEN "'.$first_day_last_month.'" AND "'.$last_day_last_month.'"';
$sql = 'SELECT sum(dauer) as summe FROM arbeitszeiterfassung WHERE '.$where;
$sum = Db::query($sql);

and when I return a Db:lastQuery() I get a perfect SQL-Statement.
But when I return $sum->summe; nothing is returned.

:white_check_mark: Solved it myself

Db::sum() allows to put in table, col and where like this:

$sum = Db::sum('arbeitszeiterfassung', 'dauer', 'userId = 25');

Unfortunately it’s not to find in the documentation.

Would be nice to have it here, right after Average for example: https://getkirby.com/docs/guide/database