-
select count (distinct 列名) from 表名查看全部
-
重點關注查看全部
-
?分組函數? AVG,SUM,MIN,MAX,COUNT,WM_CONCAT
字符串的拼接? concat
查看全部 -
找到員工表中薪水大于本部門平均薪水的員工
select empno,ename,sal
from emp e
where sal>(select avg(sal) from emp where deptno=e.deptno);
查看全部 -
兩個查詢嵌套,把其中一個select當做條件
?? ?select *
?? ?from emp
?? ?where sal > (select sal
?? ??? ??? ??? ? from emp
?? ??? ??? ??? ? where ename='SCOTT');查看全部 -
清屏 host cls查看全部
-
avg 平均值
sum 總和
select avg(sal),sum(sal) from emp;
min 最小值
max 最大值
select min(sal),max(sal) from emp;
count 總數
select count(*) from emp;
select count(empno) from emp;
distinct 去掉重復值:
select count(distinct deptno) from emp;
wm_concat 行轉列:
select deptno,wm_concat(ename) from emp group by deptno;
count(comm) 去掉空值:
select count(comm) from emp;
rollup?
groupby語句增強
語法:group by rollup(a,b)
等同于:group by a,b
+
group by a
+
group by null
?select deptno,job,sum(sal)
?from emp group by rollup(deptno,job);
group by rollup分組等價于 group by deptno +group by job+null group by null
查看全部 -
order by 順序(小到大排序)
查看全部 -
oracle分頁查詢
1嵌套子查詢方式實現2 rownum只能< <=,不能> >=,
實例分頁查詢員工信息每頁最多顯示四條信息,顯示第二頁信息 ? ? ? ? ? ??
?? select r,empno,ename,sal
????????from????(?select rownum???r,empno,ename,sal
???????????????from?(?select? rownum,empno,ename,sal from emp order by sal desc) e1
????????????????????where rownum<=8)????e2
where r>=5;
查看全部 -
數據庫高級查詢語句查看全部
-
decode函數可以用于字符串處理查看全部
-
多行操作符 any in all查看全部
-
分頁查詢:
select r,empno,ename,sal
from (select rownum r,empno,ename,sal
? ?FROM (select ROWNUM,E.* from emp E order by sal desc) e1
? ?where rownum <=8)e2
? ?where r>5;
查看全部 -
1.查詢不是老板的員工:
select *
from emp
where empno not in (select mgr from emp where mgr is not null);
2.not in(結果集):注意not in 后面括號里的結果集不能有空值,必須想辦法過濾掉空值
查看全部 -
單行子查詢只能使用單行操作符;多行子查詢只能使用多行操作符
查看全部
舉報