Content deleted Content added
Asilvering (talk | contribs) m Removing link(s) Wikipedia:Articles for deletion/Where (SQL) closed as delete (XFDcloser) |
m →RANK() window function: {{mono}} |
||
(One intermediate revision by the same user not shown) | |||
Line 259:
<code>ROW_NUMBER() OVER</code> may be used for a ''simple table'' on the returned rows, e.g. to return no more than ten rows:
<syntaxhighlight lang="
SELECT * FROM
( SELECT
Line 270:
</syntaxhighlight>
{{mono|ROW_NUMBER}} can be [[Nondeterministic algorithm|non-deterministic]]: if ''sort_key'' is not unique, each time you run the query it is possible to get different row numbers assigned to any rows where ''sort_key'' is the same. When ''sort_key'' is unique, each row will always get a unique row number.
=== RANK() window function ===
The <code>RANK() OVER</code> window function acts like {{mono|ROW_NUMBER}}, but may return more or less than ''n'' rows in case of tie conditions, e.g. to return the top-10 youngest persons:
<syntaxhighlight lang="
SELECT * FROM (
SELECT
|