Window Functions - Aggregate Functions

📝 Window Functions - Aggregate Functions

Total Questions: 6
Click an answer to select it, then click "Check Answers" to see your results.
Question 1

Window functions in SQL differ from GROUP BY primarily because they:

A.

A) Collapse rows into groups

B.

B) Return results for every row without collapsing data

C.

C) Require subqueries for partitioning

D.

D) Only work with ranking functions

Question 2

What is the primary purpose of using the **OVER()** clause with the **SUM()** aggregate function?

A.

A) To group rows before aggregation

B.

B) To sort the result set by the aggregated column

C.

C) To filter rows based on aggregate values

D.

D) To compute calculations across a set of rows while retaining individual row details

Question 3

What does the **AVG()** function return when used as a basic aggregate without window clauses?

A.

A) A cumulative average for each row

B.

B) An average reset by partitions

C.

C) A single average value across all rows

Question 4

What distinguishes basic **AVG(Price)** from **AVG(Price) OVER ()**?

A.

A) Basic returns row-level values

B.

B) Window version returns a single scalar

C.

C) Basic aggregates to one value; window repeats it per row

D.

D) They produce identical results

Question 5

What is the key difference between using COUNT() with GROUP BY versus COUNT() OVER (PARTITION BY)?

A.

A) GROUP BY returns one row per group; PARTITION BY returns all rows with aggregates repeated

B.

B) PARTITION BY returns one row per group; GROUP BY returns all rows

C.

C) They are functionally identical

D.

D) PARTITION BY only works with numeric columns

Question 6

What is the primary advantage of using **MIN** as a window function instead of a traditional GROUP BY aggregate?

A.

A) Window functions execute faster than GROUP BY queries

B.

B) Window functions return all rows with partition-level aggregates, while GROUP BY reduces rows to one per group

C.

C) Window functions eliminate the need for JOIN operations

D.

D) Window functions automatically sort results in descending order

Quiz Complete!

Score: 0 / 6