问题出现情况:
select * from
(
select a,b,c
from tab_a
order by a
union all
select a,b,c
from tab_b
order by a
) A;
出现如题所示的错误,
解决方式如下:
select * from
(
select a,b,c
from tab_a
--order by a
union all
select a,b,c
from tab_b
--order by a
) A order by a;
原来是union all 中出现的 "order by a"
本文介绍了一个常见的SQL查询错误,即在使用Union All时错误地应用了Order By子句。通过一个具体的例子展示了如何正确地调整查询结构以实现期望的数据排序,避免语法错误。
11万+

被折叠的 条评论
为什么被折叠?



