1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. SUM(amount) OVER (PARTITION BY account ORDER BY day) is…

Added 30 Nov -0001

SUM(amount) OVER (PARTITION BY account ORDER BY day) is used as a running total. Which frame does the default produce?

  1. RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which also includes rows tied on day Correct answer
  2. ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, counting only physical rows read
  3. RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING, which totals the whole partition
  4. ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING, a reverse running total by default

Correct answer

A. RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which also includes rows tied on day

17 views

MCQSEXAM

Explanation

Window frames default to RANGE UNBOUNDED PRECEDING TO CURRENT ROW whenever ORDER BY is present, so rows sharing a day value are included together and a running total can jump at ties. Specifying ROWS BETWEEN ... CURRENT ROW gives one increment per physical row instead. Without ORDER BY the frame covers the whole partition, so the same SUM becomes a grand total.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs