mariadb order by results in group by trick

new mariadb optimizes subqueries, which prevents using trick to get required row when grouping by multiple rows, and you need specific row to show after applying group by

when using queries like:

    SELECT ... FROM table ORDER BY column DESC
GROUP BY some_field

to fix that, before this query set following option:

SET SESSION optimizer_switch='derived_merge=off';

this would allow sorting group by query by required column, and in turn provide us witch correct results