Comments - MAX(<date>) / GROUP BY behaviour...
Content reproduced on this site is the property of its respective owners,
and this content is not reviewed in advance by MariaDB. The views, information and opinions
expressed by this content do not necessarily represent those of MariaDB or any other party.
While it is an error in standard SQL, which can be enabled by sql_mode=STRICT, MySQL and MariaDB allow non-aggregate columns that are not included in the GROUP BY clause.
The values that the non-aggregate columns include are completely random and not necessarily related to, as in your case, a single row with the aggregate function result.
If you rewrite the query, you'll get consistent results:
I meant "the same row as the aggregate function result" instead of "a single row"
May I ask what's the role of `d1`in this query which apears to work perfectly by the way !
Many thanks !
My sample is creating a derived table which needs a name. I just did `d1`, but any name will do.