When used in a select clause, the limit the maximum number of rows to return.When used in an ordered by clause, the limit applies to each of the items in the ordered list (after the ordering is executed). See Implicit Window Examples.
Without the limit clause, this query would return all customers. With the limit, it returns 10 customers, with an offset of 20. That is, it returns customers 20-30.
The above query keeps count of the number of students per department. Every time a student enrolls or leaves, the count changes and the query produces the entire list sorted on the count, sorted in descending order, and limited to the first two.The limit clause specifies that only the first two of the ordered lists of departments are returned by the query: the list of departments with the largest number of students, and the list of departments with the second largest number of students.
Copyright © TIBCO Software Inc. All Rights Reserved.