-
子查詢還是少用的好因為損耗性能查看全部
-
order by number,number數字,代表查詢出的第幾個字段查看全部
-
求平均值時用三種方式: SUM(FIELD)/COUNT(*),SUM(FIELD)/COUNT(FIELD),AVG(FIELD) 如果字段有空值,AVG時和COUNT(FIELD)時,不會統計進去,count(*)時會統計查看全部
-
count結合distinct,重復的只記一次,select count(distinct field) from table;查看全部
-
GROUP BY 中選擇的非組函數列必須全部出現在 GROUP BY 中查看全部
-
嵌套函數的使用。查看全部
-
select c.ci_id ,wm_concat(c.stu_name) stu_name from (select a.ci_id, b.stu_name from pm_ci a ,pm_stu b where instr(stu_ids,b.stu_id) !=0 ) c group by c.ci_id查看全部
-
a not in(10,20,null)相當于a!=10 and a!=20 and a!=null,然而a!=null永遠為假, 所以要排除空值,判斷是否是null值,只能用is or is not而不能用= 或者!=。 select * from emp where empno not in (select mgr from emp where mgr is not null);查看全部
-
子查詢必須有小括號(子查詢必須有小括號)查看全部
-
select last_name,employee_id,department_name,department_id from employees e,departments d where e.department_id = d.department_id; 等值連接查看全部
-
select avg(salary),sum(salary) from employees; select min(salary),max(salary),sum(salary) from employees; select count(*) from employees; select count(distinct department_id) from departments;查看全部
-
多表查詢; 兩個方法的結果一樣,如何比較優劣 通過比較select語句的執行計劃:explain plan for,一般放在開頭,執行結束之后如何查看explain生成的執行計劃:select * from table(dbms_xplan.display);可以打印查看執行計劃,一般放在末尾 然后看耗費了多少CPU的執行資源,結果發現使用相關子查詢比多表查詢耗費的CPU資源要少查看全部
-
a not in(10,20,null)相當于a!=10 and a!=20 and a!=null,然而a!=null永遠為假, 所以要排除空值,判斷是否是null值,只能用is or is not而不能用= 或者!=。 select * from emp where empno not in (select mgr from emp where mgr is not null);查看全部
-
一般先執行子查詢,再執行主查詢;但相關子查詢例外 相關子查詢,外表必須起別名,傳遞給子查詢 select empno,ename,sal,(select avg(sal) from emp where deptno=e.deptno) avgsal from emp e where sal>(select avg(sal) from emp where deptno=e.deptno);查看全部
-
行號永遠按照默認的順序生成 行號只能使用<,<=;不能使用>,>=查看全部
舉報
0/150
提交
取消