MY_TABLE = Table with 2 columns Number, City.
Desired Output = City and count of unique Number associated to the city. Seattle, Bellevue is part of Combined. Even though there are 4 numbers associated to Seattle, Bellevue the output is 3 as there are only 3 distinct numbers – 123, 456, 786.
MY_TABLE
Number City
123 Seattle
456 Bellevue
789 LosAngeles
780 LosAngeles
123 Bellevue
786 Bellevue
Desired Output:
Combined 3
LosAngeles 2
Query so far:
SELECT NUMBER, CITY FROM MY_TABLE WHERE LOOKUP_ID=100 AND CITY IN
('Seattle', 'Bellevue', 'LosAngeles')
GROUP BY NUMBER, CITY
Would highly appreciate if anyone provides a recommendations around the same.
You could do something like
Of course, my guess is that you have some other table that tells you which
CITYvalues need to be combined rather than having a hard-codedCASEstatement.