2009 May 27 3:34 AM
I need to create a sap query like using SELECT MAX(begda) statement.
Please teach me how...
Thank u in advance..
2009 May 27 5:01 AM
Hi,
you can use aggeragate functions in the SQL statements in ABAP. for your reference please check the below code snippet.
data: i_mara type standard table of mara.
select max( matnr ) from mara into table i_mara.
Regards,
Prabhu.
2009 May 27 5:11 AM
Hi Ella,
You can very well use the aggregate functions in sql which is usually a performance tuning technique.
A calculation that is made on several records or cells of data. SUM, AVG, MAX, MIN and COUNT are examples of aggregate functions that are used in spreadsheets and database programs.
MAX: returns the maximum value of the column
MIN: returns the minimum value of the column
AVG: returns the average value of the column
SUM: returns the sum value of the column
COUNT: counts values or lines as follows:
· COUNT( DISTINCT ) returns the number of different values in the column.
· COUNT( * ) returns the total number of lines in the selection.
Ex: DATA: fldate LIKE sbook-fldate,
count TYPE i,
avg TYPE p DECIMALS 2,
max TYPE p DECIMALS 2.
SELECT fldate COUNT( * ) AVG( luggweight ) MAX( luggweight )
FROM sbook
INTO (fldate, count, avg, max)
WHERE carrid = 'LH' AND
connid = '0400'
GROUP BY fldate.
WRITE: / fldate, count, avg, max.
ENDSELECT.
For further info:
http://help.sap.com/saphelp_nw04/helpdata/EN/fc/eb3990358411d1829f0000e829fbfe/content.htm
http://help.sap.com/abapdocu/en/ABAPSELECT_AGGREGATE.htm
Thanks and Regards
Srikant.P
Edited by: SRIKANTH P on May 27, 2009 9:41 AM
2009 May 27 5:14 AM
Pl. check the F1 help
tables: pa0001.
select max( begda ) from pa0001 into pa0001-begda.
write: pa0001-begda.