重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
SQL> SELECT avg(sal) FROM emp;
AVG(SAL)
2135
SQL> SELECT MIN(sal) FROM emp;
MIN(SAL)
800
SQL> SELECT MIN(sal) FROM emp;
MIN(SAL)
800
SQL> SELECT COUNT(*) FROM emp;
COUNT(*)-
15
SQL> select count(distinct deptno) from emp;
COUNT(DISTINCTDEPTNO)
3
SQL> select wm_concat(ename) from emp;
WM_CONCAT(ENAME)
EASON,G_EASON,ALLEN,WARD,JONES,MARTIN,BLAKE,CLARK,SCOTT,KING,TURNER,ADAMS,JAMES,
FORD,MILLER
SQL> SELECT deptno, avg(sal) from emp group by deptno;
DEPTNO AVG(SAL)
30 1566.66667
20 2312.5
10 2916.66667
SQL> SELECT deptno, job, avg(sal) from emp group by deptno, job;
DEPTNO JOB AVG(SAL)
20 CLERK 950
30 SALESMAN 1400
20 MANAGER 2975
30 CLERK 950
10 PRESIDENT 5000
30 MANAGER 2850
10 CLERK 1300
20 ANALYST 3000
10 MANAGER 2450
已选择9行。
SQL> select avg(sal) from emp group by deptno;
AVG(SAL)
1566.66667
2312.5
2916.66667
SQL> select deptno, WM_concat(ename) from emp group by deptno;
DEPTNO WM_CONCAT(ENAME)
10 CLARK,MILLER,KING
20 EASON,FORD,ADAMS,SCOTT,JONES,G_EASON
30 ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD
SQL> select deptno,avg(sal) from emp group by deptno having avg(sal) >2500;
DEPTNO AVG(SAL)
10 2916.66667
SQL> select deptno, avg(sal) from emp where deptno=10 group by deptno;
DEPTNO AVG(SAL)
10 2916.66667
SQL> select max(avg(sal)) from emp group by deptno;
MAX(AVG(SAL))
2916.66667