实用T-SQL代码
2024-09-29 01:06:32
1.根据出生日期计算当前已满周岁
DECLARE @birth datetime
SET @birth='1990-01-01'
SELECT (cast(convert(char( 8 ),GETDATE(),112) as int) - cast(convert(char(8),@birth,112) as int))/10000
2.COUNT(expression) just returns the total number of rows in which that expression is not null.
COUNT函数返回值不为null的行数。
ID | FullName |
1 | NULL |
2 | NULL |
SELECT COUNT(1) FROM t1 -- Returns 2
SELECT COUNT(FullName) FROM t1 -- Returns 0
COUNT(expression) just returns the total number of rows in which that expression is not null. - See more at: http://www.sqlteam.com/article/how-to-use-group-by-in-sql-server#sthash.b6O058Mg.dpuf
(持续更新中)
最新文章
- 利用Jquery获取、设置iframe中元素
- Twentydaysgone
- oracle中merge方法
- R12.2 URL Validation failed. The error could have been caused through the use of the browser's navigation buttons
- WaitForMultipleObjects返回失败原因之一
- 【转】bind - DNS 設定
- iOS10权限声明国际化
- [css] 【转载】 精简高效的CSS命名准则/方法
- SQL查询(笔记2——实体查询)
- CSS 样式二
- php拓展ssh功能
- 在Azure Cloud Service中部署Java Web App(2)
- MySQL分区表的局限和限制
- Openning
- linux atoi
- ios安装ipa与安卓安装apk
- C# EF 与 MySql 的那些坑
- Python Number 类型转换
- mysql 5.7 基于GTID 主从同步的1236故障处理(其它事务故障等同)
- SpringMVC工作原理详解