Subject | Re: Subquery Question (FB 1.5) |
---|---|
Author | data.inspector |
Post date | 2010-07-08T00:07:58Z |
Perfect! Thanks for your help. BTW, I will be migrating to FB2.5 soon. Will this continue to work there?
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@...> wrote:
>
> At 01:36 AM 8/07/2010, you wrote:
> >Here are the two peices of the query I can't get tied together.
> >Thanks for looking at it.
> >
> >select
> > watlev.inventory_pk,
> > watlev.wl_date,
> > watlev.wl_comment
> >from
> >watlev
> >where
> >
> >/*It is this piece of the SQL Statement I can't seem to puzzle out */
> >
> > (select
> > w.inventory_pk,
> > max( w.wl_date ) max_of_wl_date
> > from watlev w
> > group by w.inventory_pk)
>
> In Fb 2 and above you could use something like that idea by use of derived tables. For Fb 1.5, try the following:
>
> select
> w1.inventory_pk,
> w1.wl_date,
> w1.wl_comment
> from
> watlev w1
> where
> w1.wl_date =
> (select max( w.wl_date ) from watlev w
> where w.inventory_pk = w1.inventory_pk)
>
> Note here I'm discouraging you from mixing table identifiers with table aliases because it becomes illegal in Fb 2+.
>
> ./hb
>