Subject | RE: [firebird-support] Way to avoid many subselects |
---|---|
Author | Leyne, Sean |
Post date | 2007-07-17T20:10:20Z |
> Look at this query. I want to get the last invoice of each customer:What version of FB are you running?
>
> select
> ( select first 1 id from invoices inv where inv.customer_id =
> cus.customer_id order by inv.id desc )
> ( select first 1 inv_date from invoices inv where inv.customer_id =
> cus.customer_id order by inv.id desc )
> ( select first 1 number from invoices inv where inv.customer_id =
> cus.customer_id order by inv.id desc )
> ( select first 1 ship_date from invoices inv where inv.customer_id =
> cus.customer_id order by inv.id desc )
> from
> customers cus
>
> Is there a way to get the same result as the query above, but
> introducing the table "invoices" in the "from" clause and avoiding
> these subselects?
Sean