
如果查詢中包括聚合函數,而所選擇的列并不在聚合函數中, 那么這些列就必須在GROUP BY子句中。否則將會出現如下錯誤:ORA-00937: not a single-group group function

不能在WHERE子句中使用聚合函數來限制行。否則將會出現如下錯誤:ORA-00934: group function is not allowed here

GROUP BY可以不與HAVING一起使用,但HAVING必須與GROUP BY一起使用

W-G-H的執行順序





2. GROUP BY對保留的行進行分組
3. HAVING對分組進行過濾

子查詢不能包含ORDER BY

雙引號直接用:'The "Great" Gatsby' (表示字符串 The "Great" Gatsby )
單引號要轉義:'O''Malley' (表示字符串 O'Malley )

select column1,column2 from table
insert into table(column1,column2) values('a','b')
update table set column1='a' where column2='b'
delete from table where column1='a'

--外連接,使用叉積表達有歧義,不運行:查詢中包含不允許的外聯接請求。
select * from a,b,c
??????? where a.a_id*=b.a_id
??????????? and b.b_id*=c.b_id
--這樣就不存在歧義性了
select * from a
??? LEFT OUTER JOIN b on (a.a_id=b.a_id)
??? LEFT OUTER JOIN c on (b.b_id=c.b_id)