Teradata Database: Selected non-aggregate values must be part of the associate group 3504

Database

Teradata Database: Selected non-aggregate values must be part of the associate group 3504

Need help with logic. Sum worked before, but added new relationship (Provider_CDC_Assignment)
SELECT DHS_Payment_Detail.Person_Id,
DHS_Payment_Billing_Detail.Provider_Id,
DHS_Payment_Detail.Service_Type_Code,
cvDHS_Provider_CDC_Assignment.Provider_Related_Flag,
Sum(DHS_Payment_Billing_Detail.Units_Paid) AS Hours_Paid

FROM cvDHS_Provider_CDC_Assignment INNER JOIN (DHS_Payment_Billing_Detail INNER JOIN
DHS_Payment_Detail ON DHS_Payment_Billing_Detail.Payment_Id = DHS_Payment_Detail.Payment_Id) ON (cvDHS_Provider_CDC_Assignment.Provider_Id = DHS_Payment_Billing_Detail.Provider_Id) AND (cvDHS_Provider_CDC_Assignment.Case_Id = DHS_Payment_Detail.Case_id) AND (cvDHS_Provider_CDC_Assignment.Child_Person_Id = DHS_Payment_Detail.Person_Id)

WHERE Assistance_Type_Code='CDCS' AND Pay_Period_Begin_Date > '2009-09-26' AND
Pay_Period_Begin_Date < '2010-09-13' AND DHS_Payment_Detail.Service_Type_Code = 'DA'

GROUP BY Person_Id, DHS_Payment_Billing_Detail.Provider_Id, DHS_Payment_Detail.Service_Type_Code;
1 REPLY

Re: Teradata Database: Selected non-aggregate values must be part of the associate group 3504

Max,

You added a new column to your SELECT list but did not include it in your GROUP BY clause. If you add cvDHS_Provider_CDC_Assignment.Provider_Related_Flag to the GROUP BY clause you should be good to go.