Oracle update和order by
今天遇到一个关于SQL转换成Oracle语句的问题,描述如下:
select * from emp order by deptno;
select * from dept;
Sql Server:
update dept a set dname=(select top 1 ename from emp where deptno=a.deptno order by sal)
经过尝试,查找资料,得出下面转换结果,不知道这样是否可行:
update dept a set dname=
(with t as(select ename,deptno from emp order by sal)
select ename from t where deptno=a.deptno and rownum=1)
where exists(with t as(select ename,deptno from emp order by sal)
select null from t where deptno=a.deptno)
执行结果:
select * from dept;
其他替代方法随后再做尝试。
相关推荐
王艺强 2020-11-17
anchongnanzi 2020-09-21
84296033 2020-09-15
heimu 2020-08-02
herohope 2020-07-18
mrandy 2020-07-04
Jaystrong 2020-06-27
89921334 2020-06-26
debugjoker 2020-06-17
Linkaibin 2020-06-14
fanhuasijin 2020-06-14
Laxcus大数据技术 2020-06-13
hanshangzhi 2020-06-10
rainchxy 2020-06-07
Jerry 2020-06-01
lilygg 2020-05-29
lclcsmart 2020-05-27