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
Create the four tables and populate them with the given data. Answer the following queries in SQL. 1. Get all part-color/part-city combinations. Note: Here and subsequently, the

Multiset types - SQL An SQL multiset is what in mathematics is also known as a bag-something like a set except that the same element can appear more than once. The body of an

write the program for traffic control system with 10 second, 15 secod, and 20 second delay

Implicit Cursor is declared and used by the oracle environment internally. while the explicit cursor is declared and used by the external user. more over implicitly cursors are no

How Bulk Binds Improve Performance The assigning of values to the PL/SQL variables in SQL statements is known as binding. The binding of the whole collection at once is know

Projection and Existential Quantification - SQL Intuitively it might seem that projection in SQL is simply a matter of specifying the required columns in the SELECT clause, a

Operators on Tables and Rows Row Extraction TUPLE FROM r, SQL has row subqueries. These are just like scalar subqueries except that they may specify more than one column.

Forward Declarations The PL/SQL needs that you declare an identifier before using it. And hence, you should declare a subprogram before calling it. For illustration, the decla

Using RENAME in combination with JOIN - SQL Example gives pairs of ids of students having the same name, by joining two renamings of IS_CALLED. Example gives an equivalent ex

Explicit Cursors The set of rows returned by the query can include zero, one, or multiple rows, depending on how many rows meet your search criteria. Whenever a query returns