Can there be in one single SQL statement simple fields and fields with aggregate functions?

If I have a text query like

SELECT any_expr, SUM(field1), COUNT(field2) FROM any_table


does this mean that the field any_expr when all hands should be included in the GROUP BY or there may be cases when you should not?

I want to make a script which would analyze the request and if the list of fields has at least one field that contains aggregate functions, all other fields would be automatically added to the section GROUP BY
April 4th 20 at 00:55
1 answer
April 4th 20 at 00:57
Solution
the field must be either in group by or under aggregate function. alternative behavior does not meet the standard

Find more questions by tags MySQLSQL