Can anyone please advise on how to go about writing a SQL query to include the sum for multiple fields across multiple rows by group. I'm using the below query, but it keeps saying that the fields "in the select line are invalid because it is not contained in either an aggregate function or the GROUP BY clause."
Select ClaimId,InternalICN,BilledAmt,
Sum(PayAmt) as TotPayAmt,Sum(COBAmt) as TotCOBAmt,Sum(PrePayAmt) as
TotPrePayAmt
from CAIDEnc.IntEncTracking.EncounterList
where BypassFlag = 0 and
BypassReason = 0
group by ClaimId, InternalICN
Any advice would be greatly appreciated. Thanks!