Window Functions · SQL SQL

What is the primary difference between using a standard aggregate function with GROUP BY and using a window function in SQL?

Practice question from Window Functions (SQL SQL), with the correct answer and a step-by-step solution.

easy · MCQ · Q-118ACD

What is the primary difference between using a standard aggregate function with GROUP BY and using a window function in SQL?

  1. A.Window functions reduce the total number of rows returned in the result set, whereas GROUP BY does not.
  2. B.Window functions perform calculations across a set of table rows that are somehow related to the current row without collapsing the rows into a single group.Correct answer
  3. C.GROUP BY can be used with analytic clauses, but window functions cannot be combined with aggregate expressions.
  4. D.Standard aggregate functions can access previous and subsequent rows directly, whereas window functions cannot.

Solution

Unlike GROUP BY which collapses multiple rows into a single summary row per group, window functions compute an aggregate or rank for each row while preserving the individual rows in the output result set.

More from Window Functions

All of Window Functions

Practise more SQL

Sign up free for adaptive practice on this chapter, with instant feedback and hints on every question.

Start practising free

Free to start · No credit card needed