Using a CTE to Aggregate a Column

  • The sample data below details my issue!! I want to avoid using a cursor any way I can, but this is proving to be difficult with how this data is structured.

    I need to SUM(PaymentAmount) by LoanapplicationID. Mulitple ApplicantID's can use the Same LoanApplicationID in this scenario. Any ideas are welcome. Thanks

    ApplicantId loanapplicationid PaymentAmount fundingdate

    262636 188670 5588.00 2012-08-06 00:00:00.000

    262635 188670 700.00 2012-08-06 00:00:00.000

    262635 188670 5333.00 2012-08-06 00:00:00.000

    266141 191204 2000.00 2012-08-08 00:00:00.000

    266140 191204 1667.00 2012-08-08 00:00:00.000

    266140 191204 6420.00 2012-08-08 00:00:00.000

    266240 191277 2000.00 2012-08-07 00:00:00.000

    266239 191277 1667.00 2012-08-07 00:00:00.000

    266239 191277 6420.00 2012-08-07 00:00:00.000

  • Thanks, this works great!! I completely over looked the "over" clause.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply