HomeInterview QuestionsHow do you use GROUP BY?

How do you use GROUP BY?

🟢 Easy Conceptual Fresher level
1Times asked
Jul 2026Last seen
Jul 2026First seen

💡 Model Answer

The basic syntax for GROUP BY in SQL is:

SELECT column1, column2, AGG_FUNC(column3)

FROM table_name

GROUP BY column1, column2;

Here, column1 and column2 are the columns you want to group by, and AGG_FUNC is an aggregate function such as SUM, AVG, COUNT, MAX, or MIN applied to column3. The GROUP BY clause must list all non-aggregated columns in the SELECT clause. The query will return one row for each distinct combination of the grouped columns, with the aggregate value computed for each group.

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