@@ -100,7 +100,9 @@ data WindowDefinition outer commons grp schemas params from where
100 WindowDefinition
100 WindowDefinition
101 :: SOP.SListI bys
101 :: SOP.SListI bys
102 => NP (Expression outer commons grp schemas params from) bys
102 => NP (Expression outer commons grp schemas params from) bys
103 -> [SortExpression outer commons grp schemas params from]
104 -> [SortExpression outer commons grp schemas params from]
104 -> WindowDefinition outer commons grp schemas params from
106 -> WindowDefinition outer commons grp schemas params from
106instance OrderBy WindowDefinition where
108instance OrderBy WindowDefinition where
@@ -127,7 +129,7 @@ the same partition as the current row.
128partitionBy
130partitionBy
129 :: SOP.SListI bys
131 :: SOP.SListI bys
130− => NP (Expression outer commons grp schemas params from) bys
132+ => NP (Expression outer commons grp schemas params from) bys -- ^ partitions
131 -> WindowDefinition outer commons grp schemas params from
133 -> WindowDefinition outer commons grp schemas params from
132partitionBy bys = WindowDefinition bys []
134partitionBy bys = WindowDefinition bys []
@@ -193,6 +195,7 @@ unsafeWindowFunctionN fun xs = UnsafeWindowFunction $ fun <>
193 parenthesized (renderCommaSeparated renderSQL xs)
195 parenthesized (renderCommaSeparated renderSQL xs)
195{- | rank of the current row with gaps; same as `rowNumber` of its first peer
197{- | rank of the current row with gaps; same as `rowNumber` of its first peer
196>>> printSQL rank
199>>> printSQL rank
@@ -200,6 +203,7 @@ rank :: WinFun0 ('NotNull 'PGint8)
200rank = UnsafeWindowFunction "rank()"
203rank = UnsafeWindowFunction "rank()"
202{- | number of the current row within its partition, counting from 1
205{- | number of the current row within its partition, counting from 1
203>>> printSQL rowNumber
207>>> printSQL rowNumber
204row_number()
208row_number()
@@ -207,6 +211,7 @@ rowNumber :: WinFun0 ('NotNull 'PGint8)
207rowNumber = UnsafeWindowFunction "row_number()"
211rowNumber = UnsafeWindowFunction "row_number()"
209{- | rank of the current row without gaps; this function counts peer groups
213{- | rank of the current row without gaps; this function counts peer groups
210>>> printSQL denseRank
215>>> printSQL denseRank
211dense_rank()
216dense_rank()
@@ -214,6 +219,7 @@ denseRank :: WinFun0 ('NotNull 'PGint8)
214denseRank = UnsafeWindowFunction "dense_rank()"
219denseRank = UnsafeWindowFunction "dense_rank()"
216{- | relative rank of the current row: (rank - 1) / (total partition rows - 1)
221{- | relative rank of the current row: (rank - 1) / (total partition rows - 1)
217>>> printSQL percentRank
223>>> printSQL percentRank
218percent_rank()
224percent_rank()
@@ -222,6 +228,7 @@ percentRank = UnsafeWindowFunction "percent_rank()"
223{- | cumulative distribution: (number of partition rows
229{- | cumulative distribution: (number of partition rows
224preceding or peer with current row) / total partition rows
230preceding or peer with current row) / total partition rows
225>>> printSQL cumeDist
232>>> printSQL cumeDist
226cume_dist()
233cume_dist()
@@ -230,6 +237,9 @@ cumeDist = UnsafeWindowFunction "cume_dist()"
231{- | integer ranging from 1 to the argument value,
238{- | integer ranging from 1 to the argument value,
232dividing the partition as equally as possible
239dividing the partition as equally as possible
241+>>> printSQL $ ntile 5
234ntile :: WinFun1 ('NotNull 'PGint4) ('NotNull 'PGint4)
244ntile :: WinFun1 ('NotNull 'PGint4) ('NotNull 'PGint4)
235ntile = unsafeWindowFunction1 "ntile"
245ntile = unsafeWindowFunction1 "ntile"