‎2019 May 24 2:44 PM
Hi,
I am writing the following select statement and it is returning wrong value.
Select max( QMNUM ) from QMEL into (lv_qmnum) groupby qmnum.
Is it because the field qmnum is of type char. I also tried without groupby.
Thanks,
Vinod.
‎2019 May 24 3:24 PM
Hi,
you should used Select group by otherwise it will be wrong anyway.
If you used aggregate function like(SUM,MAX....) with the group by you have to put rest of the field with group by close . I mean rest of the all field with group by.
"DEPT", SUM("SALARY") from"KABIL_PRACTICE"."DEMO_EMP"Groupby"DEPT";
"here with group by you have to put only 'DEPT' not SALARY. because SALARY goes with aggregate function.
Regards,
Nawa.
‎2019 May 24 4:44 PM
Read and analyze your code.
You are selecting the max value QMNUM inside a group formed by QMNUM, so, basically, you are doing a select single.. since QMNUM is the split criteria.
‎2019 May 24 8:45 PM
I don't have any error with the code you mention, and it does what any SQL developer would expect. A character field is not an issue for MAX:
DATA lv_qmnum TYPE qmel-qmnum.
SELECT MAX( qmnum ) FROM qmel INTO (lv_qmnum).
‎2019 May 25 1:01 PM