I just found a handy SELECT in the mail archives, a simple example would be:
SELECT name, COUNT(*) FROM contacts GROUP BY name;
Which returns every contact name, along with the number of occurances...
What I couldn't find in the archives, is a way of doing:
SELECT the number of distinct names FROM contacts;
And have the query just return a single number, e.g. 57 (There are 57
different names in the 'contacts' table).
Is this possible? - I can't find any way to combine the DISTINCT and COUNT()
clauses in a SELECT statement in order to achieve this in one simple step...
|• DISTINCT SELECT's?||Karl Pielorz||5 Jun|