RE: Something similar to ROWNUM in Oracle

RE: Something similar to ROWNUM in Oracle

 

  

As of DB2 Version 7, try this:

SELECT EMPNO, ENAME FROM DEDBADM.EMP FETCH FIRST 5 ROW ONLY;


-----Original Message-----
From: DANIEL CALLAHAN
[mailto:db2udbdba-ezmlmshield-x8818269.[Email address protected]
Sent: Monday, June 14, 2004 10:40 AM
To: LazyDBA Discussion
Subject: Re: Something similar to ROWNUM in Oracle






Or you can add an identity column with a numeric increaser of one each time
a row gets inserted. and then use that as part of
the query.

Dan Callahan IT Specialist
603-472-4121 t/l 525-4121
[Email address protected]
[Email address protected]




"GrJohnson"
<db2udbdba-ezmlms
hield-x13146427.x To
[Email Address Removed] "LazyDBA Discussion"
a.com> <[Email address protected]

cc
06/14/2004 10:38
AM Subject
Re: Something similar to ROWNUM in
Oracle










You can use fetch first XX rows only.

select * from employee fetch first 5 rows only




Greg S. Johnson
Oracle/DB2 Database Administrator
Tomax Corporation
801-924-6297




"amit b " <db2udbdba-ezmlmshield-x39278066.[Email address protected]
06/14/2004 08:24 AM


To: "LazyDBA Discussion" <[Email address protected]
cc:
Subject: Something similar to ROWNUM in Oracle


Hi,

Can anyone tell me is there any syntax in DB2 similar to rownum in oracle.

Say in oracle i can give select * from employee where rownum > 5 or delete
from emp where rownum >6;
is there something similar to that in DB2.

Thanks,
Amit


---------------------------------------------------------------------
PLEASE CLICK REPLY-ALL TO SEND A REPLY TO EVERYONE
website: http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
For additional commands, e-mail: db2udbdba-[Email address protected]





---------------------------------------------------------------------
PLEASE CLICK REPLY-ALL TO SEND A REPLY TO EVERYONE
website: http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
For additional commands, e-mail: db2udbdba-[Email address protected]




---------------------------------------------------------------------
PLEASE CLICK REPLY-ALL TO SEND A REPLY TO EVERYONE
website: http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
For additional commands, e-mail: db2udbdba-[Email address protected]

DB2 & UDB email list listserv db2-l LazyDBA home page