以SCOTT用户下的表,实现以下查询:
1、假设大家6个月后毕业,计算毕业的日期
select add_months('20-6月-11',6) from dual;
2、查询入职超过300个月的员工信息
select * from emp where months_between(sysdate,hiredate)>300;
select * from emp where sysdate>add_months(hiredate,300);
3、查询每个员工入职的天数
select sysdate-hirdate 入职天数 from emp;
4、查询每月最后一天入职的员工信息
select * from emp where hiredate=last_day(hiredate);
5、查询2月份入职的员工信息
select * from emp where extract(month from hiredate)=2;
6、查询所有员工姓名的小写形式
select lower(ename) from emp;
7、以首字母大写、其他字母小写的方式显示所有员工的姓名
select initcap(ename) from emp;
8、查询姓名长度为5的员工信息
select * from emp where length(ename)=5;
9、查询所有员工姓名的前3个字符
select substr(ename,1,3) from emp;
10、将所有员工岗位中的‘S’字符替换为‘5’
select replace(job,'S','5') from emp;
11、查询所有员工的年薪(sal*13+comm*13)
select sal*13+nvl(comm,0)*13 年薪 from emp;
12、查询员工中最高工资和最低工资
select max(sal) 最高工资,min(sal) 最低工资 from emp;
13、查询员工的平均工资和工资总和
select avg(sal) 平均工资,sum(sal) 工资总和 from emp;
14、统计共有多少员工
select count(*) from emp;
15、统计有奖金的员工个数
select count(comm) from emp;
1、假设大家6个月后毕业,计算毕业的日期
select add_months('20-6月-11',6) from dual;
2、查询入职超过300个月的员工信息
select * from emp where months_between(sysdate,hiredate)>300;
select * from emp where sysdate>add_months(hiredate,300);
3、查询每个员工入职的天数
select sysdate-hirdate 入职天数 from emp;
4、查询每月最后一天入职的员工信息
select * from emp where hiredate=last_day(hiredate);
5、查询2月份入职的员工信息
select * from emp where extract(month from hiredate)=2;
6、查询所有员工姓名的小写形式
select lower(ename) from emp;
7、以首字母大写、其他字母小写的方式显示所有员工的姓名
select initcap(ename) from emp;
8、查询姓名长度为5的员工信息
select * from emp where length(ename)=5;
9、查询所有员工姓名的前3个字符
select substr(ename,1,3) from emp;
10、将所有员工岗位中的‘S’字符替换为‘5’
select replace(job,'S','5') from emp;
11、查询所有员工的年薪(sal*13+comm*13)
select sal*13+nvl(comm,0)*13 年薪 from emp;
12、查询员工中最高工资和最低工资
select max(sal) 最高工资,min(sal) 最低工资 from emp;
13、查询员工的平均工资和工资总和
select avg(sal) 平均工资,sum(sal) 工资总和 from emp;
14、统计共有多少员工
select count(*) from emp;
15、统计有奖金的员工个数
select count(comm) from emp;