Hi, I have a database with 5 teams and each team has 'n' categories and each category has 5 sub-categories.
i.e TeamOne = Ottawa, Category 1 = Player Name, Sub-Categories = Goals, assists, ppg, gwg, points. Team0ne Category 1 Sub 1 Sub 2 Sub 3 Sub 4 Sub 5 Category 2 Sub 1 Sub 2 Sub 3 Sub 4 Sub 5 Etc. >From the examples above I am trying to add the all the sub-categories together for each category for each team in descending order. To put it simpler - I want a total of all the goals scored for each team and display them in descending order. I have been able to put a query together that gets me the totals, but I can not get them in decending order. The query below is in a for loop in PHP and cycles through each team and does give me the totals, just not in descending order (actually the order is the way they are numbered in the database); $query = "select team.name, sum(goals) from roster join reference join team where team.idn=reference.idn and reference.idp=roster.idp and position = 'F' and team.idn = 1 group by team.name"; Now the query here may not be the problem, but the way the for loop works, but any help is appreciated. TIA -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]