Oracle 查询

来源:互联网 发布:香港买mac pro 过关 编辑:程序博客网 时间:2024/05/16 08:53

nvl进行判空处理,如果money字段是空 就用0来代替

select name ,nvl(money,0),from yy;

name like ‘_ _o%’ 查找第三个字母是o的名字

查询平均薪资大于2000的部门

select avg(sal),max(sal),depton from rmp group by depton  haveing avg(sal)>2000;

查询本部门高于部门平均工资的员工

select a.name,a.sal,b.mysal,b.depton from emp a ,(select depton ,avg(sal) mysal from emp group by depton) b  where a.depton=b.depton and a.sal >b.mysal;

利用子查询建表 (可以同时将表里面的记录导出来)

 create table mytable (id ,name) as  select id,name from yy;

insert 结合子查询导数据

insert into yy(id,name) select user_id,name from  user where user_id>10;
0 0
原创粉丝点击