sql - Combining similar names and counting distinct from a single column -
i attempting combine rows similar names within single column. data using has clients listed same name:
| client_column | address | | xyz isd | 1 drive | | xyz isd | 2 drive | | xyz isd | 3 drive |
however, there records same client has distinct, similar name alternate address:
| client_column | address | | abc inc. | 101 lane | | abc inc. - p1 | 102 lane | | abc inc. - p2 | 103 lane |
i count total number of distinct addresses each client in table. in example, xyz isd , abc inc. each have 3 unique addresses. how can adjust script can achieve result?
i think need use sum aggregate total, not sure how. able count addresses clients exact same name accuracy, ones similar names display single record addresscount.
here script:
select clientname, count(address) addresscount tablea group clientname order addresscount
result:
| client_column | addresscount | | blue llc | 15 | | psc parts | 14 | | abc inc. | 1 | | abc inc. - p1 | 1 | | abc inc. - p2 | 1 |
Comments
Post a Comment