juniorSQL

What is GROUP BY?

Updated May 17, 2026

Short answer

GROUP BY groups rows sharing same values.

Deep explanation

It is used with aggregate functions like COUNT, SUM, AVG to summarize data.

Real-world example

Counting employees per department.

Common mistakes

  • Selecting non-aggregated columns not in GROUP BY.

Follow-up questions

  • Can GROUP BY be used without aggregation?
  • What is difference between GROUP BY and DISTINCT?

More SQL interview questions

View all →