How to count distinct values over multiple columns using SQL

404

nVector

posted on 20 Jun 20

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds




kahumphrey16-Jul-20

Maybe I am a lil old fashion, but why would not the following query work:

SELECT  DocumentId, DocumentSessionId,count(*)

FROM Table

group by DocumentId, DocumentSessionId

nVector17-Jul-20

Sure. This query will produce the list of distinct groups and count per each group (the result will be one or more rows). The article is about, how to get distinct count for entire table (returns consolidated one row)