2006 Nov 07 7:12 PM
Hi All,
I want select second largest amount from a table . How i have to write a query for that?
Thanks,
Priya
2006 Nov 07 7:18 PM
You must write some extra logic for this:
data: begin of i_tbl occurs 0,
netwr like vbap-netwr,
end of i_tbl.
select netwr up to 2 rows from vbap into table i_tbl
order by netwr descending.
read table i_tbl index 2.
Well, I think you may need to get all of the data, then sort the amount column in descending order, then read line two of the internal table.
Regards,
Rich Heilman
2006 Nov 07 7:16 PM
2006 Nov 07 7:16 PM
You could:
SELECT * from table
into itab.
sort itab descending by field1.
read table itab index 2.
Rob
You'll have to check the syntax. I didn't.
Message was edited by: Rob Burbank
2006 Nov 07 7:18 PM
You must write some extra logic for this:
data: begin of i_tbl occurs 0,
netwr like vbap-netwr,
end of i_tbl.
select netwr up to 2 rows from vbap into table i_tbl
order by netwr descending.
read table i_tbl index 2.
2006 Nov 07 7:22 PM
2006 Nov 07 7:22 PM
2006 Nov 07 7:29 PM
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |