var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Smart way to count the number of TWO distinct fields??
I'm trying to find out the total number of rows with the distinct values from TWO fields. This works:
SELECT DISTINCT Field1, Field2 FROM Table
SET @Nr = @@ROWCOUNT
But there MUST be a more clever method! COUNT() doesn't work because it can only take ONE distinct field, and that goes for SUM() also. GROUP BY didn't cut it either. Any ideas?
I've now received two solutions!!
SELECT @Nr = COUNT(*) FROM
(SELECT DISTINCT Field1, Field2 FROM Table) AS Nr
SELECT @Nr = COUNT(DISTINCT (Field1+ CAST(Field2 AS VARCHAR(20))) ) FROM Table