手敲数据库练习

select deptno,job,count(*)
from emp
group by deptno,job;

select job,sum(sal)
from emp
group by job 
havingsum(sal)>5000
order by sum(sal);

select deptno,AVG(sal)
from emp
group by deptnohaving AVG(sal)<(select AVG(sal
from emp
where deptno=20))

select ename,sal
from (select ename,sal,rownuw
      from emp
      order by sal)
 where rownuw<=5;

 select ename,sal,job
 from (select a.*,rownuw rn 
 	   from (select*
 	   	     from emp
 	   	      order by sal desc)a)
 where rn between 5 and 8;

 select ename,sal
 from emp
 where sal>1600;

 select ename,deptno
 from emp
 where empno=7369;

 select ename,sal
 from emp
 where sal not between 4000 and 6000;

 

你可能感兴趣的:(sql)