Re: SQL: count distinct multi-column
Posted in 1997
Nyet,
There are not too many rows for group by:
SELECT COUNT(*)
FROM tbl
GROUP BY k1,k2,k3______________________________ Reply Separator _________________________________
Subject: SQL: count distinct multi-column
Author: "Roger W. Fischer" <roger_fischer@nortel-nsm.com> at INTERNET
Date: 8/5/97 1:19 PM
Greetings:
In SQL, is there a way to count the number of rows that have distinct
multi-column keys? It seems that the count function does not accept a
distinct expression with multiple columns.
Table:
Column Type Null
k1 char(3) no
k2 char(8) no
k3 char(11) no
ref1 char(20) no
...
SQL:
SELECT COUNT( DISTINCT k1,k2,k3) FROM tbl;
This query failed with an error at the comma following k1.
I also tried the following to no avail:
SELECT COUNT( DISTINCT k1||k2||k3) FROM tbl;
Note that the query without the count works OK. Also there are too many
rows to use "GROUP BY k1,k2,k3".
Is there any other way to get the count of unique keys?
Please reply through email, as the retention period on our site is very
short. Thanks...
Roger
--
Roger W. Fischer roger_fischer@nortel-nsm.com
Nortel NST roger.fischer@bnr.ca
Vancouver, BC (Canada) fischer@ncrsu123.crest.nt.com