Skip to Content
0
Sep 22, 2014 at 07:22 AM

Problem with Aggregate function

29 Views

Hi experts,

i have a table as

counter value operation

1 100 40

1 100 60

2 200 60

from the above table , i want to fetch the data based on the max(counter) for the same operation.

i want my data like

counter value operation

1 100 40

2 200 60

i have writtern my query as follows

select * from afpo into table it_afpo WHERE matnr IN s_matnr

AND dwerk IN s_werks

AND ltrmi IN s_ltrmi

if it_afpo is not initial.

SELECT aufnr isdd isdz iedd iedz vornr ersda max( rmzhl) FROM afru

INTO CORRESPONDING FIELDS OF TABLE it_afru

FOR ALL ENTRIES IN it_afpo

WHERE aufnr = it_afpo-aufnr

AND vornr IN ('0040' , '0060') group by aufnr isdd isdz iedd iedz vornr ersda.

endif.

but problem is there with For All Entries statement.

without using for all entries , how to achieve this?.

would be grateful if somebody helps.

thanks in advance

regards

satish