Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Sum amount fields by distinct ID fields and Item Type Fields

David HorneNov 9 2024 — edited Nov 9 2024

Hi,

I use an Oracle PeopleSoft Query Manager tool that doesn't let me write raw SQL, but does allow me to write expression functions that I can use as output fields.

I am currently pulling data from two separate queries (Total Grants & Total Charges) that I would like to pull in a single query.

When I pull in both types of data, the raw data rows gets messy and duplicated. (See below)

How can I modify these sample expressions to sum the Grant amounts by the distinct Student ID and Grant ID and the Charges by the distinct Student ID and Charge ID?

Grant Aggregate Expression: SUM(case when Aid_Type = Grant then Grant_Amount else 0 end)

Charges Aggregate Expression: SUM(case when Charge_Date < Withdraw_Date then Charge_Amount else 0 end)

Sample Query 1 Data from Aid Offers table

Sample Query 2 Data from Charges Table

Sample messy combined data with duplicated data rows:

Thank you in advance for any help you can provide.

Comments
Post Details
Added on Nov 9 2024
5 comments
604 views