Your true issue was not clear for me.
You asked similar, but different questons on your first and second posts.
Quote:
|
inwhich i want to take 50001's last 2 records one by one.
|
Quote:
|
i want to selct e02's last 3 records(transaction) & i want to display those 3 records in map(cics).
|
Anyhow, you can select last <n> rows by combination of "ORDER BY ... DESC" and "FETCH FIRST <n> ROWS ONLY", like ...
SELECT amount FROM ... WHERE acco_no = 50001 ORDER BY sno DESC FETCH FIRST 2 ROWS ONLY;
or
SELECT salary FROM ... WHERE eno = 'e02' ORDER BY sno DESC FETCH FIRST 3 ROWS ONLY;
If you used cursor, "FETCH FIRST <n> ROWS ONLY" might be unnecessary.
Quote:
sno acco_no amount
6 50001 1500-----> i want to move this record to variable1
3 50001 2500-----> i want to move this record to variable2
|
Declare cursor, OPEN cursor then repeat two FETCH statements, like...
FETCH ... INTO variable1;
FETCH ... INTO variable2;