SQL query: Nested Aggregate Functions Not Allowed error

1.6k Views Asked by At
Select PAYMENT.CONTRIBUTION_NO, CONTRIBUTION.CONTRIBUTION_NO,
SUM(
  count(*) *
  (
    select sum(contribution.CONTRIB_AMOUNT)
    from contribution 
    where CONTRIBUTION.CONTRIBUTION_NO= PAYMENT.CONTRIBUTION_NO
  )
) as GT
from contribution, payment
Group By PAYMENT.CONTRIBUTION_NO, CONTRIBUTION.CONTRIBUTION_NO

Sorry I am really new to SQL and I am Having trouble with this code, I got an error saying that nested aggregates functions are not allowed, can somebody help me please . . . Sorry for the trouble and I really appreciate the help . . . Basically I wanted to stored a Total Value from the Count multiplied to a specific value from a row since it is grouped according to Contribution ID I wanted to get the total and stored it in GT

0

There are 0 best solutions below