Subject | RE: [firebird-support] Re: Select first 3 and last 3 records |
---|---|
Author | Cao Ancoinc |
Post date | 2005-06-09T10:38:41Z |
Thanks MailMur however
as far as I know the From Select statement will only be implemented in Ver 2
so I am back to my original problem
as far as I know the From Select statement will only be implemented in Ver 2
so I am back to my original problem
> -----Original Message-----
> From: firebird-support@yahoogroups.com
> [mailto:firebird-support@yahoogroups.com]On Behalf Of mailmur
> Sent: 09 June 2005 09:08
> To: firebird-support@yahoogroups.com
> Subject: [firebird-support] Re: Select first 3 and last 3 records
>
>
> > I need to select the first 3 and last 3 records from a transaction
> file This I would imagine would be a simple query as the example below
> however Firebird objects to the "order by" clause when a "union"
> operator is present
> > select first 3 PrnId, InvNo
> > from Ordtrn
> > where PrnId='21'
> > order by InvNo
> > union
> > select first 3 PrnId, InvNo
> > from Ordtrn
> > where PrnId='21'
> > order by InvNo desc
>
> Maybe a derived inner queries could solve this problem.
> Select a.* From
> (Select first 3 prnid, invno From Ordtrn ... Order by Invno asc) a
> UNION
> Select b.* From
> (Select first 3 prnid, invno From Ordtrn ... Order by Invno desc) b