Subject Re: [firebird-support] Syntax for Union
Author Helen Borrie
At 10:41 AM 24/06/2004 -0400, you wrote:
>Hi All,
>
>I need some help with unions.
>
>select Field1, Field2 from table1
>union
>select Field1, Field2 from table2
>
>This works fine but I need to use the order by and where clauses on the
>first table. Something I read suggested this.
>
>(select t1.Field1, t1.Field2 AS Name from table1 t1
>union
>select t2.Field1, t2.Field2 AS Name from table2 t2)
>where t1.Field3 = 'T'
>order by Name
>
>But this barfs on the initial '('. Can someone give me an example of a
>union which can have where and order by clauses for the unioned tables?

select Field1, Field2 AS Name from table1
where Field3 = 'T'
union
select Field1, Field2 from table2
order by 2

/heLen