Subject Re: [firebird-support] Named fields in WHERE ..
Author Thomas Steinmaurer
>> select L_ID, L_NUMBER, lt.LT_TIMESTAMP as START_TIME
>> from L_TABLE
>> left join L_TABLE_SLAVE lt on lt.LT_L_ID = L_TABLE.L_ID and lt.LT_EVENT_ID = 1
>> where L_TABLE.L_ID > 177700
>>
>> I'd like to limit search resutl on to rows where START_TIME is null.
>> However my first idea ".. AND START_TIME IS NULL" doesn't work, but
>> second guess ".. AND lt.LT_TIMESTAMP IS NULL" works.
>>
>> Is it possible to use use "START_TIME" in query at all?
>>
>> I'm using Firebird 2.0.4 with this one.
>
> Not supported in Firebird 2.0, but it is supported in Firebird 2.1. The
> same goes for GROUP BY. Very handy e.g. when you have some kind of
> longish CASE statement in the field list. Although, you also can ORDER
> BY the field index since ages.
>
> In your case:
>
> select L_ID, L_NUMBER, lt.LT_TIMESTAMP as START_TIME
> from L_TABLE
> left join L_TABLE_SLAVE lt on lt.LT_L_ID = L_TABLE.L_ID and
> lt.LT_EVENT_ID = 1
> where L_TABLE.L_ID > 177700
> order by 3
>
>
> But I don't like that as a permanent solution, because just in case the
> field list gets extended before the field in question, you also have to
> adjust the ORDER BY clause accordingly. Something one might miss when in
> hurry. ;-)

Yeah, and I was in a hurry when reading your message. ;-) I stand
corrected. You can't use a field alias in the WHERE clause. Other things
noted for ORDER BY and GROUP BY are correct though. ;-)


--
Best Regards,
Thomas Steinmaurer
LogManager Series - Logging/Auditing Suites supporting
InterBase, Firebird, Advantage Database, MS SQL Server and
NexusDB V2
Upscene Productions
http://www.upscene.com
My blog:
http://blog.upscene.com/thomas/