Select statement
Hi,
I'm accessing one of the HR table. I have to take to second last record when condition meet in WHERE clause.
Can u guys let me know what the best way to code my requirement?
Pls Help.
Hi !!
Select * from <table> into <itab> where .......
Sort <itab> by <key> descending.
Read <itab> index 2.
Regards,
Sudhir/Mohit
Thanks 2Abapers
Hi !!
Select * from <table> into <itab> where .......
Sort <itab> by <key> descending.
Read <itab> index 2.
Regards,
Sudhir/Mohit
Just a thought, and to rekindle the argument between select single and select .... up to.....
I have always argued that 'SELECT SINGLE' is different from 'SELECT ... UP TO 1 ROWS', in that select single returns the first record it comes across where as UP TO performs all the required processing and then returns the specified number of records from the result set, so how about this (and I haven't checked the syntax....)
Select ...
into table t_table
from tab
up to 2 rows
where .... condition
ordered by sort-key descending.
Read t_table index 1.....
Now... if Select Single and Select Up To 1 rows are identical, I'm pretty certain this wouldn't give you what you want....
Any comments ??
R
Hi R !!
Your code does work and provides the reqd. ouput, by changing
Read t_table index 1.....
to
Read t_table index 2.....
But we guess thats just a typin mistake ....
Regards,
Sudhir/Mohit
[/code]