2008 Feb 11 7:26 AM
there is a field in internal table that contains salary of employees. How can I get the second highest salary and if there r two or more second highest salary , how can I get it?
2008 Feb 11 7:32 AM
Hi,
first u create one duplicate table with all thos entries.
then in that table. get the max value of the salary and then remove that field from the duplicate table and now try to find out the highest value in that table then after that find how many rows are there with that value then u can get all the second highest salaries..
if it is usefull plzz reward plzz dont forget to reward..
plz dont forget to reward plzzzz....
there is a field in internal table that contains salary of employees. How can I get the second highest salary and if there r two or more second highest salary , how can I get it?
2008 Feb 11 7:32 AM
Hi,
first u create one duplicate table with all thos entries.
then in that table. get the max value of the salary and then remove that field from the duplicate table and now try to find out the highest value in that table then after that find how many rows are there with that value then u can get all the second highest salaries..
if it is usefull plzz reward plzz dont forget to reward..
plz dont forget to reward plzzzz....
2008 Feb 11 7:36 AM
HI Tanuj
How about using sub query while using the select statement.
Eg:
DATA: g_mnr TYPE fcmnr.
SELECT MAX( mnr ) INTO g_mnr FROM t247
WHERE spras = sy-langu
AND mnr < ( SELECT MAX( mnr ) FROM t247
WHERE spras = sy-langu ).
WRITE:/ g_mnr.
In above example am trying to retreive second highest month.
Regards
Eswar
2008 Feb 11 7:52 AM
Hi tanuj joshi,
Try like this code.
Data:
begin of itab occurs 10,
name(20),
sal type i,
end of itab.
sort itab by sal descending.
read table itab index 2.
write: itab-sal,
'Is the second higest salary'.
Plzz reward if it is useful,
Mahi.
2008 Feb 11 8:01 AM
Hi tanuj joshi,
Try like this code.
>Data :
> sal1 type i,
> sal2 type i.
>
>Data:
> begin of itab occurs 10,
> name(20),
> sal type i,
> end of itab.
>
>
>sort itab by sal descending.
>
>
>loop at itab.
>
>at first.
> itab-sal = sal1.
>endat.
>
> if itab-sal ne sal1 and itab-sal ge sal2.
> write / itab-sal.
> itab-sal = sal2.
> else.
> exit.
> endif.
>
>endloop.
Plzz reward if it is useful,
Mahi.
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |