db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: Problem with derby 10.4
Date Tue, 15 Apr 2008 06:59:48 GMT
caxo <caxo@imperiaonline.org> writes:

> I have to take a certain number of rows ordered by a field.
> And the derby say me error: Syntax error: Encountered "ORDER"
>
> SELECT * FROM (
>    SELECT ROW_NUMBER() OVER () AS R,
>     playerId, 
>     playerName, 
>     points 
>    FROM ranks 
>    ORDER BY points DESC
>    )
>  AS TR WHERE R <= 10
>
> This is my query and I'm not shure is it a bug or I'm not doing something
> right.

It should work if you move the ORDER BY clause into the outer SELECT,
like this:

  SELECT * FROM (
    SELECT ROW_NUMBER() OVER () AS R,
           playerId,
           playerName,
           points
    FROM ranks) AS TR
    WHERE R <= 10 ORDER BY points DESC

-- 
Knut Anders

Mime
View raw message