Reputation: 19
I have the following result set:
What I am needing to do is combine just the "New Admission" and "New Admit" values from the Reason column with the corresponding amounts.
So what I would like to end up with is this result set:
The query that I have created to build the first result set is as follows:
SELECT Region, Reason, CAST(SUM(Amount) AS Decimal(18,2)) AS Amount FROM Table GROUP BY Region, Reason
Just wondering if anyone else has insight into this. I am using SQL Server 2019
This is a screen shot of the actual data from my table
Upvotes: 1
Views: 40
Reputation: 1271003
Use a case
expression:
SELECT Region,
(CASE WHEN Reason IN ('New Admission', 'New Admit') then 'New Admission/New Admit'
ELSE 'Other'
END) as Reason,
CAST(SUM(Amount) AS Decimal(18,2)) AS Amount
FROM Table
GROUP BY Region,
(CASE WHEN Reason IN ('New Admission', 'New Admit') then 'New Admission/New Admit'
ELSE 'Other'
END);
Upvotes: 2