SELECT Failed. 3504: Selected non-aggregate values must be part of the associated group

Database

SELECT Failed. 3504: Selected non-aggregate values must be part of the associated group

I think I understand why this error would occur, but I do not understand why it is occuring with my query.

SELECT

   FIELD_1,

   FIELD_2,

   FIELD_3,

   FIELD_4,

   SUM(FIELD_5) AS CNT

FROM

   TABLE

WHERE

   FIELD_4 BETWEEN 200901 AND 201112

   AND

   (FIELD_1 = '1029' AND FIELD_2 = '02' AND FIELD_3 IN ('489889','488332','489890','489870'))

   OR

   (FIELD_1 = '5029' AND FIELD_2 = '01' AND FIELD_3 IN ('474812','474813'))

   OR

   (FIELD_1 = '1029' AND FIELD_2 = '03' AND FIELD_3 IN ('489894'))

GROUP BY 1,2.3,4

ORDER BY 2,3,4,1

Any help would be greatlly appreciated.

1 REPLY

Re: SELECT Failed. 3504: Selected non-aggregate values must be part of the associated group

The syntax of your Group By Clause is not correct. There is a "." instead of "," in between 2 & 3. Replacing the "." with "," will make it work.

GROUP BY 1,2,3,4