Forum Moderators: coopster
Name ¦ Address ¦ Email Address
Jake TX abc@example.com
Ric OH ric@example.com
table_2
Name ¦ Date ¦ Score
Jake 01/05/07 34
Ric 06/07/07 14
Ric 08/1/07 18
Jake 02/09/07 12
Jake 07/15/07 30
I need a query that will give an output like this (ORDER BY score), please help :
Name ¦ Score
Jake 76
Ric 32
[edited by: Gian04 at 7:03 am (utc) on Aug. 4, 2007]
This query shows an error :
SELECT table_1.name, sum(table_2.score) AS total_score from table_1, table_2 WHERE table_1.name = table_2.name ORDER by total_score
[edited by: Gian04 at 10:43 am (utc) on Aug. 4, 2007]
You need to specify how the data is sum()'ed - use group by name.
select name, sum(score) as ts from table_1, table_2 where table_1.name = table_2.name group by table_2.name order by ts
[edited by: darrenG at 11:53 am (utc) on Aug. 4, 2007]