Can you check this query in the lowest version of PostgreSQL we support? OTOH I'm not sure older versions support SELECT columns that don't also appear in GROUP BY statements.