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
Short-Circuit Evaluation When computing a logical expression, the PL/SQL uses short-circuit evaluation. That is, the PL/SQL stops computing the expression as soon as the result

Using a join on 2 tables, select all columns and 10 rows from the 2 tables without the use of a Cartesian product. Query: SELECT * FROM EMPLOYEE1 E JOIN STAFF S ON E.EMP_

Using SET TRANSACTION You use the SET TRANSACTION statement to begin the read-only or read-write transaction, start an isolation level, or assign your present transaction to a

IS NULL Operator The IS NULL operator returns the Boolean value TRUE whenever its operand is null or FALSE if it is not null. The comparisons including the nulls always yield NU

Project Description: I want to write some SQL statements. The things I need are between pages 5-7. The only problem is that i want it till tomorrow. Skills required is SQL

%ISOPEN The Oracle closes the SQL cursor automatically after executing its related SQL statement. As a result, the %ISOPEN forever yields FALSE.

Cursors The Oracle uses work areas to execute the SQL statements and to store process information. A PL/SQL construct known as the cursor. Let's you assume name a work area and

Relational Operators The relational operators permit you to compare randomly complex expressions. The list below provides the meaning of each operator:

Keyword and Parameter Description: boolean_expression: This is an expression which results the Boolean value TRUE, FALSE, & NULL. It is related with a series of statement

Order of Evaluation When you do not use the parentheses to specify the order of evaluation, the operator precedence determine the order. Now compare the expressions below: NOT