复制当前所有,ID自动增长。 insert into test(name,pass) select name,pass from test
删除当前重复 delete A from test A,test B where A.name = B.name and A.pass = B.pass and A.ID > B.ID
平均薪水大于5000元的部门数据 select deptno,avg(nvl(salary,0)) avg_s from emp_ning where deptno is not null group by deptno having avg(nvl(salary,0)) >> 5000
计算每个部门的薪水综合和平均薪水 select deptno,sum(salary) sum_s,avg(nvl(salary,0)) avg_s from emp_ning group_by deptno
按部门计算每个部门的最高和最低薪水分别是多少 select deptno,max(salary) max_s,min(salary) min_s from emp_ning group by deptno;
按部门排序,同一个部门按薪水由高到低排序。 select ename,deptno,salary from emp_ning order by deptno,salary desc;
计算员工的平均薪水和薪水总和是多少。 select avg(salary) avg_sal,sum(salary) sum_sal from emp_ning;
计算员工的最高薪水和最低薪水 select max(salary) max_sal,min(salary)min_sal from emp_ning;
模糊查询 select * from emp_ning where job like '%sales%'
in(list),在列表中 select * from emp_ning where job in ('sds','asd');
系统时间 select sysdate from dual;
把时间按照指定格式输出 select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
select to_char(sysdate,'year month dd day dy') from dual;
日期相减 select ename,hiredate,(sysdate - hiredate) from emp;