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】
分享到:
相关推荐
- **语法**: `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 ...
- **语法**: `SELECT COUNT(column_name) FROM table_name;` - **示例**: 计算`Store_Information`表中有多少条记录。 - **命令**: `SELECT COUNT(*) FROM Store_Information;` **2. GROUP BY** - **功能**: 将...
- **语法**:`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...
- **语法**:`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...
- **语法**:`SELECT COUNT(column_name) FROM table_name` - **示例**:计算`Store_Information`表中有多少条记录。 ```sql SELECT COUNT(*) FROM Store_Information; ``` ##### 10. GROUP BY - **用途**:将...
- **分组**: `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 ...
- **`SELECT COUNT(column_name) FROM table_name WHERE condition;`**:计算满足条件的记录数。 - **字符串函数**:如`UPPER`, `LOWER`, `LENGTH`, `SUBSTRING`等。 - **`SELECT UPPER(column_name) FROM table_...
- **示例**:`COUNT(column_name)`计算特定列的非空值数量。 10. **GROUP BY**: - **功能**:用于结合具有相同值的行作为一组。 - **语法**:`SELECT column_name, aggregate_function(column_name) FROM table...
- **统计**: `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 ...
- `SELECT column_name, COUNT(column_name) FROM table_name GROUP BY column_name HAVING COUNT(column_name) > 5;` #### INTO Clause INTO 子句用于将查询结果插入到新表中。 - **语法**: - `SELECT column_...
- **语法**:`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_...
- **计数**: `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 ...
- 示例: `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;...
- **基本语法**:`SELECT column_name, COUNT(column_name) FROM table_name GROUP BY column_name;` - **示例**:`SELECT Name, COUNT(*) FROM Users GROUP BY Name;` - **4. 子查询** - **用途**:在一个查询中...
- **语法**:`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';` #### 综合...
- **语法**:`SELECT column_name(s) FROM table_name WHERE column_name IN (value1, value2, ...);` - **示例**:查找洛杉矶或圣地亚哥的店铺信息: ```sql SELECT * FROM Store_Information WHERE store_name ...
例如,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(别名)**: - 用于给表或者列取一个临时的名称。 ...
- **语法**: `SELECT column_name, aggregate_function(column_name) FROM table_name GROUP BY column_name;` - **说明**: 分组可以对数据进行分类统计。 - **示例**: `SELECT Department, COUNT(EmployeeID) ...
- **聚合函数**:`COUNT(*)`, `SUM(column_name)`, `AVG(column_name)`, `MAX(column_name)`, `MIN(column_name)` - **示例**:`SELECT COUNT(*), AVG(age) FROM employees GROUP BY department;` #### 2. 排序 - *...