Subject Re: [firebird-support] TOP 1?
Author Svein Erling Tysvær
> On 5/11/07, Steve Miller <Steve_Miller@...> wrote:
>> I thought I read somewhere that the latest version of Firebird
>> supports selecting the first record from a result set, such as this
>> query in SQL Server:
>>
>> SELECT TOP 1 MyColumn FROM MyTable ORDER BY SomeOrd
>>
>> Is this true, or am I dreaming it? If it's still a dream, what do
>> people do for a workaround?
>
> Firebird does support this functionality, the only thing you'd need to
> change is the syntax:
>
> SELECT FIRST 1 MyColumn FROM MyTable ORDER BY SomeOrd
>
> Regards
> Gareth Marshall

Firebird has supported SELECT FIRST for quite a while, but that syntax is Firebird-specific. A newer SQL standard is using ROWS, so that this particular statement becomes
SELECT MyColumn FROM MyTable ORDER BY SomeOrd ROWS 1

From the release notes of Firebird 2:
"A more understandable alternative to the FIRST/SKIP clauses, the ROWS syntax accords with the latest SQL standard and brings some extra benefits. It can be used in unions, any kind of subquery and in UPDATE or DELETE statements."

Set


[Non-text portions of this message have been removed]