View previous topic :: View next topic
|
Author |
Message |
nandakumar Warnings : 2 New User
Joined: 05 May 2005 Posts: 50
|
|
|
|
hi,
this is nandakumar,
Any one can plz tell me the db2 sqlquery for the following:
if a table contains 100 rows (that 100 records),how to fetch the
only last 10 records from the table(from 91st rec to 100th rec) |
|
Back to top |
|
|
harinadh
New User
Joined: 01 Sep 2004 Posts: 18
|
|
|
|
Suppose the table contains the fields Eno, Ename and Eno is the primary key then the query is
select * from Emp order by Eno desc fetch first 100 rows only; |
|
Back to top |
|
|
kumar_jalluri
New User
Joined: 02 Jun 2005 Posts: 24 Location: PUNE
|
|
|
|
if the table contains any field like serial number or emp number in serial order,
write the query
select * from emp order by sno desc fetch first 10 rows only. |
|
Back to top |
|
|
deepak dixit
New User
Joined: 02 Jun 2005 Posts: 1
|
|
|
|
hello sir,
sppose you have a three fields a b c in a table in some cases b is blank. at the time of disply if b is blank then the memory of b should be removed and a and c must be cocatenate lilke firstname middlename lastname. if middle name is not there. in db2 and db2 to vsm also.its a big proble for me i have allready face 2 times this problem if knows please tell me.
thanks |
|
Back to top |
|
|
badal
New User
Joined: 05 Sep 2004 Posts: 21
|
|
|
|
Hi,
use the function ROWID. all of u r problem will be solved.
hope u can find the query from udb book.
thanks. |
|
Back to top |
|
|
laxmi
New User
Joined: 24 May 2005 Posts: 9
|
|
|
|
By using scrollable cursors it is possible
by this we can move forward and backward and we can retreive specified set of records
to fetch last 10 records u have to use relagtive n option with FETCH
DECLARE CSR1 SENSITIVE STATIC SCROLL CURSOR
FOR SELECT FIRSTNAME , LASTNAME FROM EMP ;
FETCH RELATIVE 10 INTO :ARRAY
WHERE ARRAY IS WORKING STOREAGE VARIABLE DECLARED AS ARRAY |
|
Back to top |
|
|
|