Vous êtes sur la page 1sur 1

ROWNUMBERING WITH AN ORDER BY CLAUSE One of the most often uses of the pseudo co umn rownum !s to p"o#!de se"!

$ num%e"s to the "eco"ds !n $ &ue"'( Th!s fe$tu"e !s )!de ' used !n "epo"ts to "ep"esent s'stem$t!c d!sp $' of !nfo"m$t!on( *o" !nst$nce L!st!n+ A Se ect "o)num, en$me, empno f"om emp-./ T$% e A ROWNUM ENAME EM0NO 111111111 1111111111 111111111 - 2ING 3456 7 BLA2E 3864 5 CLAR2 3347 9 :ONES 3;88 ; MARTIN 38;9 Ho)e#e", )hen )e o"de" th!s st$tement the "o)num +ets d!stu"%ed $s sho)n %e o) < L!st!n+ B $nd T$% e B=( L!st!n+ B se ect "o)num, en$me, empno f"om emp-. o"de" %' en$me/ T$% e B ROWNUM ENAME 111111111 1111111111 111111111 7 BLA2E 5 CLAR2 9 :ONES - 2ING ; MARTIN EM0NO 3864 3347 3;88 3456 38;9

As )e c$n see f"om $%o#e the emp o'ee n$mes d!d +et o"de"ed %ut the "o)num $ so +ot the )"on+ o"de"( The des!"ed "esu t )$s BLA2E h$#!n+ "o)num - , CLAR2 h$#!n+ $ "o)num of 7 $nd so on( To $ch!e#e th!s )e h$#e to oute" >o!n th!s t$% e )!th du$ th$t p"ocess fo"ces $ !mp !c!t o"de" on the "o)num $s sho)n %e o) < L!st!n+ C, T$% e C=( L!st!n+ C se ect "o)num, en$me, empno f"om emp-. $ , du$ d )he"e $(en$me ? d(dumm' <@= o"de" %' en$me/ T$% e C ROWNUM ENAME 1111111 1111111111 BLA2E 7 CLAR2 5 :ONES 9 2ING ; MARTIN EM0NO 111111111 3864 3347 3;88 3456 38;9

The t"!cA !s to do $n oute" >o!n )!th the co umn th$t 'ou )$nt to o"de" $nd th!s p"ocess does not d!stu"% the "o)num o"de"( In $dd!t!on to th$t !f the co umn !s of num%e" d$t$t'pe then one shou d m$Ae su"e to use TOBCHAR d$t$t'pe con#e"s!on funct!on(

Vous aimerez peut-être aussi