
|
If you were logged in you would be able to see more operations.
|
|
|
Time Tracking:
Issue & Sub-Tasks
Issue Only
Issue & Sub-Tasks
Issue Only
|
|
|
|
After CTE, it would be nice to have ANSI SQL Window Functions
SQL2003 allows for a window_clause in aggregate function calls, the addition of which makes those functions into window functions.
SQL2003 specifies the following syntax for window functions:
FUNCTION_NAME(expr) OVER {window_name|(window_specification)}
window_specification ::= [window_name][partitioning][ordering][framing]
partitioning ::= PARTITION BY value [, value...] [COLLATE collation_name]
ordering ::= ORDER [SIBLINGS] BY rule [, rule...]
rule ::= {value|position|alias} [ASC|DESC] [NULLS {FIRST|LAST}]
framing ::= {ROWS|RANGE} {start|between} [exclusion]
start ::= {UNBOUNDED PRECEDING|unsigned-integer PRECEDING|CURRENT ROW}
between ::= BETWEEN bound AND bound
bound ::= {start|UNBOUNDED FOLLOWING|unsigned-integer FOLLOWING}
exclusion ::= {EXCLUDE CURRENT ROW|EXCLUDE GROUP
|EXCLUDE TIES|EXCLUDE NO OTHERS}
List of Window Functions
CUME_DIST( ) OVER {window_name|(window_specification)} : Calculates the cumulative distribution, or relative rank, of the current row to other rows in the same partition
DENSE_RANK( ) OVER {window_name|(window_specification)} : Assigns a rank to each row in a partition, which should be ordered in some manner. The rank for a given row is computed by counting the number of rows preceding the row in question, and then adding 1 to the result. Rows with duplicate ORDER BY values will rank the same. Unlike the case with RANK( ), gaps in rank numbers will not result from two rows sharing the same rank.
RANK( ) OVER {window_name|(window_specification)} : Assigns a rank to each row in a partition, which should be ordered in some manner. The rank for a given row is computed by counting the number of rows preceding the row in question, and then adding 1 to the result. Rows with duplicate ORDER BY values will rank the same, and will lead to subsequent gaps in rank numbers.
PERCENT_RANK( ) OVER ({window_name|(window_specification)} : Computes the relative rank of a row by dividing that row's rank less 1 by the number of rows in the partition, also less 1
ROW_NUMBER( ) OVER ({window_name|(window_specification)} : Assigns a unique number to each row in a partition.
|
|
Description
|
After CTE, it would be nice to have ANSI SQL Window Functions
SQL2003 allows for a window_clause in aggregate function calls, the addition of which makes those functions into window functions.
SQL2003 specifies the following syntax for window functions:
FUNCTION_NAME(expr) OVER {window_name|(window_specification)}
window_specification ::= [window_name][partitioning][ordering][framing]
partitioning ::= PARTITION BY value [, value...] [COLLATE collation_name]
ordering ::= ORDER [SIBLINGS] BY rule [, rule...]
rule ::= {value|position|alias} [ASC|DESC] [NULLS {FIRST|LAST}]
framing ::= {ROWS|RANGE} {start|between} [exclusion]
start ::= {UNBOUNDED PRECEDING|unsigned-integer PRECEDING|CURRENT ROW}
between ::= BETWEEN bound AND bound
bound ::= {start|UNBOUNDED FOLLOWING|unsigned-integer FOLLOWING}
exclusion ::= {EXCLUDE CURRENT ROW|EXCLUDE GROUP
|EXCLUDE TIES|EXCLUDE NO OTHERS}
List of Window Functions
CUME_DIST( ) OVER {window_name|(window_specification)} : Calculates the cumulative distribution, or relative rank, of the current row to other rows in the same partition
DENSE_RANK( ) OVER {window_name|(window_specification)} : Assigns a rank to each row in a partition, which should be ordered in some manner. The rank for a given row is computed by counting the number of rows preceding the row in question, and then adding 1 to the result. Rows with duplicate ORDER BY values will rank the same. Unlike the case with RANK( ), gaps in rank numbers will not result from two rows sharing the same rank.
RANK( ) OVER {window_name|(window_specification)} : Assigns a rank to each row in a partition, which should be ordered in some manner. The rank for a given row is computed by counting the number of rows preceding the row in question, and then adding 1 to the result. Rows with duplicate ORDER BY values will rank the same, and will lead to subsequent gaps in rank numbers.
PERCENT_RANK( ) OVER ({window_name|(window_specification)} : Computes the relative rank of a row by dividing that row's rank less 1 by the number of rows in the partition, also less 1
ROW_NUMBER( ) OVER ({window_name|(window_specification)} : Assigns a unique number to each row in a partition.
|
Show » |
|
http://umitanuki.net/pgsql/wfv03/design.html
and this one for a good introduction and summary on this complex topic
http://wwwdvs.informatik.uni-kl.de/courses/NEDM/WS0607/Vorlesungsunterlagen/NEDM.Chapter.06.Windows_and_Query_Functions_in_SQL.pdf
this ticket deserves a higher priority. Even if only partially implemented those features would significantly enhance the toolkit of OLAP users of Firebird.