oracle group by與分組列為null空

wisdomone1發表於2012-12-19
SQL> create table t_group(a int,b int);
Table created
SQL> insert into t_group values(null,1);
1 row inserted
SQL> insert into t_group values(null,2);
1 row inserted
SQL> insert into t_group values(1,2);
1 row inserted
SQL> insert into t_group values(3,2);
1 row inserted
SQL> commit;
Commit complete
SQL> select * from t_group;
                                      A                                       B
--------------------------------------- ---------------------------------------
                                                                              1
                                                                              2
                                      1                                       2
                                      3                                       2
SQL> select a,count(b) from t_group  group by a;
                                      A   COUNT(B)
--------------------------------------- ----------
                                                 2
                                      1          1
                                      3          1

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-751370/,如需轉載,請註明出處,否則將追究法律責任。

相關文章