
+---------+----------------+

Subqueries in the RETURNING clause that return more than one row or column
cannot be used.

Aggregate functions cannot be used in the RETURNING clause. Since aggregate
functions work on a set of values, and if the purpose is to get the row count,
ROW_COUNT() with SELECT can be used or it can be used in
INSERT...SELECT...RETURNING if the table in the RETURNING clause is not the
same as the INSERT table.

URL: https://mariadb.com/kb/en/insert/