mr.wr
mr.wr

Reputation: 32

count(distinct(column))

I can run this sql succesfully:

select count(distinct(BusinessEntityID)) from Person.Person

But what if I want to know this, give me error:

select count(distinct(*)) from Person.Person

How can I run equliviant sql ?

Upvotes: 0

Views: 118

Answers (2)

JavidRathod
JavidRathod

Reputation: 483

please use directly count(*) for example :

select count(*) from Person.Person

Upvotes: -1

Andrey Korneyev
Andrey Korneyev

Reputation: 26846

You can use query like this to get count of distinct records in table:

select count(*) from (select distinct * from Person.Person) as T

In the inner select you're retrieving distinct records, and in the outer one you're getting the count.

Upvotes: 4

Related Questions