我有两个列的表MYTABLE:A和B.
我有以下几段代码:
SELECT MYTABLE.A FROM MYTABLE HAVING SUM(MYTABLE.B) > 100 GROUP BY MYTABLE.A
和
SELECT MYTABLE.A FROM MYTABLE GROUP BY MYTABLE.A HAVING SUM(MYTABLE.B) > 100
它是一样的吗?这两个代码是否有可能返回不同的结果集?
先感谢您
解决方法
据记载,没有区别.人们习惯于在GROUP BY之后看到HAVING.
http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10002.htm#SQLRF20040
Specify GROUP BY and HAVING after the where_clause and hierarchical_query_clause. If you specify both GROUP BY and HAVING,then they can appear in either order.