Is a GROUP BY statement valid if there are no aggregate functions?
💡 Model Answer
In standard SQL, a GROUP BY clause is used to aggregate rows into groups and then apply aggregate functions (SUM, COUNT, AVG, etc.) to each group. If you include a GROUP BY but omit any aggregate functions, the query is syntactically valid but semantically redundant. The result will simply return one row per distinct combination of the grouped columns, which is equivalent to using SELECT DISTINCT. Some databases allow GROUP BY without aggregates for convenience, but it is generally discouraged because it can mislead readers into thinking aggregation is happening. Therefore, while the statement is technically allowed, it is better to use SELECT DISTINCT or remove the GROUP BY if no aggregation is required.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500