Subject Re: [firebird-support] Re: How to mix ascending and descending fields in one index
Author Martijn Tonies
> Martijn Tonies wrote:
>> The derived table select takes milliseconds.
> ...
>> select
>> *
>> from
>> ( select first 10 * from
>> CSV_DATA_TEST_2
>> order by C_INT desc) as first_10
>> order by first_10.c_float asc
>
> But is that really the same thing?
>
> select first 10 * from
> CSV_DATA_TEST_2
> order by C_INT desc
>
> does not (necessarily) return the same 10 rows as
>
> select first 10 * from
> CSV_DATA_TEST_2
> order by C_INT desc, c_float asc
>
>
> If there were 50 rows all with C_INT = 1
> then your statement will return a random(ish)
> selection of 10 of them.

Hmm, good thinking... Not the correct solution as the OP did state
that column "A" could have the same values...

> If there was some known limiter value for C_INT
> then a WHERE clause could be used... but I suspect
> that would work without derived tables too.


With regards,

Martijn Tonies
Upscene Productions
http://www.upscene.com

Download Database Workbench for Oracle, MS SQL Server, Sybase SQL
Anywhere, MySQL, InterBase, NexusDB and Firebird!

Database questions? Check the forum:
http://www.databasedevelopmentforum.com