Top Listing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Etherguy
Forum Commoner
Posts: 70
Joined: Fri Nov 01, 2002 9:09 pm
Location: Long Island, New York

Top Listing

Post by Etherguy »

This really...really pains me to write this, only because I know I have done it before many...many times.. but for the life of me I am blanking on this.

I need to make sort of a top downloader list. All the data is in a MYSQL table called xfer_stats. In this table there are a ton of columns but the ones I am interested in are usr,bytes I want to add up all the bytes per user and display. Listing all the users in order of most to least. Something similar might be done with money values in a similar application.

How do I go about doing this??
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Code: Select all

Select usr, sum(bytes) as sumBytes from xfer_stats group by usr order by sumBytes desc;
User avatar
Etherguy
Forum Commoner
Posts: 70
Joined: Fri Nov 01, 2002 9:09 pm
Location: Long Island, New York

Post by Etherguy »

Thanks. In my blind stupidity I forgot about the built in ability of MYSQL.

Thanks Again.
Post Reply