请教PLSQL的如何书写

oodick 2010-02-25 02:50:18
emp和department表(字段类型见表定义)。其中emp表的departmentCode字段和department表的depcode字段关联。请把入职日期为2010年1月1日之前的职员数据导入empwork表(字段类型见表定义),如果职员薪水低于5000,则薪水加600,如果职员薪水高于8000,则薪水减400。
...全文
236 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
zcjlyj 2010-03-19
  • 打赏
  • 举报
回复
oracle太复杂了
huangqibing0626 2010-03-19
  • 打赏
  • 举报
回复
`````````
duqiangcise 2010-03-19
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 suiziguo 的回复:]
引用 3 楼 lin_dong 的回复:
引用 1 楼 suiziguo 的回复:巧妇难为无米之炊 回复内容太短了!
my god,果然是巧妇
日本娘娘腔,sui guo菜菜zi!
你丫找抽?
[/Quote]
3楼的贴子到哪里去了???看一下原版的赛。呵呵!不要恐吓小孩子!!
心中的彩虹 2010-03-16
  • 打赏
  • 举报
回复


create table empwork(empid varchar2(5),empname varchar2(8),salary number,deptname varchar2(20))
as
(select a.empid,a.empname,a.salary,a.deptname from emp a,department b where a.deptid=b.deptid and rjdate<=to_date('20100101','yyyymmdd'))

update empwork
set salary=salary+600
where empid in(select empid from empwork where salary<5000)

update empwork a
set salary=salary-400
where exists(select 1 from empwork where a.empid=empid and salary>8000)




碧水幽幽泉 2010-02-26
  • 打赏
  • 举报
回复
引用 7 楼 sxx_tt 的回复:
emp表与department表关联有什么意义?
SQL codeinsertinto empwork
(
empno,empname,depcode,depname,sal,hiredate
)select a.empno,
a.ename,
a.deptno,
b.dname,casewhen a.sal<5000then a.sal+600when a.sal>8000then a.sal-400end,
a.hiredatefrom emp a,dept bwhere a.deptno= b.deptnoand a.hiredate<= date'2010-1-1';
zhangwonderful 2010-02-26
  • 打赏
  • 举报
回复
参考sql:
insert into empwork
(
empno,empname,depcode,depname,sal,hiredate
)
select a.empno,
a.ename,
a.deptno,
b.dname,
case when a.sal <5000
then a.sal+600
when a.sal >8000
then a.sal-400
end,
a.hiredate
from emp a,dept b
where a.deptno = b.deptno
and a.hiredate <= to_date( '2010-01-01','YYYY-MM-DD')
and not exists(select 1 from empwork w where w.empno=a.empno);
注意避免重复员工插入
sxx_tt 2010-02-26
  • 打赏
  • 举报
回复
emp表与department表关联有什么意义?

insert into empwork
(
empno,empname,depcode,depname,sal,hiredate
)
select a.empno,
a.ename,
a.deptno,
b.dname,
case when a.sal <5000
then a.sal+600
when a.sal >8000
then a.sal-400
end,
a.hiredate
from emp a,dept b
where a.deptno = b.deptno
and a.hiredate <= date '2010-1-1';
oodick 2010-02-26
  • 打赏
  • 举报
回复
题目就没给表结构,自己看情况定义 汗
sxx_tt 2010-02-26
  • 打赏
  • 举报
回复
引用楼主 oodick 的回复:
emp和department表(字段类型见表定义)。其中emp表的departmentCode字段和department表的depcode字段关联。请把入职日期为2010年1月1日之前的职员数据导入empwork表(字段类型见表定义),如果职员薪水低于5000,则薪水加600,如果职员薪水高于8000,则薪水减400。

你的表定义在哪?
suiziguo 2010-02-25
  • 打赏
  • 举报
回复
引用 3 楼 lin_dong 的回复:
引用 1 楼 suiziguo 的回复:巧妇难为无米之炊 回复内容太短了!
my god,果然是巧妇
日本娘娘腔,sui guo菜菜zi!



你丫找抽?
cyousor 2010-02-25
  • 打赏
  • 举报
回复
insert into empwork
select
case when sal > 8000 then sal - 400 when sal < 5000 then sal + 600 else sal end sal,
...
from department d,emp e
where d.depcode = e.depcode
and e.[入职日期] >= '2010-01-01'
suiziguo 2010-02-25
  • 打赏
  • 举报
回复
巧妇难为无米之炊
回复内容太短了!

17,089

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧