I want build a sum in a window based on an expression, in in this expression I want reference a value from current row. How can I do that?
I expected in the code above always 1 as result. asked 17 May '12, 16:47 mikron |
For an idea of how to do this, see Example 14 in this whitepaper. answered 17 May '12, 17:24 Glenn Paulley I thought about mentioned approach with two windows, how it pointed in example 14, but I didn't see, how I can apply that. My trouble is to refer to a value from current result row (not current row in window) in an expression, that used in sum. In other words, I want to access a value from current result row and a value from current window row.
(18 May '12, 14:03)
mikron
Replies hidden
Currently, you can't do that within the same window function because the semantics of the function are a consequence of the definition of the window, which, if ORDER BY is not specified, is from unbounded preceding to current row. Today, you have to recompose the expression you're trying to compute and compute it using different window functions. Recently, the SQL standard committee approved extensions that appear in SQL:2011 that permit you to refer directly to a specific value, like the value of the attribute at the current row. But I'm not aware of any product that supports that new syntax yet.
(18 May '12, 14:13)
Glenn Paulley
|