db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John English <john.fore...@gmail.com>
Subject Re: Processing a subset of records correctly
Date Tue, 05 Apr 2016 10:52:06 GMT
On 05/04/2016 08:45, Bob M wrote:
> I have just realized that I am processing the subset in reverse order (i.e.
> latest date backwards)
>
> I want to process in earliest date forwards direction
> rs = s.executeQuery("SELECT * FROM xxx WHERE TRADE_NO <>0 ORDER BY
> Trading_Date DESC,"
>          + " Trading_Time DESC FETCH NEXT 101 ROWS ONLY");

One way would be to wrap the first query inside another one: something 
like This:

   SELECT * FROM (SELECT * FROM xxx WHERE TRADE_NO <>0
                  ORDER BY Trading_Date DESC, Trading_Time DESC
                  FETCH NEXT 101 ROWS ONLY) AS x
            ORDER BY Trading_Date ASC

but I'm sure there must be a more elegant way to do it...
-- 
John English

Mime
View raw message