in reply to ORDER BY COUNT(*)?

SELECT DISTINCT surveys, COUNT(*) col2 FROM neverland GROUP BY surveys ORDER BY col2 DESC
Should work, though it may need an "AS" between the COUNT(*) and the col2 (an alias for the column) depending on the RDBMS (I don't know much about MySQL I'm afraid).

Replies are listed 'Best First'.
Re: Re: ORDER BY COUNT(*)?
by Caillte (Friar) on Mar 20, 2002 at 15:48 UTC

    In mySQL you need to use the AS keyword to name a column, ie count(*) AS col2. After that, this method works fine.

    This page is intentionally left justified.

      No, AS keyword is optional. The above query is perfect.
Re(2): ORDER BY COUNT(*)?
by dmmiller2k (Chaplain) on Mar 21, 2002 at 04:28 UTC

    Given your GROUP BY clause, your DISTINCT keyword is completely unnecessary. And, by the way, the second column may be equivalently specified as COUNT(*) [AS] col2 or col2=COUNT(*).

    The ORDER BY clause may alternatively be specified as ORDER BY 2 DESC or as ORDER BY count(*) DESC.