zoukankan      html  css  js  c++  java
  • Oracle 中count(1) 和count(*) 的区别

    count详解:    

    count(*)将返回表格中所有存在的行的总数包括值为null的行,然而count(列名)将返回表格中除去null以外的所有行的总数(有默认值的列也会被计入).  

    distinct 列名,得到的结果将是除去值为null和重复数据后的结果  

    举例演示如下:  

    SQL> create table test  

    2 (  

    3 ename varchar2(10),  

    4 sal number(4)  

    5 );  

    表已创建。  

    SQL> insert into test values('fxe1',90);  

    已创建 1 行。  

    SQL> insert into test(ename) values('fxe2');  

    已创建 1 行。  

    SQL> insert into test(ename) values('fxe3');  

    已创建 1 行。  

    SQL> insert into test(ename) values('fxe4');  

    已创建 1 行。  

    SQL> insert into test values('fxe5',80);  

    已创建 1 行。  

    SQL> insert into test values('fxe6',80);  

    已创建 1 行。  

    SQL> select * from test;  

    ENAME SAL  

    ---------- ----------  

    fxe1 90  

    fxe2  

    fxe3  

    fxe4  

    fxe5 80  

    fxe6 80  

    SQL> select count(*) from test;  

    COUNT(*)  

    ----------  

    6  

    SQL> select count(sal) from test;  

    COUNT(SAL)  

    ----------  

    3  

    SQL> select count(distinct sal) from test;  

    COUNT(DISTINCTSAL)  

    ------------------  

    2  

    SQL> select distinct sal from test;  

    SAL  

    ----------  

    80  

    90  

     

     

  • 相关阅读:
    Python环境变量的配置
    关于selenium+python的googledirver和iedirver的配置
    jdk1.6环境变量配置
    windows server 2012R2安装激活码
    Git生成SSHKey
    Linux下配置和安装VNCServer远程服务
    Win7 64位硬盘安装Ubuntu 64位的细微配置
    apache tomcat 8.0 显示目录文件
    跨域登录
    jsonp 代码优化
  • 原文地址:https://www.cnblogs.com/lidan90/p/6157942.html
Copyright © 2011-2022 走看看