Assuming it is 5 fixed columns, you could try:

SELECT t1.Name, SUM(t2.col1+t2.col2+t2.col3+t2.col4+t2.col5) as sum 
FROM t1, t2, t3 
WHERE t1.id1 = t3.id1  AND  t3.id2 = t2.id2 
GROUP BY t2.id2
ORDER BY sum DESC

Also, i'm assuming that all entries in t1 have a correspondent in t3 and
t2.

On Sat, 2003-02-08 at 04:47, Beauford wrote:
> Not sure my other email got through, so here it is again, with an updated
> description.
> 
> Hi,
> 
>  I have a database with 3 names in it. In each of these names is 5
> categories  that have numbers in them. I want to be able to do a select and
> total these numbers for each name, and then sort them in descending order. I
> have tried for over 6 hours tonight and no matter what I do, there is one
> minor glitch. I am not supplying any code as I would like to know from you
> people what the best way to go about this would be - as what I have done is
> obviously not working.
> 
>  TIA
> 
>  i.e
> 
> This is what is in the database.
> 
> Table 1
> 
> ID1 NAME
> 
> 1  Bill
> 2  John
> 3  Fred
> 
> Table 2
> 
> ID2  Col1 Col2 Col3 Col4
> 
> 1   1    4    5    6
> 2   3    2    8    6
> 3   4    9    2    2
> 
> Database 3 is a reference file that ties them together - so I would have to
> use a join in the select statement.
> 
> ID1  ID2
> 1        1
> 2        2
> 3        3
> 
> This is what I want to be able to show:
> 
> John   21
> Fred   20
> Bill     16
> 
> MySQL
-- 
Diana Soares


---------------------------------------------------------------------
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