sql中count(0),count(1),count(),count(列名)
来源:互联网 发布:毁灭战士4优化 贴吧 编辑:程序博客网 时间:2024/05/20 05:28
count(0) count(1) count(*) count(列名)
--创建测试表
create table tb(id varchar(10))
--插入非空数据
insert tb select 'test'
go
--测试
select count(0) as 'count(0)',count(1) as 'count(1)',count(*) as 'count(*)',count(id) as 'count(id)' from tb
--结果
/*
count(0) count(1) count(*) count(id)
1 1 1 1
*/
--插入null值
insert tb values(null)
go
--测试
select count(0) as 'count(0)',count(1) as 'count(1)',count(*) as 'count(*)',count(id) as 'count(id)' from tb
--结果
/*
count(0) count(1) count(*) count(id)
2 2 2 1
*/
--插入空值
insert tb values ('')
go
--测试
select count(0) as 'count(0)',count(1) as 'count(1)',count(*) as 'count(*)',count(id) as 'count(id)' from tb
--结果
/*
count(0) count(1) count(*) count(id)
3 3 3 2
*/
--结论
/*
count(0)=count(1)=count(*) --不忽略null值和空值
count(列名) --忽略null值
*/
--创建测试表
create table tb(id varchar(10))
--插入非空数据
insert tb select 'test'
go
--测试
select count(0) as 'count(0)',count(1) as 'count(1)',count(*) as 'count(*)',count(id) as 'count(id)' from tb
--结果
/*
count(0) count(1) count(*) count(id)
1 1 1 1
*/
--插入null值
insert tb values(null)
go
--测试
select count(0) as 'count(0)',count(1) as 'count(1)',count(*) as 'count(*)',count(id) as 'count(id)' from tb
--结果
/*
count(0) count(1) count(*) count(id)
2 2 2 1
*/
--插入空值
insert tb values ('')
go
--测试
select count(0) as 'count(0)',count(1) as 'count(1)',count(*) as 'count(*)',count(id) as 'count(id)' from tb
--结果
/*
count(0) count(1) count(*) count(id)
3 3 3 2
*/
--结论
/*
count(0)=count(1)=count(*) --不忽略null值和空值
count(列名) --忽略null值
*/
阅读全文
0 0
- sql中count(0),count(1),count(),count(列名)
- count(*) 和 count(1)和count(列名)区别
- count(*) 和 count(1)和count(列名)区别
- select count(*) 和 count(1),count(列名)区别
- count(*)、count(1)和count(列名)
- count(1)、count(*)与count(列名)的执行区别
- count(*) 和 count(1)和count(列名)区别
- count(),count(1),count(*)
- mysql中count(*)、count(列)、count(1)分析
- 【数据库】count(*),count(1)和count(列)
- sql语句中count(*)与count(1)以及count(字段名)的异同点
- SQL Server中count(*), count(col), count(1)的对比
- SQL Server中count(*), count(col), count(1)的对比
- SQL Server中count(*), count(col), count(1)的对比
- sql语句中count(*),count(1),count(id)区别详解
- sql server中count(*),count(col),count(1)的区别
- sql语句中count(*),count(1),count(id)区别详解
- sql count(*) count(1)count(colnum)区别
- sql 中的 coalesce
- Executor,Executors,ExecutorService
- 响应头过长
- jQuery 之 两个div之间切换
- Android Telephony分析(一) ---- Phone详解
- sql中count(0),count(1),count(),count(列名)
- tomcat服务器配置字符集为utf-8-彻底解决中文乱码问题
- 仿饿了么 问题集
- libuv download
- merge into delete的语法
- nginx 配置https 并兼容http 或强制http 转为https
- fragment在activity里面实例化
- properties文件的配置加载
- Android Studio的Gradle的加速