In Oracle, having must be used in combination with groupby, but in mysql, the situation is different and can be used separately. C: DocumentsandSettingsguogangsqlplustesttestSQL * Plus: Release102010 in Oracle, having must be used in combination with group by, but in mysql, the situation is different and can be used separately.
C: \ Documents Ents and Settings \ guogang> sqlplus test/test
SQL * Plus: Release 10.2.0.1.0-Production on Tuesday August 12 09:09:58 2014
Copyright (c) 1982,200 5, Oracle. All rights reserved.
Connect:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select * from test1 having owner = 'sys ';
Select * from test1 having owner = 'sys'
*
Row 3 has an error:
ORA-00979: not a group by expression
SQL> select owner, count (1) from test1 group by owner having owner = 'sys ';
Owner count (1)
----------------------------------------
SYS 30754
Mysql> select * from test having id> 98;
+ ------ + ------------- +
| Id | create_time |
+ ------ + ------------- +
| 99 | 2014-08-12 |
| 100 |
+ ------ + ------------- +
2 rows in set (0.00 sec)
Mysql> select id, count (1) from test group by id having id> 98;
+ ------ + ---------- +
| Id | count (1) |
+ ------ + ---------- +
| 99 | 1 |
| 1 | 100 |
+ ------ + ---------- +
2 rows in set (0.00 sec)