Window Functions · Question 3 · Easy
Table DailySales: day_no | amount 1 | 100 2 | 250 3 | 150 4 | 300 What does this query return (day_no, total)?
SELECT day_no,
SUM(amount) OVER (ORDER BY day_no)
FROM DailySales
ORDER BY day_no;
- 1, 800; 2, 800; 3, 800; 4, 800
- 1, 100; 2, 350; 3, 500; 4, 800
- 1, 100; 2, 250; 3, 150; 4, 300
- 1, 100; 2, 350; 3, 400; 4, 450
Answer and explanation
Answer: B. 1, 100; 2, 350; 3, 500; 4, 800
Explanation: With ORDER BY inside OVER, SUM becomes a running total: each row gets the sum of all rows up to and including itself. 100, then 100 + 250 = 350, then 500, then 800.
Previous: Table DailySales: day_no | amount 1 | 100 2 | 250 3 | 150 4 | 300 What does… · Next: Table Scores: player | team | runs Arjun | Royals | 82 Bhuvan | Royals | 82…
Practise window functions
Try a fresh set of window functions questions with an explanation after every answer, free and without signing up: Window Functions practice. Or sit a full placement mock test.
More window functions questions
- Three students are tied on the highest marks. Which function, used with OVER…
- Table DailySales: day_no | amount 1 | 100 2 | 250 3 | 150 4 | 300 What does…
- Table Scores: player | team | runs Arjun | Royals | 82 Bhuvan | Royals | 82…
- What does PARTITION BY do inside an OVER clause?
- Table DailySales: day_no | amount 1 | 100 2 | 250 3 | 150 4 | 300 What does…
- Table Scores: player | team | runs Arjun | Royals | 82 Bhuvan | Royals | 82…
- Table Results: student | section | marks Aditi | A | 92 Bharti | A | 92 Chetna…
- Table DailySales: day_no | amount 1 | 100 2 | 250 3 | 150 4 | 300 What does…
- Table Wallet: txn_id | holder | amount 1 | Tara | 500 2 | Uday | 200 3 | Tara…
- Table Scores: player | team | runs Arjun | Royals | 82 Bhuvan | Royals | 82…
More sql practice
NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT · Tables, Keys & Constraints · DML & Transactions · SELECT, WHERE & ORDER BY · SQL Joins · Aggregates & GROUP BY
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge