List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 1 2002 4:19pm
Subject:Re: How do I select something distinct ordered by most frequent?
(e.g. top 10)
View as plain text  
At 15:56 +0000 2/1/02, SED wrote:
>Hi,
>
>I'm trying to make a query where I select something distinct ordered by
>most frequent?
>
>I found below example from the manual but I can not figure out how I
>should order them by most frequent - do you know how?
>
>	SELECT DISTINCT owner FROM pet

Don't use distinct in that case.  Count them and order by the descending
counts.

SELECT owner, COUNT(owner) AS frequency FROM pet ORDER BY frequency DESC;

>
>Regards,
>SED

Thread
MyODBCMike Nelson26 Jan
  • Re: MyODBCSinisa Milivojevic26 Jan
    • Data Types for TEXT, BINARY?Paul Reilly26 Jan
      • Re: Data Types for TEXT, BINARY?Jeremy Zawodny26 Jan
  • RE: MyODBCVenu26 Jan
    • Re: MyODBCD'Arcy Rittich1 Feb
      • Re: MyODBCSinisa Milivojevic1 Feb
        • How do I select something distinct ordered by most frequent? (e.g. top 10)SED1 Feb
          • Re: How do I select something distinct ordered by most frequent?(e.g. top 10)Paul DuBois1 Feb
            • Re: How do I select something distinct ordered by most frequent?(e.g. top 10)Paul DuBois1 Feb
      • RE: MyODBCVenu1 Feb