QuizzesIntroduction to SQL Window Functions
beginner
databases

Introduction to SQL Window Functions

A beginner's quiz on understanding and using SQL window functions.

15 minutes 15 questions Pass at 70%
Time Limit
15 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

15 questions on Introduction to SQL Window Functions. Work through them here, then start the quiz to answer them and see your score.

  1. 1.What is the primary purpose of SQL window functions?

    • ATo delete duplicate rows from a table
    • BTo create new tables from existing data
    • CTo perform calculations across a set of table rows related to the current row
    • DTo update multiple rows in a table
  2. 2.Which clause is used to define the window for a window function?

    • AORDER BY
    • BGROUP BY
    • CWHERE
    • DPARTITION BY
  3. 3.Which SQL function can be used to calculate a running total?

    • AROW_NUMBER()
    • BLAG()
    • CSUM()
    • DRANK()
  4. 4.What does the ROW_NUMBER() function do?

    • AReturns the previous row value
    • BFinds the average of a column
    • CAssigns a unique number to each row within a partition
    • DCalculates the sum of a column
  5. 5.In SQL, what does the RANK() function return?

    • AThe average of a column
    • BThe sum of a column
    • CThe total number of rows
    • DThe rank of a row within its partition
  6. 6.Which window function would you use to access data from the previous row?

    • ALAST_VALUE()
    • BLEAD()
    • CFIRST_VALUE()
    • DLAG()
  7. 7.What is the difference between ROW_NUMBER() and RANK()?

    • ABoth may have gaps
    • BROW_NUMBER() assigns unique numbers, RANK() may have gaps
    • CBoth assign unique numbers
    • DRANK() assigns unique numbers, ROW_NUMBER() may have gaps
  8. 8.Which function would you use to find the first value in a window?

    • AFIRST_VALUE()
    • BLAST_VALUE()
    • CLEAD()
    • DLAG()
  9. 9.What does the DENSE_RANK() function do differently than RANK()?

    • ADENSE_RANK() is faster
    • BDENSE_RANK() does not leave gaps in ranking
    • CDENSE_RANK() only works with numeric columns
    • DDENSE_RANK() assigns random numbers
  10. 10.Which clause is used to order rows within a window function?

    • ADISTINCT
    • BORDER BY
    • CGROUP BY
    • DPARTITION BY
  11. 11.What is the purpose of the LEAD() function?

    • ATo find the maximum value
    • BTo rank rows
    • CTo calculate the sum of a column
    • DTo access data from the next row
  12. 12.How does NTILE() function divide data?

    • AInto a specified number of groups
    • BBy unique values
    • CBy data type
    • DBy column length
  13. 13.Which window function would you use to find the last value in a window?

    • ALAG()
    • BLEAD()
    • CFIRST_VALUE()
    • DLAST_VALUE()
  14. 14.What does the CUME_DIST() function calculate?

    • ASum of a column
    • BCumulative distribution of a value
    • CAverage of a column
    • DTotal number of rows
  15. 15.Which function would you use to assign a sequential integer to rows in a result set?

    • ADENSE_RANK()
    • BRANK()
    • CROW_NUMBER()
    • DCUME_DIST()