Window Functions
# StreamSQL Window Functions
Window functions provide window-related information.
# WINDOW_START - Window Start Time
Syntax: window_start()
Description: Returns the start time of the current window.
Incremental Calculation: ✅ Supported
Example:
SELECT device, window_start() as window_begin, avg(temperature) as avg_temp
FROM stream
GROUP BY device, TumblingWindow('10s')
2
3
# WINDOW_END - Window End Time
Syntax: window_end()
Description: Returns the end time of the current window.
Incremental Calculation: ✅ Supported
Example:
SELECT device, window_end() as window_finish, avg(temperature) as avg_temp
FROM stream
GROUP BY device, TumblingWindow('10s')
2
3
# Extended Window Functions
Extended window functions provide more window-related functionality.
# ROW_NUMBER - Row Number Function
Syntax: row_number() OVER (ORDER BY col)
Description: Assigns a unique row number to each row in the result set.
Incremental Calculation: ✅ Supported
# FIRST_VALUE - First Value Function
Syntax: first_value(col) OVER (ORDER BY col)
Description: Returns the value from the first row in the window.
Incremental Calculation: ✅ Supported
# LEAD - Lead Function
Syntax: lead(col, offset, default_value) OVER (ORDER BY col)
Description: Returns the value from the Nth row after the current row.
Incremental Calculation: ✅ Supported
# NTH_VALUE - Nth Value Function
Syntax: nth_value(col, n) OVER (ORDER BY col)
Description: Returns the value from the Nth row in the window.
Incremental Calculation: ✅ Supported
# 📚 Related Documentation
- Aggregate Functions - Learn detailed usage of aggregate functions
- Analytical Functions - Learn detailed usage of analytical functions
- SQL Reference - View complete SQL syntax reference