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 with aggregate function MAX

Former Member
0 Likes
821

Hi,

Can I write a query like:

select field1 field2 MAX( field3 )

from z_table

into table itab

for all entries in itab2

where field1 = itab2-field1

and field2 = itab2-field2.

In the above case all the 3 fields are key fields.

Thanks in advance.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
772

hi

try this

select , max() as field2, min() as field3, ...

from........

6 REPLIES 6
Read only

Former Member
0 Likes
772

Why dont you try to execute it and check if its working?

Read only

Former Member
0 Likes
773

hi

try this

select , max() as field2, min() as field3, ...

from........

Read only

Former Member
0 Likes
772

Hi,

I did try it.. but got an error like: "The field "z_table~field2" from the select list is missing in the GROUP BY clause" but my aggregate funtion is used only for the field3..... So, I wanted to know if anybody has come across such a query....

Thanks,

Read only

0 Likes
772

If there is only one max function in the select you do not need a group by. In your case, you need one. But this was told you by the compiler....

Read only

0 Likes
772

Check online help for aggregate functions. All selected columns which are not used as aggregate functions must appear in the GROUP BY clause.

Thomas

Read only

Former Member
0 Likes
772

Hi All,

The code works fine after the group by clause.

Thanks for your help.

Thanks,

Sindhu