Subject | Re: [Firebird-Architect] Improving CTE with ANSI SQL2003 Window Functions |
---|---|
Author | Philippe Makowski |
Post date | 2008-04-09T06:43:50Z |
Adriano dos Santos Fernandes [08-04-08 20.11] :
but it is only a facility in case you wanted to use same window definition in more than
one OVER cause
> Philippe Makowski escreveu:ok I missed that
>> Adriano dos Santos Fernandes [08-04-08 19.46] :
>>
>>> What I don't understand and never see is the named "window definition",
>>> that starts with the word WINDOW.
>>>
>>>
>> I don't see the word WINDOW in the definition
>> cf http://tracker.firebirdsql.org/browse/CORE-1688
>> and http://en.wikipedia.org/wiki/Select_(SQL)
>> and
>> http://wwwdvs.informatik.uni-kl.de/courses/NEDM/WS0607/Vorlesungsunterlagen/NEDM.Chapter.06.Windows_and_Query_Functions_in_SQL.pdf
> In the tracker link, there is window_name. That's how you reference a
> named window.
>
> I'm not certainly, but I think it's more or less this:
>
> WITH OrdersRN AS
> (
> SELECT EmployeeID, Value,
> ROW_NUMBER() OVER(X) AS RowNum,
> COUNT(*) OVER(Y) AS Cnt
> FROM VOrders
> WINDOW X AS (PARTITION BY EmployeeID ORDER BY Value),
> Y AS (PARTITION BY EmployeeID)
> )
> SELECT EmployeeID, AVG(Value) AS Median
> FROM OrdersRN
> WHERE RowNum IN((Cnt + 1) / 2, (Cnt + 2) / 2)
> GROUP BY EmployeeID;
>
but it is only a facility in case you wanted to use same window definition in more than
one OVER cause
> But one window could reference others and then things become more complex.no, windows are independent from each other