Rownum - sql pseudocolumns, PL-SQL Programming

ROWNUM

The ROWNUM returns a number representing the order in which a row was selected from the table. The first row selected has a ROWNUM of 1; the second row has a ROWNUM of 2, and so on. If the SELECT statement involves an ORDER BY clause, then the ROWNUMs are assigned to the retrieved rows before the sort is complete.

You can use the ROWNUM in an UPDATE statement to assign exclusive values to each row in a table. You can also use ROWNUM in the WHERE clause of a SELECT statement to the limit the number of rows retrieved, as shown:

DECLARE

CURSOR c1 IS SELECT empno, sal FROM emp

WHERE sal > 2000 AND ROWNUM < 10; -- returns 10 rows

The value of ROWNUM increase only whenever a row is retrieved, so the only significant use of ROWNUM in a WHERE clause is

... WHERE ROWNUM < constant;

Posted Date: 10/4/2012 3:43:52 AM | Location : United States







Related Discussions:- Rownum - sql pseudocolumns, Assignment Help, Ask Question on Rownum - sql pseudocolumns, Get Answer, Expert's Help, Rownum - sql pseudocolumns Discussions

Write discussion on Rownum - sql pseudocolumns
Your posts are moderated
Related Questions
Raise_application_error -  procedure of package DBMS_STANDARD , allows to issue an user_defined error messages by stored sub-program or database trigger.

Example of Table Literal - SQL Example: A Table Literal (correct version) VALUES ('S1', 'C1', 'Anne'), ('S1', 'C2', 'Anne'), ('S2', 'C1', 'Boris'), ('S3', 'C3'

Nested Tables versus Index-by Tables The Index-by tables and nested tables are just similar. For e.g.  They have similar structure and their individual elements are accessed in

Example of Null operator - NiNo Rule If we wanted to make HIGHER_OF adhere to "NULL in, NULL out"-let's call it the NiNo rule-we would have to write something like what is sho

Relational Operators and Logical Operators It prepares the ground for subsequent sections in which each specific relational operator is paired with its logical counterpart, su

Introduction Oracle 9i - it was made public in the year 2001 with over 400 features, and graphics, it has merged the traditional business with modern internet application

Product-specific Packages The Oracle and different Oracle tools are supplied with the product-specific packages which help you to build the PL/SQL-based applications. For illus

Transaction context As the figure shows, the major transaction shares its context with the nested transactions, but not with the autonomous transactions. Similarly, If one aut

Multiple Assignment- SQL SQL supports multiple assignment to local variables and also applies multiple assignment semantics in SET clauses of UPDATE statements, but does not

User-Defined Exceptions The PL/SQL defines the exceptions of your own. Dissimilar to the predefined exceptions, the user-defined exceptions should be declared and should be rai