Hi
Below is the code
SELECT T1."DocNum",T1."DocEntry",
(Select "Location" from OLCT where "Code" = (Select Max(A0."LocCode") from PCH1 A0
inner join OPCH A1 On A0."DocEntry" = A1."DocEntry"
where A0."DocEntry" = T1."DocEntry" and A1."BPLId" = T2."BPLId"
)) As "Location"
FROM OJDT T0 inner join JDT1 T2 on T0."TransId" = T2."TransId"
inner join VPM2 T1 On T1."DocNum" = T2."CreatedBy"
group by T2."BPLId"
Thanks
Daniel WrightPosted Apr 24, 2025, 7:49 AM
Hi there! Thanks for providing the code snippet. The error in this case, "Error - T1.Docentry must ne in Group by Clause," occurs because when using a GROUP BY clause in SQL, all non-aggregated columns in the SELECT statement that are not included in the GROUP BY clause must be aggregated or be part of an aggregate function.
In your SQL query, the column T1."DocEntry" is selected but not included in the GROUP BY clause or aggregated. To resolve this error, you have a couple of options:
1. Include T1."DocEntry" in the GROUP BY clause:
2. Aggregate the T1."DocEntry" column if it's meant to be in the SELECT statement without being in the GROUP BY clause:
By making one of these adjustments, you should be able to avoid the "T1.Docentry must ne in Group by Clause" error and execute your SQL query successfully. If you have any more questions or need further clarification, feel free to ask!