Content deleted Content added
→Limiting result rows: Tarvin, thanks for making me read up on SQL 2003. I have clarified a few points. |
→Limiting result rows: Fix typo, add sections |
||
Line 100:
* By intoducing ''window functions'' to the SELECT-statement
=== ROW_NUMBER() window function ===
Several ''window functions'' exist. <code>ROW_NUMBER() OVER</code> may be used for a ''simple limit'' on the returned rows. E.g., to return no more than ten rows:
Line 112 ⟶ 113:
</pre>
=== RANK() window function ===
The <code>RANK() OVER</code> window function acts like ROW_NUMBER, but may return more than ''n'' rows in case of tie conditions. E.g., to return the top-10 youngest persons:
Line 129 ⟶ 132:
The above code could return more than ten rows, e.g. if there are eleven people of the same age.
=== Non-standard syntax ===
Not all DBMSes support the mentioned window functions, and non-standard syntax has to be used. Below, variants of the ''simple limit'' query for different DBMSes are listed:
|