Combining UNION ALL and ORDER BY in Firebird

前端 未结 6 2179
梦谈多话
梦谈多话 2020-12-06 10:36

This is my first attempt at answering my own question, since someone may well run into this and so it might be of help. Using Firebird, I want to combine the results of two

6条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-06 11:00

    Field names are not required to be equal. That's why you can't use the field name in the order by.
    You may use the field index instead. As in:

    (select C1, C2, C3 from T1)
    union all 
    (select C7, C8, C9 from T2)
    order by 3  
    

提交回复
热议问题