Subject Re: [firebird-support] Re: SELECT UNION with ORDER BY?!
Author Helen Borrie
At 05:32 AM 12/04/2005 +0000, you wrote:
> > > SELECT T1.*,T2.A WHERE T2.ID=T1.ID
> > > UNION
> > > SELECT T1.*,T1.B WHERE T1.ID=-1
> > >
> > > ORDER BY 0 /or T1.C
> > >
> wrong?
> >
> > ORDER BY <column ordinal, starting at 1>
> >

At 05:32 AM 12/04/2005 +0000, Graeme Edwards wrote:

>In the example above using the union clause, I don't believe that
>you can order by an ordinal field number when using the t1.* syntax.
>You may have to explicitly name the fields in order to do this.
>Correct me if I am wrong.

Why not? Did you test it? It's only saying "order by the first field in
the spec, regardless of what it is"...

The syntax would come to grief sooner than that point, if the two
corresponding output fields weren't type-compatible for forming the
union....but that's not the case here.

<pedant hat on>
Of course, whether using select * at all is good practice is another story.