Oracle单表的简单查询

查看表结构

desc emp;

查询所有列

Select * from emp;

查找所以部门编号(查指定的列)

select deptnofrom emp;

查找编号不同的部门编号(去重)

selectdistinct deptnofrom emp;

查找enameSMITH的员工职位,工资,部门编号

select job,sal,deptnofrom emp  where t.ename='SMITH';

查找员工的年薪

NVL( string1, replace_with)

功能:如果string1为NULL,则NVL函数返回replace_with的值,否则返回string1的值

SELECT sal*12+nvl(comm,0)*12as salsun , ename,sal,comm  from emp

别名的应用

select salas "工资"from emp

查询工资大于1000的员工工资

select salas "工资"from empwhere sal>1000

查找1982.1.1后入职的员工

select ename,hiredatefrom empwhere  hiredate>'1-1-1982'

显示工资在20003000的员工

select ename,salfrom empwhere sal>=2000and sal<=3000;

模糊查询like,%,_

select ename,salfrom emp t   where t.enamelike'%S%';

select ename,salfrom emp t where t.enamelike'_O%';

in的使用

select sal,enamefrom emp twhere t.salin(800,1600)

is null的使用

select *from empwhere mgrisnull;

猜你喜欢

转载自xty88645.iteye.com/blog/1940171