823oracle

--分组再排序
select dept_no from employee group by dept_no ,name order by dept_no desc
 
--实现查询部们人数2个以上的部门ID
select dept_no from employee group by dept_no having count (dept_no)>1
--创建表对象
select e.sex from employee e
--dual空表,补充
select sysdate from dual
--关联查询
select * from employee
select * from department
select d.name,e.name from  department d left join employee e on d.dept_no=e.dept_no
select d.name,e.name from employee e full join department d on d.dept_no=e.dept_no
select d.name,e.name from  department d right join  employee e on d.dept_no=e.dept_no
select d.name,e.name from  department d  join  employee e on d.dept_no=e.dept_no 
where e.dept_no in(select dept_no from employee group by dept_no having count (dept_no)>1)


select * from employee where dept_no between 1 and 2


delete from employee t where rownum<2 and t.dept_no=1  


select rownum,t.* from(select * from employee) t


select dept_no a, name b from employee union select dept_no, name from department
--创建索引
create index index_employee on employee (id)


select  to_char(sysdate,"yyyy-mm-dd") from dual
--三元运算符
select nvl(null,1) from dual --第一个为空返回第二个
select nvl(1,2) from dual --第一个不为空返回第一个
select nvl2(null,1,2) from dual --为空则返回第二个
select nvl2(0,1,2) from dual --不为空则返回第一个
select nullif(2,3) from dual --不同返回前面的
select nullif(2,2) from dual --相同返回null


select name ,case when sex=0 then '男' else '女' end from employee
select name ,case when sex=0 then '南' else '女' end from employee
select name,sex,age,case when dept_no=1 then '总经办ha' when dept_no =2 then '业务ha' else '质量部ha' end from employee
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值