`
can_do
  • 浏览: 265988 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

count(*)与count(column_name)的区别

阅读更多
count(*)===>表的记录数,与某个字段是否为空无关
count(column_name)===>如果当前列有空,则会剔除掉该列为空的那些行

可以参看以下实验结果:
SQL> select count(*) from table_name t where t.lvx_id is null;

COUNT(*)
----------
         9

SQL> select count(t.lvx_id) from table_name t where t.lvx_id is null;

COUNT(T.LVX_ID)
---------------
              0

SQL>

【编写于 2009-01-20】
分享到:
评论

相关推荐

    SQL语句基础教程.doc

    - **语法**: `SELECT AVG(column_name) AS 'Median' FROM (SELECT column_name FROM table_name ORDER BY column_name LIMIT 2 - (SELECT COUNT(*) FROM table_name) % 2 OFFSET (SELECT (COUNT(*) - 1) / 2 FROM ...

    SQL学习教程

    - **语法**: `SELECT COUNT(column_name) FROM table_name;` - **示例**: 计算`Store_Information`表中有多少条记录。 - **命令**: `SELECT COUNT(*) FROM Store_Information;` **2. GROUP BY** - **功能**: 将...

    SQL语句教程

    - **语法**:`SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name HAVING COUNT(*) > 1;` - **示例**:`SELECT store_name, COUNT(*) FROM Store_Information GROUP BY store_name HAVING COUNT...

    sql学习资料,总结的很好

    - **语法**:`SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name HAVING COUNT(*) > 1;` - **示例**:`SELECT store_name, COUNT(*) FROM Store_Information GROUP BY store_name HAVING COUNT...

    SQL语句教程【经典】

    - **语法**:`SELECT COUNT(column_name) FROM table_name` - **示例**:计算`Store_Information`表中有多少条记录。 ```sql SELECT COUNT(*) FROM Store_Information; ``` ##### 10. GROUP BY - **用途**:将...

    SQL入门教程大全2024

    - **分组**: `SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name;` - **计算统计信息**: `SELECT column_name, SUM(column_name), AVG(column_name), MAX(column_name), MIN(column_name) FROM ...

    图文并茂的SQL用法

    - **`SELECT COUNT(column_name) FROM table_name WHERE condition;`**:计算满足条件的记录数。 - **字符串函数**:如`UPPER`, `LOWER`, `LENGTH`, `SUBSTRING`等。 - **`SELECT UPPER(column_name) FROM table_...

    sql语句最强教程-各种情况都包含

    - **示例**:`COUNT(column_name)`计算特定列的非空值数量。 10. **GROUP BY**: - **功能**:用于结合具有相同值的行作为一组。 - **语法**:`SELECT column_name, aggregate_function(column_name) FROM table...

    mysql命令整合和各种情况介绍

    - **统计**: `SELECT COUNT(column_name) AS total_count FROM table_name;` - **求和**: `SELECT SUM(column_name) AS sum_value FROM table_name;` - **平均值**: `SELECT AVG(column_name) AS avg_value FROM ...

    SQL Server 2012 Transact-SQL DML Reference

    - `SELECT column_name, COUNT(column_name) FROM table_name GROUP BY column_name HAVING COUNT(column_name) > 5;` #### INTO Clause INTO 子句用于将查询结果插入到新表中。 - **语法**: - `SELECT column_...

    非常好的sql语句入门教程

    - **语法**:`SELECT column_name FROM table_name WHERE column_name IN (SELECT column_name FROM other_table);` - **示例**:`SELECT store_name FROM Store_Information WHERE store_name IN (SELECT store_...

    sql用法大全,包含sql多种基本用法

    - **计数**: `SELECT COUNT(column_name) AS total_count FROM table_name;` - **求和**: `SELECT SUM(column_name) AS sum_value FROM table_name;` - **平均值**: `SELECT AVG(column_name) AS avg_value FROM ...

    Oracle数据库SQL学习教程

    - 示例: `SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name HAVING COUNT(*) > 1;` **2.1.13 ALIAS** - 用于为表或列名创建别名。 - 示例: `SELECT column_name AS alias_name FROM table_name;...

    SQL语法大全

    - **基本语法**:`SELECT column_name, COUNT(column_name) FROM table_name GROUP BY column_name;` - **示例**:`SELECT Name, COUNT(*) FROM Users GROUP BY Name;` - **4. 子查询** - **用途**:在一个查询中...

    SQL语句教程.doc

    - **语法**:`SELECT column_name(s) FROM table_name WHERE condition1 AND/OR condition2;` - **示例**:`SELECT store_name FROM Store_Information WHERE Sales > 1000 AND Date = 'Jan-05-1999';` #### 综合...

    sql server 之sql语句教程

    - **语法**:`SELECT column_name(s) FROM table_name WHERE column_name IN (value1, value2, ...);` - **示例**:查找洛杉矶或圣地亚哥的店铺信息: ```sql SELECT * FROM Store_Information WHERE store_name ...

    《数据库原理及应用》教案12:分组、排序.pdf

    例如,SELECT column_name, COUNT(*) FROM table_name GROUP BY column_name HAVING COUNT(*) > 10,可以对分组后的结果进行过滤,只保留记录数量大于10的分组。 三、查询结果集的排序 查询结果集的排序是指对查询...

    数据库教程

    - **基本格式**:`SELECT column_name(s) FROM table_name WHERE column_name BETWEEN value1 AND value2;` - 用于选取位于两个值之间的记录。 - **SQL Alias(别名)**: - 用于给表或者列取一个临时的名称。 ...

    SQL语句大全

    - **语法**: `SELECT column_name, aggregate_function(column_name) FROM table_name GROUP BY column_name;` - **说明**: 分组可以对数据进行分类统计。 - **示例**: `SELECT Department, COUNT(EmployeeID) ...

    Mysql最经典的语句集合

    - **聚合函数**:`COUNT(*)`, `SUM(column_name)`, `AVG(column_name)`, `MAX(column_name)`, `MIN(column_name)` - **示例**:`SELECT COUNT(*), AVG(age) FROM employees GROUP BY department;` #### 2. 排序 - *...

Global site tag (gtag.js) - Google Analytics