Why can't we use count(distinct *)
in SQL? As in to count all distinct rows?
相关问题
- SQL join to get the cartesian product of 2 columns
- sql execution latency when assign to a variable
- Difference between Types.INTEGER and Types.NULL in
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
COUNT(*) is the number of rows matching a query.
A row contains unique information such as rowid. All rows are by definition distinct.
You must count the distinct instances of values in some field instead.
You can try a CTE in Sql Server 2005
To answer the question, From the documentation
some languajes may not be able to handle 'distinct *' so, if you want the distinction made through many columns you might want to use 'distinct ColumnA || ColumnB' , combining the values before judging if they are different. Be mindful whether your variables are numeric and your database handler can make automatic typecast to character strings.
why not?
UberKludge, and may be postgre specific, but