07-02-2007 9:24 AM
Hi ..
Using SELECT ...FROM ...UPTO <n> ROWS.. i can select first 10 rows
of a DB table ,now how can i select last 10 rows of DB table.
Please advise.
jahaan
07-02-2007 9:26 AM
Hi
First select all the rows from the DB table
SELECT * FROM db TAB INTO TABLE itab
sort the ITAB by the Key field decending
then take the first 10 records of that sorted ITAB and move into another internal table and use them
<b>Reward points for useful Answers</b>
Regards
Anji
07-02-2007 9:26 AM
Hi
First select all the rows from the DB table
SELECT * FROM db TAB INTO TABLE itab
sort the ITAB by the Key field decending
then take the first 10 records of that sorted ITAB and move into another internal table and use them
<b>Reward points for useful Answers</b>
Regards
Anji
07-02-2007 9:27 AM
SELECT ...FROM ...UPTO <n> ROWS.. ORDER BY <field name> DESCENDING.
regards
shiba dutta
07-02-2007 9:28 AM
Hi,
USE ORDERBY In the select statement in such a way that your last 10 rows become your first 10 rows and then use UPTO 10 rows.
Regards,
Sesh
07-02-2007 9:28 AM
last 10 rows on what condition?
create date? if yes then you have to have create date filed in the table to be able to do that
document number?
or some other condition?
07-02-2007 9:29 AM
*to get the last 10 recod fo the condition
SELECT *
INTO itab FROM <database table>
UP TO 10 ROWS ( where condition ) order by <fieldname> ascending.
regards,
Prabhu
Reward if it is helpful.
07-02-2007 9:32 AM
Use ORDER BY.
Eg.
SELECT *
INTO itab FROM MARA
UP TO 10 ROWS where werks in so_werks order by MATNR decending.
07-02-2007 9:48 AM
Wt the exact difference bt select single and select up to one record?