MySQL Forums
Forum List  »  Newbie

sql query syntax
Posted by: Girija Mittagunta
Date: July 12, 2005 02:48PM

Hi,

I need to do a query as follows


select max(scores) from
(select sum(scores) AS scores, player from gametable group by player) AS tbl;

i.e. I need to calulate sum of scores for each player and then I need to find the max score amongst all players.

I keep getting error as follows
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use

I tried even simple nested queries as

select player from (select * from gametable) AS g;

I get the same error no 1064 with the above message.

I am comparing my statement with an example in the sql documentation
SELECT sb1,sb2,sb3
FROM (SELECT s1 AS sb1, s2 AS sb2, s3*2 AS sb3 FROM t1) AS sb
WHERE sb1 > 1;

How can I make these nested queries work in mysql.
I have mysql version 4.0.21 server installed on my windowsXP machine.

Thanks.
Girija

Options: ReplyQuote


Subject
Written By
Posted
sql query syntax
July 12, 2005 02:48PM
July 12, 2005 06:29PM
July 12, 2005 06:37PM
July 12, 2005 06:45PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.