Window Functions - Value Access Functions

📝 Window Functions - Value Access Functions

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

What is the primary advantage of using LAG() instead of a self-join to retrieve previous row values?**

A.

A) LAG() returns more columns

B.

B) LAG() automatically filters NULL values

C.

C) LAG() is more readable and efficient, avoiding the complexity of self-joins

D.

D) LAG() works with all data types without conversion

Question 2

What does the **LEAD()** window function primarily retrieve from an ordered set of rows?

A.

A) The previous row's value

B.

B) The next row's value

C.

C) The current row's value

D.

D) The average of surrounding rows

Question 3

What value does **LEAD()** return for the last row in a window?

A.

A) The first row's value

B.

B) Zero

C.

C) The maximum value in the partition

D.

D) NULL

Question 4

What is the primary difference between **FIRST_VALUE()** and **LAG()** in the context of window functions?

A.

A) **FIRST_VALUE()** returns the first row in the partition; **LAG()** returns the previous row relative to the current row

B.

B) **FIRST_VALUE()** requires a frame clause; **LAG()** does not

C.

C) **FIRST_VALUE()** can be used with **PARTITION BY**, but **LAG()** cannot

D.

D) **LAG()** is older and less efficient than **FIRST_VALUE()**

Question 5

What happens when you apply **FIRST_VALUE()** without an **ORDER BY** clause in the window specification?

A.

A) The function returns an error

B.

B) The function returns NULL for all rows

C.

C) The function operates on an undefined row order, producing unpredictable results

D.

D) The function treats all rows as equally valid and returns a random value

Question 6

When using **NTH_VALUE()**, what determines which value is considered the "nth" value?

A.

A) The position of the row in the original table

B.

B) The ordering specified in the **ORDER BY** clause of the window function

C.

C) The numerical suffix in the column name

D.

D) The number of partitions defined by **PARTITION BY**

Quiz Complete!

Score: 0 / 6