---- having 子句對 group by 子句所確定的行組進行控制,having 子句條件中只允許涉及常量,聚組函數或group by 子句中的列.
---- 2.外部聯結"+"的用法
---- 外部聯結"+"按其在"="的左邊或右邊分左聯結和右聯結.若不帶"+"運算子的表中的一個行不直接匹配於帶"+"預算符的表中的任何行,則前者的行與後者中的一個空行相匹配並被返回.若二者均不帶'+',則二者中無法匹配的均被返回.利用外部聯結"+",可以替代效率十分低下的 not in 運算,大大提高運行速度.例如,下面這條命令執行起來很慢
select a.empno from emp a where a.empno not in
(select empno from emp1 where job='SALE');
---- 倘若利用外部聯結,改寫命令如下:
select a.empno from emp a ,emp1 b
where a.empno=b.empno(+)
and b.empno is null
and b.job='SALE';
---- 可以發現,運行速度明顯提高.
---- 3.刪除表內重複記錄的方法
---- 可以利用這樣的命令來刪除表內重複記錄:
delete from table_name a
where rowid< (select max(rowid) from table_name
where column1=a.column1 and column2=a.column2
and colum3=a.colum3 and ...);