SQL Quiz: Running Totals, LAG & LEAD

This SQL quiz covers aggregate window functions and the offset functions LAG() and LEAD(). You will compute running totals and moving averages, compare each row with the previous one and run into the default window frame that surprises many developers when the sort order has ties.

कठिन 10 सवाल ~8 मिनट पास होने के लिए 80% SQLite

मोड चुनें

आप गेस्ट के तौर पर खेल रहे हैं: XP और streak सेव रखने के लिए साइन इन करें।

सैंपल सवाल

सवाल 1 / 10

What does this print?

CREATE TABLE sales (day INTEGER, amount INTEGER);
INSERT INTO sales VALUES (1, 10), (2, 20), (3, 5), (4, 15);
SELECT day, SUM(amount) OVER (ORDER BY day)
FROM sales
ORDER BY day;
जवाब दिखाएं

A. 1|10 2|30 3|35 4|50 With ORDER BY inside OVER, the sum runs from the first row up to the current one, giving a running total. Unlike GROUP BY, every row is kept.

इस क्विज़ में क्या है

  • Running totals with SUM(...) OVER (ORDER BY ...)
  • LAG and LEAD with offsets and default values
  • Frames: ROWS BETWEEN ... AND CURRENT ROW
  • The default RANGE frame and ties
  • Per-group running totals with PARTITION BY

अक्सर पूछे जाने वाले सवाल

क्या अकाउंट ज़रूरी है?

नहीं। कोई भी खेल सकता है। XP, streak, badge और हिस्ट्री सेव रखने के लिए साइन इन करें।

क्या मैं इसे दोबारा दे सकता हूं?

हां। आपका बेस्ट स्कोर सेव रहता है, और हर बार सवाल और जवाब शफ़ल होते हैं।