1
我真的卡在UNION ALL加入的顺序,下面是塞纳里奥联盟都在DB2 SQL查询更新拳头表
,如果我来逐个运行此查询我得到如下结果
1) Select salary as result from employee
where empno = '111628548' and seqno = 4
order by seqno Desc
result
------
$7000
$3000
2) Select descofemp as result from empdetail
where empno = '111628548' and seqno = 4
order by seqno Desc
result
------
very good employee
good employee
上述两导致字符串,所以列是相同的类型。 但是当我上面的两个查询与工会加入我得到像
With s1 as (Select salary from employee
where empno = '111628548' and seqno = 4
order by seqno Desc),
s2 as (Select descofemp from empdetail
where empno = '111628548' and seqno = 4
order by seqno Desc
)
select * from s1
Union ALL
select * from s2
Result
------
$3000
$7000
very good employee
good employee
您可以在这里看到工资的顺序已经改变,我想verious的事情,但为什么顺序改变我不能够理解在UNION ALL中,是否有人知道或面对这个问题,如果是的话,你可以分享一些关于如何解决问题的信息。
预先感谢您。
问候 蒙娜丽莎
谢谢..会给你试试..并让你知道... – SmartDev
@monamona。 。 。需要注意的是,'by by'不稳定,因为你正在用'seqno'命令,它的值总是为'4'。你可能应该使用另一个在两个查询所选择的行上不同的字段。 –
...我试过你的查询,它的工作..像魅力..非常感谢你保存了我的另一个小时...再次感谢你.. – SmartDev