count distinct records (all columns) not working [

2019-04-06 17:33发布

问题:

This question already has an answer here:

  • Counting DISTINCT over multiple columns 17 answers

what's proper syntax for

count (distinct *) from t1

I am getting he following error:

[Err] 42000 - [SQL Server]Incorrect syntax near the keyword 'distinct'.

回答1:

select count(*)
from
(
   select distinct * from your_table
) x