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'.
Yes, DISTINCT works on all combinations of column values for all columns in the SELECT clause.
select count(distinct col1 || '-' || col2) from mytable; or use a subquery: select count(*) from (select distinct col1, col2 from mytable);
The DISTINCT clause can be applied to one or more columns in the select list of the SELECT statement.
The COUNT DISTINCT function returns the number of unique values in the column or expression, as the following example shows. SELECT COUNT (DISTINCT item_num) FROM items; If the COUNT DISTINCT function encounters NULL values, it ignores them unless every value in the specified column is NULL.
select count(*)
from
(
select distinct * from your_table
) x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With