Add missing ORDER BY timestamp to grouped queries