update A set 学历=(select MAX(文化程度) from B where B.ID=A.ID);
store educational level to the column 文化程度,and thenupdate A set 学历=nvl((select max(文化程度) from B where A.ID=B.ID),"<default educational level>")
sorry,i mean store educational level code to the column 文化程度,
关键是先把B表中每一ID的最高文化程度选出来 Select ID,MAX(文化程度) as 文化程度 from B group by ID 再更新A表。
关键是先要把B表分组,然后把同组的最高的文化程度的纪录更新到A表 同时要判断B表的纪录中文化程度不为空 update A set 学历=(select 文化程度 from B group by id having MAX(文化程度) where 文化程度 is not null) where A.ID=B.ID 意思就是这样 请高手帮忙
A表 ID 姓名 学历 001 张山 大学 002 李氏 硕士B表 ID 学校 文化程度 001 大学 001 北大 硕士 002 南大 大学 002 南大 硕士 update A set 学历=(select 文化程度 from B group by id having MAX(文化程度) where 学校 is not null) where A.ID=B.ID 我想实现上面这句的功能,语句应该怎么写?上面的句子是错误的。
这样写呢? update A set 学历=(select MAX(文化程度) from B group by id where 学校 is not null) where A.ID=B.ID
update A set 学历=(select MAX(文化程度) from B where B.ID=A.ID); 就ok了
update A set 学历=(select MAX(文化程度) from B where B.ID=A.ID); 这样是不是能把ID相同的最高文化程度 赋给A表对应的字段? 还想加一个约束 update A set 学历=(select MAX(文化程度) from B where B.ID=A.ID and B.学校 is not null);
where A.ID=B.ID),"<default educational level>")
Select ID,MAX(文化程度) as 文化程度 from B group by ID
再更新A表。
同时要判断B表的纪录中文化程度不为空
update A set 学历=(select 文化程度 from B group by id having MAX(文化程度) where 文化程度 is not null) where A.ID=B.ID
意思就是这样
请高手帮忙
ID 姓名 学历
001 张山 大学
002 李氏 硕士B表
ID 学校 文化程度
001 大学
001 北大 硕士
002 南大 大学
002 南大 硕士
update A set 学历=(select 文化程度 from B group by id having MAX(文化程度) where 学校 is not null) where A.ID=B.ID
我想实现上面这句的功能,语句应该怎么写?上面的句子是错误的。
update A set 学历=(select MAX(文化程度) from B group by id where 学校 is not null) where A.ID=B.ID
就ok了
这样是不是能把ID相同的最高文化程度 赋给A表对应的字段?
还想加一个约束
update A set 学历=(select MAX(文化程度) from B where B.ID=A.ID and B.学校 is not null);