Query Help Humbly and Respectfully Requested

Hi everyone. I hope someone can help me with this. I haven't been able to figure out how to do a select statement from below table in which my result set will have only one row per Revenue Type with all Revenue summed for that Revenue Type. Each revenue type shares the same sort number.

RevenueType          Revenue          Sort
RetailCard                 100.00                  2
Crew                        10.00                    1
RetailCard                200.00                 2

Use "group by" and "sum" aggregation

1 Like

Thanks, I have tried that. I spent all day on this problem using "group by" and sum. Maybe this task isn't possible?

Select the RevenueType column and sum the Revenue column then group by RevenueType should work as bitsmed has mentioned, unless we are missing something :slight_smile:

1 Like
SELECT RevenueType, TotalRevenue
    SELECT RevenueType, SUM(Revenue) AS TotalRevenue, MAX(Sort) AS Sort
    FROM dbo.tablename
    GROUP BY RevenueType
) AS query1

Hi bitsmed and StephenChapman, sorry I didn't show my appreciation earlier. Was so slammed in life and lost my login info to this site on top of that. Thanks for the help :slight_smile:

1 Like