Subject | union and order by |
---|---|
Author | Bart Smissaert |
Post date | 2012-07-15T19:42:38Z |
Firebird 1.5 classic on Windows.
Is it possible to have a SQL with union all and an order by that
includes a field that is not in the selects?
eg:
select fieldA, fieldB from table1 where fieldA starting with 'bd'
union all
select fieldA, fieldB from table1 where fieldA starting with 'bi'
order by
fieldA asc, fieldC asc
In case you wondered why I used a union here, it is as I found it be a
lot faster than using an OR.
RBS
Is it possible to have a SQL with union all and an order by that
includes a field that is not in the selects?
eg:
select fieldA, fieldB from table1 where fieldA starting with 'bd'
union all
select fieldA, fieldB from table1 where fieldA starting with 'bi'
order by
fieldA asc, fieldC asc
In case you wondered why I used a union here, it is as I found it be a
lot faster than using an OR.
RBS