码字定式之SQL(2)
select * from emp;
select * from emp where empno>8000;
select empno,ename,sal,comm from emp where sal<comm;
select deptno,count(*) from emp group by deptno;
select deptno,sum(sal) total_sal from emp where job=‘MANAGER‘ group by deptno;
select job,count(distinct deptno) from emp where mgr is not null group by job order by job;
select job,count(distinct deptno) from emp where mgr is not null group by job order by count(distinct deptno) desc,job;
select job, count(distinct deptno) uniq_deptno from emp where mgr is not null group by job order by uniq_deptno desc, job;
select deptno, to_char(hiredate,‘yyyy‘),count(*) from emp group by deptno,to_char(hiredate,‘yyyy‘);
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。