Hi

Many thanks to one and all for your time and assistance with my
question. I used the 'AS cnt' method and it works brilliantly.  Simple
isn't it? :-)

Cheers
Gary

-----Original Message-----
From: Victoria Reznichenko [mailto:[EMAIL PROTECTED] 
Sent: 24 July 2003 14:01
To: [EMAIL PROTECTED]
Subject: Re: GROUP BY ORDER BY

"Gary Broughton" <[EMAIL PROTECTED]> wrote:
> 
> I wonder if someone could help with what I assume is a simple query
> using GROUP and/or ORDER statements (something I struggle to get to
> grips with).  I am trying to get a list of users who have posted to a
> forum by number of posts descending, but am unable to find the right
> statement to do it.
> 
> 
> 
> At the moment I have: "select count(*), user_id FROM messages WHERE
> forum_id = 294 GROUP BY user_id" . which gets me what I want, but in a
> random user order.
> 
> 
> 
> I have looked through the MySQL documentation, but have been unable to
> hit on the combination of functions needed to get what I need (which
is
> effectively 'ORDER BY count(*) DESC').


SELECT COUNT(*) AS cnt, user_id FROM messages WHERE forum_id = 294 GROUP
BY user_id ORDER BY cnt DESC


-- 
For technical support contracts, goto
https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.net http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Victoria Reznichenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.net
       <___/   www.mysql.com





-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to