A Window
is part of a window function specifying the window over which a window function operates.
Sequel::SQL::Window.new(partition: :col1) # (PARTITION BY col1) Sequel::SQL::Window.new(partition: [:col2, :col3]) # (PARTITION BY col2, col3) Sequel::SQL::Window.new(order: :col4) # (ORDER BY col4) Sequel::SQL::Window.new(order: [:col5, Sequel.desc(:col6)]) # (ORDER BY col5, col6 DESC) Sequel::SQL::Window.new(partition: :col7, frame: :all) # (PARTITION BY col7 ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) Sequel::SQL::Window.new(partition: :col7, frame: :rows) # (PARTITION BY col7 ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) Sequel::SQL::Window.new(partition: :col7, frame: {type: :range, start: current}) # (PARTITION BY col7 RANGE CURRENT ROW) Sequel::SQL::Window.new(partition: :col7, frame: {type: :range, start: 1, end: 1}) # (PARTITION BY col7 RANGE BETWEEN 1 PRECEDING AND 1 FOLLOWING) Sequel::SQL::Window.new(partition: :col7, frame: {type: :range, start: 2, end: [1, :preceding]}) # (PARTITION BY col7 RANGE BETWEEN 2 PRECEDING AND 1 PRECEDING) Sequel::SQL::Window.new(partition: :col7, frame: {type: :range, start: 1, end: [2, :following]}) # (PARTITION BY col7 RANGE BETWEEN 1 FOLLOWING AND 2 FOLLOWING) Sequel::SQL::Window.new(partition: :col7, frame: {type: :range, start: :preceding, exclude: :current}) # (PARTITION BY col7 RANGE UNBOUNDED PRECEDING EXCLUDE CURRENT ROW) Sequel::SQL::Window.new(window: :named_window) # you can create a named window with Dataset#window # (named_window)
Attributes
opts | [R] |
The options for this window. Options currently supported:
|
Public Class methods
Set the options to the options given
# File lib/sequel/sql.rb 1995 def initialize(opts=OPTS) 1996 @opts = opts.frozen? ? opts : Hash[opts].freeze 1997 freeze 1998 end