This is a pretty simple question, as I'm still pretty new to MS SQL. I'm trying to figure out a way to combine all values except one into one single field using a case statement. To be more clear, using the Northwind Database as an example, I want to make a table that shows the number of orders placed to customers in Germany and the number of orders placed to customers from everywhere else.
This is the query I attempted:
SELECT
CASE
WHEN A.Country = 'Germany'
THEN 'Germany'
WHEN A.Country <> 'Germany'
THEN 'Everywhere Else'
END
AS ShipTo,
COUNT(OrderID)
FROM Customers A
INNER JOIN Orders B ON A.CustomerID = B.CustomerID
GROUP BY Country;
Of Course that brings up a table like this in which every country appears separately by aliased as 'Everywhere Else'.
Everywhere Else 22
Everywhere Else 122
Everywhere Else 28
Everywhere Else 83
Germany 122
Everywhere Else 18
Everywhere Else 28
Everywhere Else 37
Everywhere Else 16
Everywhere Else 40
Everywhere Else 56
Everywhere Else 7
Everywhere Else 30
Everywhere Else 19
Everywhere Else 6
Everywhere Else 77
I would like all "Everywhere Else" fields combined into one. I know that's possible cuz I've done something similar before, I just can't remember how.
Just to expand on my comment.