Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Select querry for maximum value

Former Member
0 Likes
433

Hi,

I want to select fields A B C D from a database table TAB using some selection criteria from selection screen, but the greatest value of A has to be selected for all unique entries of B C and D. Please suggest an appropriate select querry.

PS: I cannot use SELECT and then DELETE ADJACENT DUPLICATES as it will effect performance in some cases.

Regards.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
400

Try using aggregate function MAX with SELECT statement.

MAX Returns the greatest value in the column determined by the database field f for the selected lines. Specifying DISTINCT does not change the result. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL .

Have a look at below link:

[Select Clause|http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select_c.htm]

I hope it helps.

Best Regards,

Vibha

Please mark all the helpful answers

2 REPLIES 2
Read only

Former Member
0 Likes
401

Try using aggregate function MAX with SELECT statement.

MAX Returns the greatest value in the column determined by the database field f for the selected lines. Specifying DISTINCT does not change the result. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL .

Have a look at below link:

[Select Clause|http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select_c.htm]

I hope it helps.

Best Regards,

Vibha

Please mark all the helpful answers

Read only

Former Member
0 Likes
400

hi Charles,

do this way


 select max( a ) from <table> into table itab where <conditons> ..
 

Regards,

Santosh