I am sorry i not am aware of sql coding but we can achieve the result by using control break events by the following program, just copy paste in se38
DATA : it TYPE TABLE OF ekpo,
wa TYPE ekpo.
DATA : count TYPE ekpo-netwr VALUE 0,
count1 TYPE ekpo-netwr VALUE 0,
count2 TYPE ekpo-netwr VALUE 0.
SELECT-OPTIONS : s_ebeln FOR wa-ebeln.
SELECT * FROM ekpo INTO TABLE it
WHERE ebeln IN s_ebeln.
SORT it BY ebeln.
LOOP AT it INTO wa.
WRITE : / wa-ebeln, wa-ebelp, wa-netwr.
count = count + wa-netwr.
count1 = count1 + 1.
AT END OF ebeln.
IF sy-subrc = 0.
WRITE :/ 'THE TOTAL OF NETWR',count.
count2 = count / count1.
WRITE :/ 'THE AVERAGE OF NETWR',count2.
CLEAR count.
CLEAR count1.
CLEAR count2.
ENDIF.
ENDAT.
ENDLOOP.