Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Rawler
Starting Member
9 Posts |
Posted - 2011-06-02 : 15:51:48
|
Hi all!I got this query that show me results grouped by Province, City and subCity. I need to count each column without repeated rows. Like this:PROVINCE CITY SUBCITY province1 city11 subcity111province1 city11 subcity111province1 city12 subcity121province2 city22 subcity221province2 city22 subcity222province2 city22 subcity223 so I need to know how many provinces (2), how many cities (3) and how many subcities (4). Is there a way of doing this? with row_number, compute, count or any other function?thanks! |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-02 : 16:16:08
|
| SELECT Count(DISTINCT PROVINCE) Provinces, Count(DISTINCT CITY) Cities, Count(DISTINCT SUBCITY) SubCitiesFROM myTable |
 |
|
|
|
|
|