select u.name, sum(p.id)
from usertable u, posts p
where u.userid = p.poster
group by u.name
order by 2 desc

//chris
www.mydba2000.com

>From: "Laban" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Subject: Query
>Date: Fri, 15 Mar 2002 02:18:27 +0100
>
>Hi
>
>I need a query that counts the number of posts each user have made in my
>forum and then sort the userlist by that. How?
>
>table posts
>id, int (post id)
>thread, int (which forum the post belong to)
>poster, int (Who posted. ID from users table)
>string, text (post text)
>category, int (forum category)
>timestamp, int (timestamp)
>
>SELECT poster, COUNT(*) AS num FROM posts GROUP BY poster ORDER BY num 
>DESC;
>this showes how many posts each user has, sorted by the number of posts.
>Most posts come first.
>
>Now, how do I implent this in the following query?
>SELECT * FROM users ORDER BY ?????????????
>
>"poster" is the ID from the user table.
>
>//Laban
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail 
><[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>


_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to